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
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.SignatureException;
import java.util.UUID;

import com.spectralogic.ds3client.commands.*;
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
import com.spectralogic.ds3client.models.bulk.JobStatus;
import org.junit.BeforeClass;
import org.junit.Test;

import com.spectralogic.ds3client.Ds3Client;
import com.spectralogic.ds3client.commands.DeleteBucketRequest;
import com.spectralogic.ds3client.commands.GetBucketRequest;
import com.spectralogic.ds3client.commands.GetBucketResponse;
import com.spectralogic.ds3client.commands.HeadBucketRequest;
import com.spectralogic.ds3client.commands.HeadBucketResponse;
import com.spectralogic.ds3client.commands.PutBucketRequest;
import com.spectralogic.ds3client.models.ListBucketResult;
import com.spectralogic.ds3client.networking.FailedRequestException;
import com.spectralogic.ds3client.serializer.XmlProcessingException;
Expand Down Expand Up @@ -105,6 +107,38 @@ public void listContents() throws IOException, SignatureException,
}
}

@Test
public void getContents() throws IOException, SignatureException, URISyntaxException, XmlProcessingException {
final String bucketName = "test_get_contents";

try {
client.putBucket(new PutBucketRequest(bucketName));
Util.loadBookTestData(client, bucketName);

final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);

final Ds3ClientHelpers.Job job = helpers.startReadAllJob(bucketName);

final UUID jobId = job.getJobId();

job.transfer(new Ds3ClientHelpers.ObjectChannelBuilder() {
@Override
public SeekableByteChannel buildChannel(final String key) throws IOException {

final Path filePath = Files.createTempFile("ds3", key);

return Files.newByteChannel(filePath, StandardOpenOption.DELETE_ON_CLOSE, StandardOpenOption.WRITE);
}
});

final GetJobResponse jobResponse = client.getJob(new GetJobRequest(jobId));
assertThat(jobResponse.getMasterObjectList().getStatus(), is(JobStatus.COMPLETED));

} finally {
Util.deleteAllContents(client, bucketName);
}
}

@Test
public void negativeDeleteNonEmptyBucket() throws IOException,
SignatureException, XmlProcessingException, URISyntaxException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ public class JobInfo {
@JsonProperty("ChunkClientProcessingOrderGuarantee")
private ChunkClientProcessingOrderGuarantee chunkClientProcessingOrderGuarantee;

@JsonProperty("Status")
private JobStatus status;

public UUID getJobId() {
return this.jobId;
}

public void setJobId(final UUID jobId) {
this.jobId = jobId;
}
Expand Down Expand Up @@ -164,4 +168,12 @@ public UUID getUserId() {
public void setUserId(final UUID userId) {
this.userId = userId;
}

public JobStatus getStatus() {
return status;
}

public void setStatus(JobStatus status) {
this.status = status;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.spectralogic.ds3client.models.bulk;

public enum JobStatus {
IN_PROGRESS, COMPLETED, CANCELED
}