Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Copyright 2014 Spectra Logic Corporation. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use
this file except in compliance with the License. A copy of the License is located at

http://www.apache.org/licenses/LICENSE-2.0

or in the "license" file accompanying this file.
This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
import java.nio.file.Files
import java.nio.file.Path

plugins {
id "com.github.hierynomus.license" version "0.11.0"
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'application'

version = '0.7.4-SNAPSHOT'
version = '0.7.5-SNAPSHOT'
group = 'com.spectralogic'

mainClassName = 'com.spectralogic.ds3cli.Main'
Expand All @@ -35,7 +39,7 @@ dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
compile 'commons-cli:commons-cli:1.2'
compile 'com.google.guava:guava:16.0.1'
compile 'com.spectralogic:ds3_java_sdk:0.7.4-SNAPSHOT'
compile 'com.spectralogic:ds3_java_sdk:0.7.5-SNAPSHOT'
testCompile 'com.googlecode.jmockit:jmockit:1.4'
testCompile 'junit:junit:4.11'
}
Expand All @@ -56,5 +60,5 @@ task genConfigProperties << {
jar.dependsOn genConfigProperties

task wrapper(type: Wrapper) {
gradleVersion = '2.0'
gradleVersion = '2.1'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jul 02 13:00:09 MDT 2014
#Wed Oct 15 12:25:55 MDT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
72 changes: 63 additions & 9 deletions src/main/java/com/spectralogic/ds3cli/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ public class Arguments {
private WriteOptimization defaultWriteOptimization;
private boolean clearBucket = false;
private boolean checksum = false;
private boolean certificateVerification = true;
private boolean https = true;

private String version = "N/a";
private String buildDate = "N/a";

Arguments(final String[] args) throws BadArgumentException, ParseException {
loadProperties();
this.args = args;
options = new Options();

Expand Down Expand Up @@ -102,6 +108,10 @@ public class Arguments {
defaultWriteOptimization.setArgName("writeOptimization");
final Option help = new Option("h", "Print Help Menu");
help.setLongOpt("help");
final Option http = new Option(null, "Send all requests over standard http");
http.setLongOpt("http");
final Option insecure = new Option(null, "Ignore ssl certificate verification");
insecure.setLongOpt("insecure");
final Option version = new Option(null, "Print version information");
version.setLongOpt("version");
final Option verbose = new Option(null, "Verbose output");
Expand All @@ -124,6 +134,8 @@ public class Arguments {
options.addOption(priority);
options.addOption(writeOptimization);
options.addOption(help);
options.addOption(insecure);
options.addOption(http);
options.addOption(version);
options.addOption(verbose);

Expand All @@ -136,14 +148,14 @@ public class Arguments {
}

private void processCommandLine() throws ParseException, BadArgumentException {

final CommandLineParser parser = new BasicParser();
final CommandLine cmd = parser.parse(options, args);

final List<String> missingArgs = new ArrayList<>();
if (cmd.hasOption("verbose")) {
Logging.setVerbose(true);
Logging.log("Verbose output has been enabled");
Logging.logf("Version: %s", this.version);
}

if (cmd.hasOption('h')) {
Expand All @@ -156,6 +168,14 @@ private void processCommandLine() throws ParseException, BadArgumentException {
System.exit(0);
}

if (cmd.hasOption("insecure")) {
setCertificateVerification(false);
}

if (cmd.hasOption("http")) {
setHttps(false);
}

final String retryString = cmd.getOptionValue("r");
try {
if (retryString != null) {
Expand Down Expand Up @@ -281,20 +301,38 @@ private Priority processPriorityType(final CommandLine cmd, final String priorit
}
}

private void printVersion() {
public String getVersion() {
return version;
}

public String getBuildDate() {
return buildDate;
}

private void loadProperties() {
final Properties props = new Properties();
final InputStream input = Arguments.class.getClassLoader().getResourceAsStream(PROPERTY_FILE);
if (input == null) {
System.err.println("Could not find property file.");
return;
}
try {
props.load(input);
System.out.println("Version: " + props.get("version"));
System.out.println("Build Date: " + props.get("build.date"));
} catch (final IOException e) {
System.err.println("Failed to load property file due to: " + e.getMessage());
else {
try {
props.load(input);
this.version = (String) props.get("version");
this.buildDate = (String) props.get("build.date");
} catch (final IOException e) {
System.err.println("Failed to load version property file.");
if (Logging.isVerbose()) {
e.printStackTrace();
}

}
}

}
private void printVersion() {
System.out.println("Version: " + getVersion() );
System.out.println("Build Date: " + getBuildDate());
}

public void printHelp() {
Expand Down Expand Up @@ -453,4 +491,20 @@ public WriteOptimization getDefaultWriteOptimization() {
private void setDefaultWriteOptimization(final WriteOptimization defaultWriteOptimization) {
this.defaultWriteOptimization = defaultWriteOptimization;
}

public boolean isCertificateVerification() {
return certificateVerification;
}

private void setCertificateVerification(final boolean certificateVerification) {
this.certificateVerification = certificateVerification;
}

public boolean isHttps() {
return https;
}

private void setHttps(final boolean https) {
this.https = https;
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/spectralogic/ds3cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ private Ds3Client createClient(final Arguments arguments) {
arguments.getEndpoint(),
new Credentials(arguments.getAccessKey(), arguments.getSecretKey())
)
.withHttpSecure(false).withRedirectRetries(arguments.getRetries());
.withHttps(arguments.isHttps())
.withCertificateVerification(arguments.isCertificateVerification())
.withRedirectRetries(arguments.getRetries());
if (arguments.getProxy() != null) {
builder.withProxy(arguments.getProxy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.spectralogic.ds3client.commands.DeleteObjectRequest;
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
import com.spectralogic.ds3client.models.Contents;

import com.spectralogic.ds3client.utils.SSLSetupException;
import org.apache.commons.cli.MissingOptionException;

import java.io.IOException;
Expand Down Expand Up @@ -57,7 +57,7 @@ public String call() throws Exception {
}
}

private String deleteBucket() throws SignatureException {
private String deleteBucket() throws SignatureException, SSLSetupException {
try {
getClient().deleteBucket(new DeleteBucketRequest(bucketName));
}
Expand All @@ -67,7 +67,7 @@ private String deleteBucket() throws SignatureException {
return "Success: Deleted bucket '" + bucketName + "'.";
}

private String clearObjects() throws SignatureException {
private String clearObjects() throws SignatureException, SSLSetupException {
// TODO when the multi object delete command has been added to DS3
// Get the list of objects from the bucket
Logging.log("Deleting objects in bucket first");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.spectralogic.ds3cli.Arguments;
import com.spectralogic.ds3client.Ds3Client;
import com.spectralogic.ds3client.commands.DeleteObjectRequest;

import org.apache.commons.cli.MissingOptionException;

import java.io.IOException;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/spectralogic/ds3cli/command/GetBulk.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.spectralogic.ds3client.models.bulk.Ds3Object;
import com.spectralogic.ds3client.models.bulk.Priority;
import com.spectralogic.ds3client.serializer.XmlProcessingException;

import com.spectralogic.ds3client.utils.SSLSetupException;
import org.apache.commons.cli.MissingOptionException;

import java.io.IOException;
Expand All @@ -54,6 +54,10 @@ public CliCommand init(final Arguments args) throws Exception {
throw new MissingOptionException("The bulk get command requires '-b' to be set.");
}

if (args.getObjectName() != null) {
System.out.println("Warning: '-o' is not used with bulk get and is ignored.");
}

final String directory = args.getDirectory();
if (directory == null || directory.equals(".")) {
this.outputPath = FileSystems.getDefault().getPath(".");
Expand Down Expand Up @@ -91,7 +95,7 @@ public String call() throws Exception {
}
}

private String restoreSome(final Ds3ClientHelpers.ObjectChannelBuilder getter) throws IOException, SignatureException, XmlProcessingException {
private String restoreSome(final Ds3ClientHelpers.ObjectChannelBuilder getter) throws IOException, SignatureException, XmlProcessingException, SSLSetupException {
final Ds3ClientHelpers helper = Ds3ClientHelpers.wrap(getClient());
final Iterable<Contents> contents = helper.listObjects(this.bucketName, this.prefix);
final Iterable<Ds3Object> objects = Iterables.transform(contents, new Function<Contents, Ds3Object>() {
Expand All @@ -110,7 +114,7 @@ public Ds3Object apply(final Contents input) {
return "SUCCESS: Wrote all the objects that start with '"+ this.prefix +"' from " + this.bucketName + " to " + this.outputPath.toString();
}

private String restoreAll(final Ds3ClientHelpers.ObjectChannelBuilder getter) throws XmlProcessingException, SignatureException, IOException {
private String restoreAll(final Ds3ClientHelpers.ObjectChannelBuilder getter) throws XmlProcessingException, SignatureException, IOException, SSLSetupException {
final Ds3ClientHelpers helper = Ds3ClientHelpers.wrap(getClient());
final Ds3ClientHelpers.Job job = helper.startReadAllJob(this.bucketName,
ReadJobOptions.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.spectralogic.ds3client.Ds3Client;
import com.spectralogic.ds3client.commands.GetObjectRequest;
import com.spectralogic.ds3client.networking.FailedRequestException;

import org.apache.commons.cli.MissingOptionException;

import java.nio.channels.FileChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.spectralogic.ds3client.commands.GetServiceResponse;
import com.spectralogic.ds3client.models.Bucket;
import com.spectralogic.ds3client.models.ListAllMyBucketsResult;
import com.spectralogic.ds3client.utils.SSLSetupException;

import java.io.IOException;
import java.security.SignatureException;
Expand All @@ -41,7 +42,7 @@ public CliCommand init(final Arguments args) throws Exception {
}

@Override
public String call() throws IOException, SignatureException {
public String call() throws IOException, SignatureException, SSLSetupException {
final GetServiceResponse response = getClient().getService(new GetServiceRequest());

final ListAllMyBucketsResult result = response.getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.spectralogic.ds3client.commands.PutBucketRequest;
import com.spectralogic.ds3client.models.bulk.Priority;
import com.spectralogic.ds3client.models.bulk.WriteOptimization;

import org.apache.commons.cli.MissingOptionException;

import java.io.IOException;
Expand Down
Loading