/** ETag == Content-MD5 */ @VisibleForTesting protected void addETagTo(HttpResponse from, MutableObjectMetadata metadata) { if (metadata.getETag() == null) { String eTagHeader = from.getFirstHeaderOrNull(S3Headers.AMZ_MD5); if (eTagHeader != null) { metadata.setETag(eTagHeader); } } }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((metadata == null) ? 0 : metadata.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; S3ObjectImpl other = (S3ObjectImpl) obj; if (metadata == null) { if (other.metadata != null) return false; } else if (!metadata.equals(other.metadata)) return false; return true; }
/** * parses the http response headers to create a new {@link * org.jclouds.aws.s3.domain.internal.MutableObjectMetadata} object. */ public MutableObjectMetadata apply(HttpResponse from) { BlobMetadata base = blobMetadataParser.apply(from); MutableObjectMetadata to = blobToObjectMetadata.apply(base); addETagTo(from, to); to.setContentMD5(HttpUtils.fromHexString(to.getETag().replaceAll("\"", ""))); to.setCacheControl(from.getFirstHeaderOrNull(HttpHeaders.CACHE_CONTROL)); to.setContentDisposition(from.getFirstHeaderOrNull("Content-Disposition")); to.setContentEncoding(from.getFirstHeaderOrNull(HttpHeaders.CONTENT_ENCODING)); return to; }
@Override public void setPayload(Payload data) { super.setPayload(data); metadata.setContentMetadata(data.getContentMetadata()); }