Skip to content

Commit 5b4904d

Browse files
committed
Fixing merge error.
2 parents 0679ce1 + 84a1d5f commit 5b4904d

30 files changed

+662
-69
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
allprojects {
1717
group = 'com.spectralogic.ds3'
18-
version = '1.1.0-SNAPSHOT'
18+
version = '1.0.1-SNAPSHOT'
1919
}
2020

2121
subprojects {

ds3-sdk-integration/src/main/java/com/spectralogic/ds3client/integration/Util.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.List;
3535

3636
public class Util {
37+
public static final String RESOURCE_BASE_NAME = "books/";
38+
3739
private Util() {}
3840

3941
public static Ds3Client fromEnv() {
@@ -75,7 +77,12 @@ private static Ds3ClientBuilder clientBuilder() {
7577

7678
private static final String[] BOOKS = {"beowulf.txt", "sherlock_holmes.txt", "tale_of_two_cities.txt", "ulysses.txt"};
7779
public static void loadBookTestData(final Ds3Client client, final String bucketName) throws IOException, SignatureException, XmlProcessingException, URISyntaxException {
78-
final String resourceBaseName = "books/";
80+
81+
getLoadJob(client, bucketName, RESOURCE_BASE_NAME)
82+
.transfer(new ResourceObjectPutter(RESOURCE_BASE_NAME));
83+
}
84+
85+
public static Ds3ClientHelpers.Job getLoadJob(final Ds3Client client, final String bucketName, final String resourceBaseName) throws IOException, SignatureException, XmlProcessingException, URISyntaxException {
7986
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
8087

8188
final List<Ds3Object> objects = new ArrayList<>();
@@ -87,9 +94,8 @@ public static void loadBookTestData(final Ds3Client client, final String bucketN
8794
objects.add(obj);
8895
}
8996

90-
helpers
91-
.startWriteJob(bucketName, objects)
92-
.transfer(new ResourceObjectPutter(resourceBaseName));
97+
return helpers
98+
.startWriteJob(bucketName, objects);
9399
}
94100

95101
public static void deleteAllContents(final Ds3Client client, final String bucketName) throws IOException, SignatureException {
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package com.spectralogic.ds3client.integration;
2+
3+
import com.spectralogic.ds3client.Ds3Client;
4+
import com.spectralogic.ds3client.commands.PutBucketRequest;
5+
import com.spectralogic.ds3client.commands.notifications.*;
6+
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
7+
import com.spectralogic.ds3client.serializer.XmlProcessingException;
8+
import org.junit.BeforeClass;
9+
import org.junit.Test;
10+
11+
import java.io.IOException;
12+
import java.net.URISyntaxException;
13+
import java.security.SignatureException;
14+
import java.util.UUID;
15+
16+
import static org.hamcrest.CoreMatchers.is;
17+
import static org.hamcrest.CoreMatchers.not;
18+
import static org.hamcrest.CoreMatchers.notNullValue;
19+
import static org.junit.Assert.assertThat;
20+
21+
public class NotificationsIntegration_test {
22+
23+
private static Ds3Client client;
24+
25+
@BeforeClass
26+
public static void startup() {
27+
client = Util.fromEnv();
28+
}
29+
30+
@Test
31+
public void objectCompletionRegistration() throws IOException, SignatureException {
32+
final CreateNotificationResponse response = client.createObjectCachedNotification(new CreateObjectCachedNotificationRequest("192.168.56.101"));
33+
assertThat(response, is(notNullValue()));
34+
assertThat(response.getRegistration(), is(notNullValue()));
35+
36+
final UUID registrationId = response.getRegistration().getId();
37+
38+
assertThat(client.deleteObjectCachedNotification(new DeleteObjectCachedNotificationRequest(registrationId)), is(notNullValue()));
39+
40+
}
41+
42+
@Test
43+
public void jobCompletionRegistration() throws IOException, SignatureException {
44+
final CreateNotificationResponse response = client.createJobCompletedNotification(new CreateJobCompletedNotificationRequest("192.168.56.101/other"));
45+
assertThat(response, is(notNullValue()));
46+
assertThat(response.getRegistration(), is(notNullValue()));
47+
48+
final UUID registrationId = response.getRegistration().getId();
49+
50+
assertThat(client.deleteJobCompleteNotification(new DeleteJobCompletedNotificationRequest(registrationId)), is(notNullValue()));
51+
}
52+
53+
@Test
54+
public void jobCreateRegistration() throws IOException, SignatureException {
55+
final CreateNotificationResponse response = client.createJobCreatedNotification(new CreateJobCreatedNotificationRequest("192.168.56.101/other"));
56+
assertThat(response, is(notNullValue()));
57+
assertThat(response.getRegistration(), is(notNullValue()));
58+
59+
final UUID registrationId = response.getRegistration().getId();
60+
61+
assertThat(client.deleteJobCreatedNotification(new DeleteJobCreatedNotificationRequest(registrationId)), is(notNullValue()));
62+
}
63+
64+
@Test
65+
public void objectLostRegistration() throws IOException, SignatureException {
66+
final CreateNotificationResponse response = client.createObjectLostNotification(new CreateObjectLostNotificationRequest("192.168.56.101/other"));
67+
assertThat(response, is(notNullValue()));
68+
assertThat(response.getRegistration(), is(notNullValue()));
69+
70+
final UUID registrationId = response.getRegistration().getId();
71+
72+
assertThat(client.deleteObjectLostNotification(new DeleteObjectLostNotificationRequest(registrationId)), is(notNullValue()));
73+
}
74+
75+
@Test
76+
public void objectPersistedRegistration() throws IOException, SignatureException, URISyntaxException, XmlProcessingException {
77+
final String bucketName = "test_bucket";
78+
79+
try {
80+
client.putBucket(new PutBucketRequest(bucketName));
81+
final Ds3ClientHelpers.Job job = Util.getLoadJob(client, bucketName, Util.RESOURCE_BASE_NAME);
82+
83+
final CreateNotificationResponse response = client.createObjectPersistedNotification(new CreateObjectPersistedNotificationRequest("192.168.56.101/other", job.getJobId()));
84+
assertThat(response, is(notNullValue()));
85+
assertThat(response.getRegistration(), is(notNullValue()));
86+
87+
job.transfer(new ResourceObjectPutter(Util.RESOURCE_BASE_NAME));
88+
89+
final UUID registrationId = response.getRegistration().getId();
90+
91+
assertThat(client.deleteObjectPersistedNotification(new DeleteObjectPersistedNotificationRequest(registrationId)), is(notNullValue()));
92+
}
93+
finally {
94+
Util.deleteAllContents(client, bucketName);
95+
}
96+
}
97+
}

ds3-sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies {
4343
compile 'commons-codec:commons-codec:1.8'
4444
compile 'commons-io:commons-io:2.1'
4545
compile 'org.codehaus.woodstox:woodstox-core-asl:4.2.0'
46-
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.2.3'
46+
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.0'
4747
compile 'com.google.guava:guava:18.0'
4848
testCompile 'org.hamcrest:hamcrest-library:1.3'
4949
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.spectralogic.ds3client;
1717

1818
import com.spectralogic.ds3client.commands.*;
19+
import com.spectralogic.ds3client.commands.notifications.*;
1920
import com.spectralogic.ds3client.models.bulk.Node;
2021
import com.spectralogic.ds3client.networking.ConnectionDetails;
2122

@@ -223,6 +224,47 @@ public abstract CancelJobResponse cancelJob(CancelJobRequest request)
223224
public abstract ModifyJobResponse modifyJob(ModifyJobRequest request)
224225
throws IOException, SignatureException;
225226

227+
public abstract CreateNotificationResponse createObjectCachedNotification(CreateObjectCachedNotificationRequest request)
228+
throws IOException, SignatureException;
229+
230+
public abstract DeleteNotificationResponse deleteObjectCachedNotification(DeleteObjectCachedNotificationRequest request)
231+
throws IOException, SignatureException;
232+
233+
public abstract CreateNotificationResponse createJobCompletedNotification(CreateJobCompletedNotificationRequest request)
234+
throws IOException, SignatureException;
235+
236+
public abstract DeleteNotificationResponse deleteJobCompleteNotification(DeleteJobCompletedNotificationRequest request)
237+
throws IOException, SignatureException;
238+
239+
public abstract CreateNotificationResponse createJobCreatedNotification(CreateJobCreatedNotificationRequest request)
240+
throws IOException, SignatureException;
241+
242+
public abstract DeleteNotificationResponse deleteJobCreatedNotification(DeleteJobCreatedNotificationRequest request)
243+
throws IOException, SignatureException;
244+
245+
public abstract CreateNotificationResponse createObjectLostNotification(CreateObjectLostNotificationRequest request)
246+
throws IOException, SignatureException;
247+
248+
public abstract DeleteNotificationResponse deleteObjectLostNotification(DeleteObjectLostNotificationRequest request)
249+
throws IOException, SignatureException;
250+
251+
public abstract CreateNotificationResponse createObjectPersistedNotification(CreateObjectPersistedNotificationRequest request)
252+
throws IOException, SignatureException;
253+
254+
public abstract DeleteNotificationResponse deleteObjectPersistedNotification(DeleteObjectPersistedNotificationRequest request)
255+
throws IOException, SignatureException;
256+
257+
public abstract CreateNotificationResponse createPartitionFailureNotification(CreatePartitionFailureNotificationRequest request)
258+
throws IOException, SignatureException;
259+
260+
public abstract DeleteNotificationResponse deletePartitionFailureNotification(DeletePartitionFailureNotificationRequest request)
261+
throws IOException, SignatureException;
262+
263+
public abstract CreateNotificationResponse createTapeFailureNotification(CreateTapeFailureNotificationRequest request)
264+
throws IOException, SignatureException;
265+
266+
public abstract DeleteNotificationResponse deleteTapeFailureNotification(DeleteTapeFailureNotificationRequest request)
267+
throws IOException, SignatureException;
226268
/**
227269
* Creates a new Ds3Client instance for the system pointed to by Node.
228270
*/

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
import com.spectralogic.ds3client.commands.*;
23+
import com.spectralogic.ds3client.commands.notifications.*;
2324
import com.spectralogic.ds3client.models.bulk.Node;
2425
import com.spectralogic.ds3client.networking.ConnectionDetails;
2526
import com.spectralogic.ds3client.networking.NetworkClient;
@@ -124,6 +125,76 @@ public ModifyJobResponse modifyJob(final ModifyJobRequest request) throws IOExce
124125
return new ModifyJobResponse(this.netClient.getResponse(request));
125126
}
126127

128+
@Override
129+
public CreateNotificationResponse createObjectCachedNotification(final CreateObjectCachedNotificationRequest request) throws IOException, SignatureException {
130+
return new CreateNotificationResponse(this.netClient.getResponse(request));
131+
}
132+
133+
@Override
134+
public DeleteNotificationResponse deleteObjectCachedNotification(final DeleteObjectCachedNotificationRequest request) throws IOException, SignatureException {
135+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
136+
}
137+
138+
@Override
139+
public CreateNotificationResponse createJobCompletedNotification(final CreateJobCompletedNotificationRequest request) throws IOException, SignatureException {
140+
return new CreateNotificationResponse(this.netClient.getResponse(request));
141+
}
142+
143+
@Override
144+
public DeleteNotificationResponse deleteJobCompleteNotification(final DeleteJobCompletedNotificationRequest request) throws IOException, SignatureException {
145+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
146+
}
147+
148+
@Override
149+
public CreateNotificationResponse createJobCreatedNotification(CreateJobCreatedNotificationRequest request) throws IOException, SignatureException {
150+
return new CreateNotificationResponse(this.netClient.getResponse(request));
151+
}
152+
153+
@Override
154+
public DeleteNotificationResponse deleteJobCreatedNotification(DeleteJobCreatedNotificationRequest request) throws IOException, SignatureException {
155+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
156+
}
157+
158+
@Override
159+
public CreateNotificationResponse createObjectLostNotification(CreateObjectLostNotificationRequest request) throws IOException, SignatureException {
160+
return new CreateNotificationResponse(this.netClient.getResponse(request));
161+
}
162+
163+
@Override
164+
public DeleteNotificationResponse deleteObjectLostNotification(DeleteObjectLostNotificationRequest request) throws IOException, SignatureException {
165+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
166+
}
167+
168+
@Override
169+
public CreateNotificationResponse createObjectPersistedNotification(CreateObjectPersistedNotificationRequest request) throws IOException, SignatureException {
170+
return new CreateNotificationResponse(this.netClient.getResponse(request));
171+
}
172+
173+
@Override
174+
public DeleteNotificationResponse deleteObjectPersistedNotification(DeleteObjectPersistedNotificationRequest request) throws IOException, SignatureException {
175+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
176+
}
177+
178+
@Override
179+
public CreateNotificationResponse createPartitionFailureNotification(CreatePartitionFailureNotificationRequest request) throws IOException, SignatureException {
180+
return new CreateNotificationResponse(this.netClient.getResponse(request));
181+
}
182+
183+
@Override
184+
public DeleteNotificationResponse deletePartitionFailureNotification(DeletePartitionFailureNotificationRequest request) throws IOException, SignatureException {
185+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
186+
}
187+
188+
@Override
189+
public CreateNotificationResponse createTapeFailureNotification(CreateTapeFailureNotificationRequest request) throws IOException, SignatureException {
190+
return new CreateNotificationResponse(this.netClient.getResponse(request));
191+
}
192+
193+
@Override
194+
public DeleteNotificationResponse deleteTapeFailureNotification(DeleteTapeFailureNotificationRequest request) throws IOException, SignatureException {
195+
return new DeleteNotificationResponse(this.netClient.getResponse(request));
196+
}
197+
127198
@Override
128199
public Ds3Client newForNode(final Node node) {
129200
final ConnectionDetails newConnectionDetails = ConnectionDetailsImpl.newForNode(node, this.getConnectionDetails());

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/AbstractRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.HashMap;
2525
import java.util.Map;
2626

27-
abstract class AbstractRequest implements Ds3Request {
27+
public abstract class AbstractRequest implements Ds3Request {
2828

2929
private final Multimap<String, String> headers = buildDefaultHeaders();
3030
private final Map<String, String> queryParams = new HashMap<>();

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/AbstractResponse.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import java.io.InputStream;
2828
import java.io.StringWriter;
2929

30-
abstract class AbstractResponse implements Ds3Response{
31-
final static String UTF8 = "UTF-8";
30+
public abstract class AbstractResponse implements Ds3Response{
31+
final public static String UTF8 = "UTF-8";
3232

3333
final private WebResponse response;
3434
final private String md5;
3535

36-
AbstractResponse(final WebResponse response) throws IOException {
36+
public AbstractResponse(final WebResponse response) throws IOException {
3737
this.response = response;
3838
if (response != null) {
3939
this.md5 = this.response.getHeaders().get("Content-MD5");
@@ -46,11 +46,11 @@ abstract class AbstractResponse implements Ds3Response{
4646

4747
protected abstract void processResponse() throws IOException;
4848

49-
WebResponse getResponse() {
49+
public WebResponse getResponse() {
5050
return this.response;
5151
}
5252

53-
void checkStatusCode(final int ... expectedStatuses) throws IOException {
53+
public void checkStatusCode(final int ... expectedStatuses) throws IOException {
5454
final ImmutableSet<Integer> expectedSet = this.createExpectedSet(expectedStatuses);
5555
final int statusCode = this.getStatusCode();
5656
if (!expectedSet.contains(statusCode)) {

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/GetObjectRequest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,6 @@ public long getEnd() {
5656
private final WritableByteChannel channel;
5757
private Range byteRange = null;
5858

59-
@Deprecated
60-
/**
61-
* Creates a request for use when getting a single object. This requet should generally not be used, since for each request
62-
* made with this constructor will create a naked bulk get implicitly, which if called over and over, will cause performance
63-
* issues.
64-
*/
65-
public GetObjectRequest(final String bucketName, final String objectName, final WritableByteChannel channel) {
66-
this.bucketName = bucketName;
67-
this.objectName = objectName;
68-
this.jobId = null;
69-
this.offset = 0;
70-
this.channel = channel;
71-
}
72-
7359
/**
7460
* Creates a request to get an object within the context of a bulk job. This is the preferred method of creating a get object request.
7561
* See {@link BulkGetRequest} for more information on creating a bulk get request.

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/PutObjectRequest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@ public class PutObjectRequest extends AbstractRequest {
3737
private Checksum checksum = Checksum.none();
3838
public final static String AMZ_META_HEADER = "x-amz-meta-";
3939

40-
@Deprecated
41-
/**
42-
* Creates a request for use when putting a single object. This request should generally not be used, since for each request
43-
* made with this constructor will create a naked bulk put implicitly, which if called over and over, will cause performance
44-
* issues.
45-
*/
46-
public PutObjectRequest(final String bucketName, final String objectName, final long size, final SeekableByteChannel channel) {
47-
this.bucketName = bucketName;
48-
this.objectName = objectName;
49-
this.channel = channel;
50-
this.stream = new SeekableByteChannelInputStream(channel);
51-
this.size = size;
52-
this.jobId = null;
53-
this.offset = 0;
54-
}
55-
5640
/**
5741
* Creates a request to put a request within the context of a bulk job. This is the preferred method of creating a put object request.
5842
* See {@link BulkPutRequest} for more information on creating a bulk put request.

0 commit comments

Comments
 (0)