ifModifiedSince != null || ifUnmodifiedSince != null
|| ifMatchTags != null || ifNoneMatchTags != null
|| byteRangeStart != null || byteRangeEnd != null;
try {
AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
GetObjectResult result = null;
if (useExtendedGet) {
log.debug("Using Extended GET to apply constraints: "
+ "ifModifiedSince=" + (ifModifiedSince != null? ifModifiedSince.getTime().toString() : "null")
+ ", ifUnmodifiedSince=" + (ifUnmodifiedSince != null? ifUnmodifiedSince.getTime().toString() : "null")
+ ", ifMatchTags=" + (ifMatchTags != null? Arrays.asList(ifMatchTags).toString() : "null")
+ ", ifNoneMatchTags=" + (ifNoneMatchTags != null? Arrays.asList(ifNoneMatchTags).toString() : "null")
+ ", byteRangeStart=" + byteRangeStart + ", byteRangeEnd=" + byteRangeEnd);
String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
Constants.SOAP_SERVICE_NAME + "GetObjectExtended" + convertDateToString(timestamp));
result = s3SoapBinding.getObjectExtended(
bucketName, objectKey, true, withData, false, byteRangeStart, byteRangeEnd,
ifModifiedSince, ifUnmodifiedSince, ifMatchTags, ifNoneMatchTags,
Boolean.FALSE, getAWSAccessKey(), timestamp, signature, null);
// Throw an exception if the preconditions failed.
int expectedStatusCode = 200;
if (byteRangeStart != null || byteRangeEnd != null) {
// Partial data responses have a status code of 206.
expectedStatusCode = 206;
}
if (result.getStatus().getCode() != expectedStatusCode) {
throw new S3ServiceException("Precondition failed when getting object "
+ objectKey + ": " + result.getStatus().getDescription());
}
} else {
log.debug("Using standard GET (no constraints to apply)");
String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
Constants.SOAP_SERVICE_NAME + "GetObject" + convertDateToString(timestamp));
result = s3SoapBinding.getObject(
bucketName, objectKey, true, withData, false,
getAWSAccessKey(), timestamp, signature, null);
}
S3Object object = new S3Object(objectKey);
object.setETag(result.getETag());
object.setLastModifiedDate(result.getLastModified().getTime());
object.setBucketName(bucketName);
// Get data details from the SOAP attachment.
if (withData) {
Object[] attachments = s3SoapBinding.getAttachments();
log.debug("SOAP attachment count for " + object.getKey() + ": " + attachments.length);
for (int i = 0; i < attachments.length; i++) {
if (i > 0) {
throw new S3ServiceException(
"Received multiple SOAP attachment parts, this shouldn't happen");