mirror of https://github.com/apache/jclouds.git
Expose resource creation date
This commit is contained in:
parent
49990d97e4
commit
b51ce5994a
|
@ -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.<String,String>of());
|
||||
.get(), null, null, null, null, ImmutableMap.<String,String>of());
|
||||
else
|
||||
return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(),
|
||||
null, null, null,ImmutableMap.<String,String>of(), null,
|
||||
null, null, null, null, ImmutableMap.<String,String>of(), null,
|
||||
null, new BaseMutableContentMetadata());
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public class BucketToResourceMetadata implements Function<BucketMetadata, Storag
|
|||
to.setName(from.getName());
|
||||
to.setType(StorageType.CONTAINER);
|
||||
to.setLocation(locationOfBucket.apply(from.getName()));
|
||||
to.setCreationDate(from.getCreationDate());
|
||||
return to;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ public class ContainerToResourceList implements Function<PageSet<ObjectInfo>, 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;
|
||||
}
|
||||
|
|
|
@ -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<StorageT
|
|||
*/
|
||||
void setETag(String eTag);
|
||||
|
||||
/**
|
||||
* @see #getCreationDate
|
||||
*/
|
||||
void setCreationDate(@Nullable Date creationDate);
|
||||
|
||||
/**
|
||||
* @see #getLastModified
|
||||
*/
|
||||
void setLastModified(Date lastModified);
|
||||
void setLastModified(@Nullable Date lastModified);
|
||||
|
||||
}
|
||||
|
|
|
@ -82,6 +82,11 @@ public interface StorageMetadata extends ResourceMetadata<StorageType> {
|
|||
*/
|
||||
String getETag();
|
||||
|
||||
/**
|
||||
* Creation date of the resource, possibly null.
|
||||
*/
|
||||
Date getCreationDate();
|
||||
|
||||
/**
|
||||
* Last modification time of the resource
|
||||
*
|
||||
|
|
|
@ -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<String, String> 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<String, String> 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");
|
||||
|
|
|
@ -34,6 +34,7 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
|||
MutableStorageMetadata {
|
||||
|
||||
private String eTag;
|
||||
private Date creationDate;
|
||||
private Date lastModified;
|
||||
|
||||
public MutableStorageMetadataImpl() {
|
||||
|
@ -54,6 +55,16 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
|||
return eTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreationDate(Date creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.net.URI;
|
|||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||
import org.jclouds.blobstore.domain.StorageType;
|
||||
import org.jclouds.domain.Location;
|
||||
|
@ -40,14 +42,18 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> 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<String, String> 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<StorageType> 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<StorageType> 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<StorageType> imple
|
|||
return eTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue