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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import com.spectralogic.ds3client.Ds3ClientBuilder;
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
import com.spectralogic.ds3client.helpers.FileObjectPutter;
import com.spectralogic.ds3client.models.Credentials;
import com.spectralogic.ds3client.models.Ds3Object;
import com.spectralogic.ds3client.models.bulk.Ds3Object;
import com.spectralogic.ds3client.serializer.XmlProcessingException;

import java.io.IOException;
Expand Down Expand Up @@ -107,8 +107,8 @@ import com.spectralogic.ds3client.Ds3ClientBuilder;
import com.spectralogic.ds3client.commands.*;
import com.spectralogic.ds3client.models.Contents;
import com.spectralogic.ds3client.models.Credentials;
import com.spectralogic.ds3client.models.Ds3Object;
import com.spectralogic.ds3client.models.Objects;
import com.spectralogic.ds3client.models.bulk.Ds3Object;
import com.spectralogic.ds3client.models.bulk.Objects;
import com.spectralogic.ds3client.serializer.XmlProcessingException;

import org.apache.commons.io.IOUtils;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_7

jar.archiveName = 'ds3_java_sdk'
version = '0.3.0-SNAPSHOT'
version = '0.4.0-SNAPSHOT'
group = 'com.spectralogic'

install.dependsOn test //make sure that the tests get ran before attempting to install
Expand Down
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 16:16:39 MDT 2014
#Tue Jul 29 14:10:20 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-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-all.zip
21 changes: 2 additions & 19 deletions src/main/java/com/spectralogic/ds3client/Ds3Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

package com.spectralogic.ds3client;

import com.spectralogic.ds3client.commands.*;

import java.io.IOException;
import java.security.SignatureException;

import com.spectralogic.ds3client.commands.*;

/**
* The main interface for communicating with a DS3 appliance. All communication with a DS3 appliance should start with
* this class.
Expand Down Expand Up @@ -180,21 +180,4 @@ public abstract BulkGetResponse bulkGet(BulkGetRequest request)
*/
public abstract BulkPutResponse bulkPut(BulkPutRequest request)
throws IOException, SignatureException;

/**
* Queries the list of active jobs on the server.
* @throws IOException
* @throws SignatureException
*/
public abstract GetJobListResponse getJobList(GetJobListRequest request)
throws IOException, SignatureException;

/**
* Queries the job details for a given job id. Includes the objects that are in cache or haven't been transferred.
* @throws IOException
* @throws SignatureException
*/
public abstract GetJobResponse getJob(GetJobRequest request)
throws IOException, SignatureException;

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.spectralogic.ds3client;

import java.net.URI;
import java.net.URISyntaxException;

import com.spectralogic.ds3client.models.Credentials;
import com.spectralogic.ds3client.networking.NetworkClient;

import java.net.URI;
import java.net.URISyntaxException;

/**
* A Builder class used to create a Ds3Client instance. This allows you to customize the behavior of a {@link com.spectralogic.ds3client.Ds3Client}.
* For instance, the number of times that the Ds3Client instance will perform a 307 redirect before throwing an error
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

package com.spectralogic.ds3client;

import java.io.IOException;
import java.security.SignatureException;

import com.spectralogic.ds3client.commands.*;
import com.spectralogic.ds3client.networking.NetworkClient;

import java.io.IOException;
import java.security.SignatureException;

class Ds3ClientImpl implements Ds3Client {
private final NetworkClient netClient;

Expand Down Expand Up @@ -82,14 +82,5 @@ public BulkPutResponse bulkPut(final BulkPutRequest request) throws IOException,
return new BulkPutResponse(this.netClient.getResponse(request));
}

@Override
public GetJobListResponse getJobList(final GetJobListRequest request) throws IOException, SignatureException {
return new GetJobListResponse(this.netClient.getResponse(request));
}

@Override
public GetJobResponse getJob(final GetJobRequest request) throws IOException, SignatureException {
return new GetJobResponse(this.netClient.getResponse(request));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@

package com.spectralogic.ds3client;

import com.spectralogic.ds3client.models.Checksum;
import org.apache.commons.codec.binary.Base64;

import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.commons.codec.binary.Base64;

import com.spectralogic.ds3client.models.Checksum;

class HashGeneratingMatchHandler implements Checksum.MatchHandler<String, IOException> {
private static final int READ_BUFFER_SIZE = 1024;

Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/spectralogic/ds3client/HeadersImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.spectralogic.ds3client;

import com.spectralogic.ds3client.networking.Headers;
import org.apache.http.Header;

public class HeadersImpl implements Headers {

private final Header[] headers;

HeadersImpl(final Header[] allHeaders){
this.headers = allHeaders;
}

@Override
public String get(final String key) {
return findHeader(key);
}

private String findHeader(final String key) {

for (final Header header : headers) {
if (header.getName().equalsIgnoreCase(key)) {
return header.getValue();
}
}
return null;
}
}
27 changes: 13 additions & 14 deletions src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@

package com.spectralogic.ds3client;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.security.SignatureException;
import java.util.Map;

import com.spectralogic.ds3client.commands.Ds3Request;
import com.spectralogic.ds3client.models.SignatureDetails;
import com.spectralogic.ds3client.networking.*;
import com.spectralogic.ds3client.utils.DateFormatter;
import com.spectralogic.ds3client.utils.Signature;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpStatus;
Expand All @@ -35,11 +31,14 @@
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.apache.http.message.BasicHttpRequest;

import com.spectralogic.ds3client.commands.Ds3Request;
import com.spectralogic.ds3client.models.SignatureDetails;
import com.spectralogic.ds3client.networking.*;
import com.spectralogic.ds3client.utils.DateFormatter;
import com.spectralogic.ds3client.utils.Signature;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.security.SignatureException;
import java.util.Map;

class NetworkClientImpl implements NetworkClient {
final static private String HOST = "HOST";
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/spectralogic/ds3client/WebResponseImpl.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package com.spectralogic.ds3client;

import java.io.IOException;
import java.io.InputStream;

import com.spectralogic.ds3client.networking.Headers;
import com.spectralogic.ds3client.networking.WebResponse;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse;

import com.spectralogic.ds3client.networking.WebResponse;
import java.io.IOException;
import java.io.InputStream;

class WebResponseImpl implements WebResponse {
private final CloseableHttpResponse response;
private final Headers headers;

public WebResponseImpl(final CloseableHttpResponse response) {
this.response = response;
this.headers = new HeadersImpl(this.response.getAllHeaders());
}

@Override
public InputStream getResponseStream() throws IOException {
return this.response.getEntity().getContent();
Expand All @@ -24,6 +27,11 @@ public int getStatusCode() {
return this.response.getStatusLine().getStatusCode();
}

@Override
public Headers getHeaders() {
return this.headers;
}

@Override
public void close() throws IOException {
this.response.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@

package com.spectralogic.ds3client.commands;

import com.spectralogic.ds3client.models.Checksum;
import org.apache.http.entity.ContentType;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.entity.ContentType;

import com.spectralogic.ds3client.models.Checksum;

abstract class AbstractRequest implements Ds3Request {

private final Map<String, String> headers = buildDefaultHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,31 @@

package com.spectralogic.ds3client.commands;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

import org.apache.commons.io.IOUtils;

import com.google.common.collect.ImmutableSet;
import com.spectralogic.ds3client.models.Error;
import com.spectralogic.ds3client.networking.FailedRequestException;
import com.spectralogic.ds3client.networking.WebResponse;
import com.spectralogic.ds3client.serializer.XmlOutput;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

abstract class AbstractResponse implements Ds3Response{
final static String UTF8 = "UTF-8";

final private WebResponse response;
final private String md5;

AbstractResponse(final WebResponse response) throws IOException {
this.response = response;
if (response != null) {
this.md5 = this.response.getHeaders().get("Content-MD5");
}
else {
this.md5 = null;
}
this.processResponse();
}

Expand Down Expand Up @@ -90,4 +96,8 @@ private String readResponseString() throws IOException {
public void close() throws IOException {
this.response.close();
}

public String getMd5() {
return md5;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.spectralogic.ds3client.commands;

import com.spectralogic.ds3client.BulkCommand;
import com.spectralogic.ds3client.models.Ds3Object;
import com.spectralogic.ds3client.models.bulk.Ds3Object;
import com.spectralogic.ds3client.serializer.XmlProcessingException;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package com.spectralogic.ds3client.commands;


import java.io.IOException;

import com.spectralogic.ds3client.networking.WebResponse;

import java.io.IOException;

public class BulkGetResponse extends BulkResponse {
public BulkGetResponse(final WebResponse response) throws IOException {
super(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.spectralogic.ds3client.commands;

import com.spectralogic.ds3client.BulkCommand;
import com.spectralogic.ds3client.models.Ds3Object;
import com.spectralogic.ds3client.models.bulk.Ds3Object;
import com.spectralogic.ds3client.serializer.XmlProcessingException;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

package com.spectralogic.ds3client.commands;

import java.io.IOException;

import com.spectralogic.ds3client.networking.WebResponse;

import java.io.IOException;

public class BulkPutResponse extends BulkResponse {
public BulkPutResponse(final WebResponse response) throws IOException {
super(response);
Expand Down
Loading