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;
|
StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB;
|
||||||
if (type == StorageType.FOLDER)
|
if (type == StorageType.FOLDER)
|
||||||
return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation
|
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
|
else
|
||||||
return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(),
|
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());
|
null, new BaseMutableContentMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class BucketToResourceMetadata implements Function<BucketMetadata, Storag
|
||||||
to.setName(from.getName());
|
to.setName(from.getName());
|
||||||
to.setType(StorageType.CONTAINER);
|
to.setType(StorageType.CONTAINER);
|
||||||
to.setLocation(locationOfBucket.apply(from.getName()));
|
to.setLocation(locationOfBucket.apply(from.getName()));
|
||||||
|
to.setCreationDate(from.getCreationDate());
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class ContainerToResourceList implements Function<PageSet<ObjectInfo>, Pa
|
||||||
public StorageMetadata apply(BlobMetadata input) {
|
public StorageMetadata apply(BlobMetadata input) {
|
||||||
if (input.getContentMetadata().getContentType().equals("application/directory")) {
|
if (input.getContentMetadata().getContentType().equals("application/directory")) {
|
||||||
return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input
|
return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input
|
||||||
.getName(), input.getLocation(), input.getUri(), input.getETag(), input
|
.getName(), input.getLocation(), input.getUri(), input.getETag(),
|
||||||
.getLastModified(), input.getUserMetadata());
|
input.getCreationDate(), input.getLastModified(), input.getUserMetadata());
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
|
import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
|
||||||
import org.jclouds.domain.MutableResourceMetadata;
|
import org.jclouds.domain.MutableResourceMetadata;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
|
@ -39,10 +40,14 @@ public interface MutableStorageMetadata extends MutableResourceMetadata<StorageT
|
||||||
*/
|
*/
|
||||||
void setETag(String eTag);
|
void setETag(String eTag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #getCreationDate
|
||||||
|
*/
|
||||||
|
void setCreationDate(@Nullable Date creationDate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #getLastModified
|
* @see #getLastModified
|
||||||
*/
|
*/
|
||||||
void setLastModified(Date lastModified);
|
void setLastModified(@Nullable Date lastModified);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,11 @@ public interface StorageMetadata extends ResourceMetadata<StorageType> {
|
||||||
*/
|
*/
|
||||||
String getETag();
|
String getETag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creation date of the resource, possibly null.
|
||||||
|
*/
|
||||||
|
Date getCreationDate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last modification time of the resource
|
* Last modification time of the resource
|
||||||
*
|
*
|
||||||
|
|
|
@ -42,9 +42,10 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements BlobMetadat
|
||||||
private final ContentMetadata contentMetadata;
|
private final ContentMetadata contentMetadata;
|
||||||
|
|
||||||
public BlobMetadataImpl(String id, String name, @Nullable Location location, URI uri, String eTag,
|
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,
|
@Nullable Date creationDate, @Nullable Date lastModified,
|
||||||
ContentMetadata contentMetadata) {
|
Map<String, String> userMetadata, @Nullable URI publicUri,
|
||||||
super(StorageType.BLOB, id, name, location, uri, eTag, lastModified, userMetadata);
|
@Nullable String container, ContentMetadata contentMetadata) {
|
||||||
|
super(StorageType.BLOB, id, name, location, uri, eTag, creationDate, lastModified, userMetadata);
|
||||||
this.publicUri = publicUri;
|
this.publicUri = publicUri;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.contentMetadata = checkNotNull(contentMetadata, "contentMetadata");
|
this.contentMetadata = checkNotNull(contentMetadata, "contentMetadata");
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
MutableStorageMetadata {
|
MutableStorageMetadata {
|
||||||
|
|
||||||
private String eTag;
|
private String eTag;
|
||||||
|
private Date creationDate;
|
||||||
private Date lastModified;
|
private Date lastModified;
|
||||||
|
|
||||||
public MutableStorageMetadataImpl() {
|
public MutableStorageMetadataImpl() {
|
||||||
|
@ -54,6 +55,16 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
return eTag;
|
return eTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreationDate() {
|
||||||
|
return creationDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCreationDate(Date creationDate) {
|
||||||
|
this.creationDate = creationDate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.net.URI;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageType;
|
import org.jclouds.blobstore.domain.StorageType;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -40,14 +42,18 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String eTag;
|
private final String eTag;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
private final Date creationDate;
|
||||||
|
@Nullable
|
||||||
private final Date lastModified;
|
private final Date lastModified;
|
||||||
private final StorageType type;
|
private final StorageType type;
|
||||||
|
|
||||||
public StorageMetadataImpl(StorageType type, @Nullable String id, @Nullable String name,
|
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) {
|
Map<String, String> userMetadata) {
|
||||||
super(id, name, location, uri, userMetadata);
|
super(id, name, location, uri, userMetadata);
|
||||||
this.eTag = eTag;
|
this.eTag = eTag;
|
||||||
|
this.creationDate = creationDate;
|
||||||
this.lastModified = lastModified;
|
this.lastModified = lastModified;
|
||||||
this.type = checkNotNull(type, "type");
|
this.type = checkNotNull(type, "type");
|
||||||
}
|
}
|
||||||
|
@ -62,12 +68,8 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(super.hashCode(), eTag, creationDate,
|
||||||
int result = super.hashCode();
|
lastModified, type);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,18 +81,10 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
StorageMetadataImpl other = (StorageMetadataImpl) obj;
|
StorageMetadataImpl other = (StorageMetadataImpl) obj;
|
||||||
if (eTag == null) {
|
if (!Objects.equal(eTag, other.eTag)) { return false; }
|
||||||
if (other.eTag != null)
|
if (!Objects.equal(creationDate, other.creationDate)) { return false; }
|
||||||
return false;
|
if (!Objects.equal(lastModified, other.lastModified)) { return false; }
|
||||||
} else if (!eTag.equals(other.eTag))
|
if (!Objects.equal(type, other.type)) { return false; }
|
||||||
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;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +96,11 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
return eTag;
|
return eTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreationDate() {
|
||||||
|
return creationDate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ResourceMetadataToRelativePathResourceMetadata implements Function<
|
||||||
name = name.substring(0, name.length() - suffix.length());
|
name = name.substring(0, name.length() - suffix.length());
|
||||||
}
|
}
|
||||||
return new StorageMetadataImpl(StorageType.RELATIVE_PATH, md.getProviderId(), name, md.getLocation(),
|
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