Skip to content

Commit 2335640

Browse files
authored
Merge pull request #197 from scribe/collisonInArgs
Collison in args
2 parents 414f9b1 + feaffcd commit 2335640

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/ArgumentFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public final class ArgumentFactory {
5757
public static final Option PREFIX = Option.builder("p").hasArg(true).argName("prefix")
5858
.desc("Used with get operations to restore only objects whose names start with prefix "
5959
+ "and with put operations, to prepend a prefix to object name(s)").build();
60-
public static final Option VERSION = Option.builder("v").argName("version")
60+
public static final Option SHOW_VERSIONS = Option.builder("sv").argName("show-versions").longOpt("show-versions")
6161
.desc("Show version information").build();
62-
public static final Option VERSIONID = Option.builder().longOpt("versionId").desc("Version ID value").hasArg(true)
62+
public static final Option VERSION_ID = Option.builder().longOpt("version-id").desc("Version ID value").hasArg(true)
6363
.build();
6464
public static final Option OBJECT_NAME = Option.builder("o").hasArg(true).argName("objectFileName")
6565
.desc("The name of the object to be retrieved or stored").build();

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/Arguments.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.common.collect.ImmutableList;
2020
import com.google.common.collect.ImmutableMap;
2121
import com.spectralogic.ds3cli.exceptions.BadArgumentException;
22-
import com.spectralogic.ds3cli.util.MetadataUtils;
2322
import com.spectralogic.ds3client.models.Priority;
2423
import com.spectralogic.ds3client.models.WriteOptimization;
2524
import org.apache.commons.cli.*;
@@ -306,8 +305,8 @@ public int getBufferSize() throws BadArgumentException {
306305

307306
// convenience getters for public options
308307
public String getBucket() { return this.getOptionValue(BUCKET.getOpt()); }
309-
public boolean getVersion() { return this.optionExists(VERSION.getOpt());}
310-
public String getVersionId() { return this.getOptionValue(VERSIONID.getLongOpt());}
308+
public boolean isShowVersions() { return this.optionExists(SHOW_VERSIONS.getOpt());}
309+
public String getVersionId() { return this.getOptionValue(VERSION_ID.getLongOpt());}
311310
public String getDirectory() { return this.getOptionValue(DIRECTORY.getOpt()); }
312311
public String getObjectName() { return this.getOptionValue(OBJECT_NAME.getOpt()); }
313312
public boolean isForce() { return this.optionExists(FORCE.getLongOpt()); }

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/command/GetBucket.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,40 @@
1919
import com.google.common.collect.ImmutableList;
2020
import com.spectralogic.ds3cli.Arguments;
2121
import com.spectralogic.ds3cli.View;
22-
import com.spectralogic.ds3cli.ViewType;
23-
import com.spectralogic.ds3cli.exceptions.BadArgumentException;
2422
import com.spectralogic.ds3cli.exceptions.CommandException;
2523
import com.spectralogic.ds3cli.models.GetBucketResult;
26-
import com.spectralogic.ds3cli.views.cli.GetBucketView;
2724
import com.spectralogic.ds3cli.views.json.DataView;
2825
import com.spectralogic.ds3client.commands.GetBucketRequest;
2926
import com.spectralogic.ds3client.commands.GetBucketResponse;
3027
import com.spectralogic.ds3client.commands.spectrads3.GetBucketSpectraS3Request;
3128
import com.spectralogic.ds3client.commands.spectrads3.GetBucketSpectraS3Response;
32-
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
3329
import com.spectralogic.ds3client.models.Bucket;
3430
import com.spectralogic.ds3client.models.Contents;
3531
import com.spectralogic.ds3client.networking.FailedRequestException;
36-
import com.spectralogic.ds3client.utils.Guard;
3732
import org.apache.commons.cli.Option;
3833

3934
import java.util.List;
4035

4136
import static com.spectralogic.ds3cli.ArgumentFactory.BUCKET;
4237
import static com.spectralogic.ds3cli.ArgumentFactory.PREFIX;
43-
import static com.spectralogic.ds3cli.ArgumentFactory.VERSION;
38+
import static com.spectralogic.ds3cli.ArgumentFactory.SHOW_VERSIONS;
4439

4540
public class GetBucket extends CliCommand<GetBucketResult> {
4641

4742
private final static ImmutableList<Option> requiredArgs = ImmutableList.of(BUCKET);
48-
private final static ImmutableList<Option> optionalArgs = ImmutableList.of(PREFIX, VERSION);
43+
private final static ImmutableList<Option> optionalArgs = ImmutableList.of(PREFIX, SHOW_VERSIONS);
4944

5045
private String bucket;
5146
private String prefix;
52-
private boolean version;
47+
private boolean showVersion;
5348

5449
@Override
5550
public CliCommand init(final Arguments args) throws Exception {
5651
processCommandOptions(requiredArgs, optionalArgs, args);
5752

5853
this.bucket = args.getBucket();
5954
this.prefix = args.getPrefix();
60-
this.version = args.getVersion();
55+
this.showVersion = args.isShowVersions();
6156
return this;
6257
}
6358

@@ -67,23 +62,23 @@ public GetBucketResult call() throws Exception {
6762
try {
6863
// GetBucketDetail to get both name and id
6964
GetBucketRequest getBucketRequest = new GetBucketRequest(bucket);
70-
getBucketRequest.withVersions(version);
65+
getBucketRequest.withVersions(showVersion);
7166
getBucketRequest.withPrefix(prefix);
7267
final GetBucketSpectraS3Request getBucketSpectraS3Request = new GetBucketSpectraS3Request(bucket);
7368
final GetBucketSpectraS3Response response = getClient().getBucketSpectraS3(getBucketSpectraS3Request);
7469
final Bucket bucketDetails = response.getBucketResult();
7570
final GetBucketResponse bucket = getClient().getBucket(getBucketRequest);
7671

7772
final List<Contents> contents;
78-
if (version) {
73+
if (showVersion) {
7974
contents = bucket.getListBucketResult().getVersionedObjects();
8075
} else {
8176
contents = bucket.getListBucketResult().getObjects();
8277
}
8378

8479
return new GetBucketResult(bucketDetails, contents);
85-
} catch(final FailedRequestException e) {
86-
if(e.getStatusCode() == 404) {
80+
} catch (final FailedRequestException e) {
81+
if (e.getStatusCode() == 404) {
8782
throw new CommandException("Error: Unknown bucket.", e);
8883
}
8984
throw e;
@@ -96,7 +91,7 @@ public View<GetBucketResult> getView() {
9691
case JSON:
9792
return new DataView();
9893
default:
99-
if(version) {
94+
if (showVersion) {
10095
return new com.spectralogic.ds3cli.views.cli.GetVersionedBucketView();
10196
} else {
10297
return new com.spectralogic.ds3cli.views.cli.GetBucketView();

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/command/GetObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class GetObject extends CliCommand<DefaultResult> {
5151

5252
private final static ImmutableList<Option> requiredArgs = ImmutableList.of(BUCKET, OBJECT_NAME);
5353
private final static ImmutableList<Option> optionalArgs = ImmutableList.of(DIRECTORY, SYNC,
54-
FORCE, NUMBER_OF_THREADS, PRIORITY, RANGE_OFFSET, RANGE_LENGTH, DISCARD, FILE_METADATA, VERSIONID);
54+
FORCE, NUMBER_OF_THREADS, PRIORITY, RANGE_OFFSET, RANGE_LENGTH, DISCARD, FILE_METADATA, VERSION_ID);
5555

5656
private String bucketName;
5757
private String objectName;

0 commit comments

Comments
 (0)