From bf330f63488fe77e25affee98f197e171f252719 Mon Sep 17 00:00:00 2001 From: andreisavu Date: Wed, 11 Jan 2012 23:02:36 +0200 Subject: [PATCH] Use listBucket to query StorageClass for a blob --- .../java/org/jclouds/s3/domain/ObjectMetadata.java | 10 +--------- .../java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java | 11 ++++++----- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java index b49cd16678..ecefdc0800 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java @@ -38,15 +38,7 @@ import org.jclouds.io.ContentMetadata; public interface ObjectMetadata extends Comparable { public enum StorageClass { - STANDARD, REDUCED_REDUNDANCY, UNKNOWN; - - public static StorageClass fromValue(String value) { - try { - return valueOf(value); - } catch(IllegalArgumentException e) { - return UNKNOWN; - } - } + STANDARD, REDUCED_REDUNDANCY } /** diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java index dd1769363c..8f6908eea4 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java @@ -25,6 +25,7 @@ import static org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions.Builder.stora import static org.jclouds.crypto.CryptoStreams.md5; import static org.jclouds.io.Payloads.newByteArrayPayload; import static org.jclouds.s3.domain.ObjectMetadata.StorageClass; +import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix; import static org.testng.Assert.assertEquals; import java.io.ByteArrayInputStream; @@ -45,9 +46,11 @@ import org.jclouds.http.apachehc.config.ApacheHCHttpCommandExecutorServiceModule import org.jclouds.io.Payload; import org.jclouds.s3.S3Client; import org.jclouds.s3.S3ClientLiveTest; +import org.jclouds.s3.domain.ListBucketResponse; import org.jclouds.s3.domain.ObjectMetadata; import org.jclouds.s3.domain.ObjectMetadataBuilder; import org.jclouds.s3.domain.S3Object; +import org.jclouds.s3.options.ListBucketOptions; import org.testng.ITestContext; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -178,12 +181,10 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { storageClass(StorageClass.REDUCED_REDUNDANCY)); S3Client s3Client = S3Client.class.cast(context.getProviderSpecificContext().getApi()); - S3Object s3Object = s3Client.getObject(containerName, blobName); + ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName)); - /** - * This fails because the storage class is not part of the server response - */ - assertEquals(s3Object.getMetadata().getStorageClass(), StorageClass.REDUCED_REDUNDANCY); + ObjectMetadata metadata = response.iterator().next(); + assertEquals(metadata.getStorageClass(), StorageClass.REDUCED_REDUNDANCY); } finally { returnContainer(containerName);