diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/DirectoryEntryListToResourceMetadataList.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/DirectoryEntryListToResourceMetadataList.java index bd45b23ecd..42f5571049 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/DirectoryEntryListToResourceMetadataList.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/DirectoryEntryListToResourceMetadataList.java @@ -60,10 +60,10 @@ public class DirectoryEntryListToResourceMetadataList implements StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation - .get(), null, null, null,ImmutableMap.of()); + .get(), null, null, null, null, ImmutableMap.of()); else return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), - null, null, null,ImmutableMap.of(), null, + null, null, null, null, ImmutableMap.of(), null, null, new BaseMutableContentMetadata()); } diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/functions/BucketToResourceMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/functions/BucketToResourceMetadata.java index 0ae946fb81..24b996c0dc 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/functions/BucketToResourceMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/functions/BucketToResourceMetadata.java @@ -48,6 +48,7 @@ public class BucketToResourceMetadata implements Function, Pa public StorageMetadata apply(BlobMetadata input) { if (input.getContentMetadata().getContentType().equals("application/directory")) { return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input - .getName(), input.getLocation(), input.getUri(), input.getETag(), input - .getLastModified(), input.getUserMetadata()); + .getName(), input.getLocation(), input.getUri(), input.getETag(), + input.getCreationDate(), input.getLastModified(), input.getUserMetadata()); } return input; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableStorageMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableStorageMetadata.java index 8224c165f0..c325486006 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableStorageMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableStorageMetadata.java @@ -22,6 +22,7 @@ import java.util.Date; import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl; import org.jclouds.domain.MutableResourceMetadata; +import org.jclouds.javax.annotation.Nullable; import com.google.inject.ImplementedBy; @@ -39,10 +40,14 @@ public interface MutableStorageMetadata extends MutableResourceMetadata { */ String getETag(); + /** + * Creation date of the resource, possibly null. + */ + Date getCreationDate(); + /** * Last modification time of the resource * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java index c370762660..5b59f24d65 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java @@ -42,9 +42,10 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements BlobMetadat private final ContentMetadata contentMetadata; public BlobMetadataImpl(String id, String name, @Nullable Location location, URI uri, String eTag, - Date lastModified, Map userMetadata, @Nullable URI publicUri, @Nullable String container, - ContentMetadata contentMetadata) { - super(StorageType.BLOB, id, name, location, uri, eTag, lastModified, userMetadata); + @Nullable Date creationDate, @Nullable Date lastModified, + Map userMetadata, @Nullable URI publicUri, + @Nullable String container, ContentMetadata contentMetadata) { + super(StorageType.BLOB, id, name, location, uri, eTag, creationDate, lastModified, userMetadata); this.publicUri = publicUri; this.container = container; this.contentMetadata = checkNotNull(contentMetadata, "contentMetadata"); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableStorageMetadataImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableStorageMetadataImpl.java index 2f62a2d406..f5631d4840 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableStorageMetadataImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableStorageMetadataImpl.java @@ -34,6 +34,7 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl imple @Nullable private final String eTag; @Nullable + private final Date creationDate; + @Nullable private final Date lastModified; private final StorageType type; public StorageMetadataImpl(StorageType type, @Nullable String id, @Nullable String name, - @Nullable Location location, @Nullable URI uri, @Nullable String eTag, @Nullable Date lastModified, + @Nullable Location location, @Nullable URI uri, @Nullable String eTag, + @Nullable Date creationDate, @Nullable Date lastModified, Map userMetadata) { super(id, name, location, uri, userMetadata); this.eTag = eTag; + this.creationDate = creationDate; this.lastModified = lastModified; this.type = checkNotNull(type, "type"); } @@ -62,12 +68,8 @@ public class StorageMetadataImpl extends ResourceMetadataImpl imple @Override public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((eTag == null) ? 0 : eTag.hashCode()); - result = prime * result + ((lastModified == null) ? 0 : lastModified.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; + return Objects.hashCode(super.hashCode(), eTag, creationDate, + lastModified, type); } @Override @@ -79,18 +81,10 @@ public class StorageMetadataImpl extends ResourceMetadataImpl imple if (getClass() != obj.getClass()) return false; StorageMetadataImpl other = (StorageMetadataImpl) obj; - if (eTag == null) { - if (other.eTag != null) - return false; - } else if (!eTag.equals(other.eTag)) - return false; - if (lastModified == null) { - if (other.lastModified != null) - return false; - } else if (!lastModified.equals(other.lastModified)) - return false; - if (type != other.type) - return false; + if (!Objects.equal(eTag, other.eTag)) { return false; } + if (!Objects.equal(creationDate, other.creationDate)) { return false; } + if (!Objects.equal(lastModified, other.lastModified)) { return false; } + if (!Objects.equal(type, other.type)) { return false; } return true; } @@ -102,6 +96,11 @@ public class StorageMetadataImpl extends ResourceMetadataImpl imple return eTag; } + @Override + public Date getCreationDate() { + return creationDate; + } + /** * {@inheritDoc} */ diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/ResourceMetadataToRelativePathResourceMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/ResourceMetadataToRelativePathResourceMetadata.java index af1a1f3796..988b1441ba 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/functions/ResourceMetadataToRelativePathResourceMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/functions/ResourceMetadataToRelativePathResourceMetadata.java @@ -43,7 +43,7 @@ public class ResourceMetadataToRelativePathResourceMetadata implements Function< name = name.substring(0, name.length() - suffix.length()); } return new StorageMetadataImpl(StorageType.RELATIVE_PATH, md.getProviderId(), name, md.getLocation(), - md.getUri(), md.getETag(), md.getLastModified(), md.getUserMetadata()); + md.getUri(), md.getETag(), md.getCreationDate(), md.getLastModified(), md.getUserMetadata()); } }