Skip to content

Commit 9bf6ec9

Browse files
committed
Adding the files that I forgot to with the last commit
1 parent 0342fc2 commit 9bf6ec9

26 files changed

+537
-108
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 = '0.7.7-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: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,97 @@
11
package com.spectralogic.ds3client.integration;
22

3-
/**
4-
* Created by ryanmo on 1/22/15.
5-
*/
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+
621
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+
}
797
}

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/notifications/AbstractDeleteNotificationRequest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
import com.spectralogic.ds3client.HttpVerb;
44
import com.spectralogic.ds3client.commands.AbstractRequest;
55

6+
import java.util.UUID;
7+
68
public abstract class AbstractDeleteNotificationRequest extends AbstractRequest {
9+
10+
private final UUID notificationId;
11+
12+
public AbstractDeleteNotificationRequest(final UUID notificationId) {
13+
super();
14+
this.notificationId = notificationId;
15+
}
16+
17+
public UUID getNotificationId() {
18+
return this.notificationId;
19+
}
20+
721
@Override
822
public HttpVerb getVerb() {
923
return HttpVerb.DELETE;
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
package com.spectralogic.ds3client.commands.notifications;
22

3-
/**
4-
* Created by ryanmo on 1/22/15.
5-
*/
6-
public class CreateJobCompletedNotificationRequest {
3+
import java.util.UUID;
4+
5+
public class CreateJobCompletedNotificationRequest extends AbstractCreateNotificationRequest {
6+
public CreateJobCompletedNotificationRequest(final String endpoint) {
7+
super(endpoint);
8+
}
9+
10+
public CreateJobCompletedNotificationRequest(final String endpoint, final UUID jobId) {
11+
super(endpoint);
12+
this.getQueryParams().put("job_id", jobId.toString());
13+
}
14+
15+
@Override
16+
public String getPath() {
17+
return "/_rest_/job_completed_notification_registration";
18+
}
719
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.spectralogic.ds3client.commands.notifications;
22

3-
/**
4-
* Created by ryanmo on 1/22/15.
5-
*/
6-
public class CreateJobCreatedNotificationRequest {
3+
public class CreateJobCreatedNotificationRequest extends AbstractCreateNotificationRequest {
4+
public CreateJobCreatedNotificationRequest(final String endpoint) {
5+
super(endpoint);
6+
}
7+
8+
@Override
9+
public String getPath() {
10+
return "/_rest_/job_created_notification_registration";
11+
}
712
}

0 commit comments

Comments
 (0)