mirror of https://github.com/apache/jclouds.git
JCLOUDS-1337: Include tier in object listing
This requires hoisting Tier from BlobMetadata to StorageMetadata.
This commit is contained in:
parent
c0a7938b69
commit
7fbef10d57
|
@ -45,6 +45,4 @@ public interface BlobMetadata extends StorageMetadata {
|
||||||
String getContainer();
|
String getContainer();
|
||||||
|
|
||||||
ContentMetadata getContentMetadata();
|
ContentMetadata getContentMetadata();
|
||||||
|
|
||||||
Tier getTier();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,4 +49,5 @@ public interface MutableStorageMetadata extends MutableResourceMetadata<StorageT
|
||||||
/** @see #getSize */
|
/** @see #getSize */
|
||||||
void setSize(@Nullable Long size);
|
void setSize(@Nullable Long size);
|
||||||
|
|
||||||
|
void setTier(Tier tier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,4 +94,6 @@ public interface StorageMetadata extends ResourceMetadata<StorageType> {
|
||||||
|
|
||||||
/** Size of the resource, possibly null. */
|
/** Size of the resource, possibly null. */
|
||||||
Long getSize();
|
Long getSize();
|
||||||
|
|
||||||
|
Tier getTier();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,18 +40,16 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements BlobMetadat
|
||||||
private final URI publicUri;
|
private final URI publicUri;
|
||||||
private final String container;
|
private final String container;
|
||||||
private final ContentMetadata contentMetadata;
|
private final ContentMetadata contentMetadata;
|
||||||
private final Tier tier;
|
|
||||||
|
|
||||||
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,
|
||||||
@Nullable Date creationDate, @Nullable Date lastModified,
|
@Nullable Date creationDate, @Nullable Date lastModified,
|
||||||
Map<String, String> userMetadata, @Nullable URI publicUri,
|
Map<String, String> userMetadata, @Nullable URI publicUri,
|
||||||
@Nullable String container, ContentMetadata contentMetadata, @Nullable Long size,
|
@Nullable String container, ContentMetadata contentMetadata, @Nullable Long size,
|
||||||
Tier tier) {
|
Tier tier) {
|
||||||
super(StorageType.BLOB, id, name, location, uri, eTag, creationDate, lastModified, userMetadata, size);
|
super(StorageType.BLOB, id, name, location, uri, eTag, creationDate, lastModified, userMetadata, size, tier);
|
||||||
this.publicUri = publicUri;
|
this.publicUri = publicUri;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.contentMetadata = checkNotNull(contentMetadata, "contentMetadata");
|
this.contentMetadata = checkNotNull(contentMetadata, "contentMetadata");
|
||||||
this.tier = checkNotNull(tier, "tier");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -94,11 +92,6 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements BlobMetadat
|
||||||
return contentMetadata;
|
return contentMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Tier getTier() {
|
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object == this) {
|
if (object == this) {
|
||||||
|
@ -111,13 +104,12 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements BlobMetadat
|
||||||
return super.equals(that) &&
|
return super.equals(that) &&
|
||||||
Objects.equal(publicUri, that.publicUri) &&
|
Objects.equal(publicUri, that.publicUri) &&
|
||||||
Objects.equal(container, that.container) &&
|
Objects.equal(container, that.container) &&
|
||||||
Objects.equal(contentMetadata, that.contentMetadata) &&
|
Objects.equal(contentMetadata, that.contentMetadata);
|
||||||
Objects.equal(tier, that.tier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), publicUri, container, contentMetadata, tier);
|
return Objects.hashCode(super.hashCode(), publicUri, container, contentMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,7 +117,6 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements BlobMetadat
|
||||||
return super.string()
|
return super.string()
|
||||||
.add("publicUri", publicUri)
|
.add("publicUri", publicUri)
|
||||||
.add("container", container)
|
.add("container", container)
|
||||||
.add("contentMetadata", contentMetadata)
|
.add("contentMetadata", contentMetadata);
|
||||||
.add("tier", tier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
import org.jclouds.blobstore.domain.MutableStorageMetadata;
|
import org.jclouds.blobstore.domain.MutableStorageMetadata;
|
||||||
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.blobstore.domain.Tier;
|
||||||
import org.jclouds.domain.internal.MutableResourceMetadataImpl;
|
import org.jclouds.domain.internal.MutableResourceMetadataImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +37,7 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
private Date creationDate;
|
private Date creationDate;
|
||||||
private Date lastModified;
|
private Date lastModified;
|
||||||
private Long size;
|
private Long size;
|
||||||
|
private Tier tier;
|
||||||
|
|
||||||
public MutableStorageMetadataImpl() {
|
public MutableStorageMetadataImpl() {
|
||||||
super();
|
super();
|
||||||
|
@ -46,6 +48,7 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
this.eTag = from.getETag();
|
this.eTag = from.getETag();
|
||||||
this.lastModified = from.getLastModified();
|
this.lastModified = from.getLastModified();
|
||||||
this.size = from.getSize();
|
this.size = from.getSize();
|
||||||
|
this.tier = from.getTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,6 +103,16 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tier getTier() {
|
||||||
|
return tier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTier(Tier tier) {
|
||||||
|
this.tier = tier;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object == this) {
|
if (object == this) {
|
||||||
|
@ -113,12 +126,13 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
Objects.equal(eTag, that.eTag) &&
|
Objects.equal(eTag, that.eTag) &&
|
||||||
Objects.equal(creationDate, that.creationDate) &&
|
Objects.equal(creationDate, that.creationDate) &&
|
||||||
Objects.equal(lastModified, that.lastModified) &&
|
Objects.equal(lastModified, that.lastModified) &&
|
||||||
Objects.equal(size, that.size);
|
Objects.equal(size, that.size) &&
|
||||||
|
Objects.equal(tier, that.tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), eTag, creationDate, lastModified, size);
|
return Objects.hashCode(super.hashCode(), eTag, creationDate, lastModified, size, tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,6 +141,7 @@ public class MutableStorageMetadataImpl extends MutableResourceMetadataImpl<Stor
|
||||||
.add("eTag", eTag)
|
.add("eTag", eTag)
|
||||||
.add("creationDate", creationDate)
|
.add("creationDate", creationDate)
|
||||||
.add("lastModified", lastModified)
|
.add("lastModified", lastModified)
|
||||||
.add("size", size);
|
.add("size", size)
|
||||||
|
.add("tier", tier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
|
|
||||||
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.blobstore.domain.Tier;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
@ -45,17 +46,29 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
private final StorageType type;
|
private final StorageType type;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Long size;
|
private final Long size;
|
||||||
|
@Nullable
|
||||||
|
private final Tier tier;
|
||||||
|
|
||||||
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 Location location, @Nullable URI uri, @Nullable String eTag,
|
||||||
@Nullable Date creationDate, @Nullable Date lastModified,
|
@Nullable Date creationDate, @Nullable Date lastModified,
|
||||||
Map<String, String> userMetadata, @Nullable Long size) {
|
Map<String, String> userMetadata, @Nullable Long size, Tier tier) {
|
||||||
super(id, name, location, uri, userMetadata);
|
super(id, name, location, uri, userMetadata);
|
||||||
this.eTag = eTag;
|
this.eTag = eTag;
|
||||||
this.creationDate = creationDate;
|
this.creationDate = creationDate;
|
||||||
this.lastModified = lastModified;
|
this.lastModified = lastModified;
|
||||||
this.type = checkNotNull(type, "type");
|
this.type = checkNotNull(type, "type");
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
this.tier = tier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated call StorageMetadataImpl(StorageType.class, String.class, String.class, Location.class, URI.class, String.class, Date.class, Date.class, Map.class, Long.class, Tier.class) */
|
||||||
|
@Deprecated
|
||||||
|
public StorageMetadataImpl(StorageType type, @Nullable String id, @Nullable String name,
|
||||||
|
@Nullable Location location, @Nullable URI uri, @Nullable String eTag,
|
||||||
|
@Nullable Date creationDate, @Nullable Date lastModified,
|
||||||
|
Map<String, String> userMetadata, @Nullable Long size) {
|
||||||
|
this(type, id, name, location, uri, eTag, creationDate, lastModified, userMetadata, size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated call StorageMetadataImpl(StorageType.class, String.class, String.class, Location.class, URI.class, String.class, Date.class, Date.class, Map.class, Long.class) */
|
/** @deprecated call StorageMetadataImpl(StorageType.class, String.class, String.class, Location.class, URI.class, String.class, Date.class, Date.class, Map.class, Long.class) */
|
||||||
|
@ -78,7 +91,7 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), eTag, creationDate,
|
return Objects.hashCode(super.hashCode(), eTag, creationDate,
|
||||||
lastModified, type, size);
|
lastModified, type, size, tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,6 +108,7 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
if (!Objects.equal(lastModified, other.lastModified)) { return false; }
|
if (!Objects.equal(lastModified, other.lastModified)) { return false; }
|
||||||
if (!Objects.equal(type, other.type)) { return false; }
|
if (!Objects.equal(type, other.type)) { return false; }
|
||||||
if (!Objects.equal(size, other.size)) { return false; }
|
if (!Objects.equal(size, other.size)) { return false; }
|
||||||
|
if (!Objects.equal(tier, other.tier)) { return false; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +119,8 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
.add("creationDate", creationDate)
|
.add("creationDate", creationDate)
|
||||||
.add("lastModified", lastModified)
|
.add("lastModified", lastModified)
|
||||||
.add("type", type)
|
.add("type", type)
|
||||||
.add("size", size);
|
.add("size", size)
|
||||||
|
.add("tier", tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,4 +149,8 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tier getTier() {
|
||||||
|
return tier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public final class B2BlobStore extends BaseBlobStore {
|
||||||
ImmutableList.Builder<StorageMetadata> builder = ImmutableList.builder();
|
ImmutableList.Builder<StorageMetadata> builder = ImmutableList.builder();
|
||||||
BucketList list = api.getBucketApi().listBuckets();
|
BucketList list = api.getBucketApi().listBuckets();
|
||||||
for (Bucket bucket : list.buckets()) {
|
for (Bucket bucket : list.buckets()) {
|
||||||
builder.add(new StorageMetadataImpl(StorageType.CONTAINER, null, bucket.bucketName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String, String>of(), null));
|
builder.add(new StorageMetadataImpl(StorageType.CONTAINER, null, bucket.bucketName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String, String>of(), null, Tier.STANDARD));
|
||||||
}
|
}
|
||||||
return new PageSetImpl<StorageMetadata>(builder.build(), null);
|
return new PageSetImpl<StorageMetadata>(builder.build(), null);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ public final class B2BlobStore extends BaseBlobStore {
|
||||||
B2ObjectList list = api.getObjectApi().listFileNames(bucket.bucketId(), options.getMarker(), options.getMaxResults(), options.getPrefix(), Strings.emptyToNull(delimiter));
|
B2ObjectList list = api.getObjectApi().listFileNames(bucket.bucketId(), options.getMarker(), options.getMaxResults(), options.getPrefix(), Strings.emptyToNull(delimiter));
|
||||||
for (B2ObjectList.Entry entry : list.files()) {
|
for (B2ObjectList.Entry entry : list.files()) {
|
||||||
if (entry.action() == Action.FOLDER) {
|
if (entry.action() == Action.FOLDER) {
|
||||||
builder.add(new StorageMetadataImpl(StorageType.RELATIVE_PATH, null, entry.fileName(), null, null, null, null, entry.uploadTimestamp(), ImmutableMap.<String, String>of(), null));
|
builder.add(new StorageMetadataImpl(StorageType.RELATIVE_PATH, null, entry.fileName(), null, null, null, null, entry.uploadTimestamp(), ImmutableMap.<String, String>of(), null, Tier.STANDARD));
|
||||||
} else if (options.isDetailed()) {
|
} else if (options.isDetailed()) {
|
||||||
BlobMetadata metadata = blobMetadata(container, entry.fileName());
|
BlobMetadata metadata = blobMetadata(container, entry.fileName());
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
|
|
Loading…
Reference in New Issue