diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index bb06e5f132..35635f4890 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -82,7 +82,7 @@ See http://code.google.com/p/jclouds for details." ;; hence separating it from the above (extend-protocol PayloadSource (class (make-array Byte/TYPE 0)) - (payload [ba] (Payloads/newPayload ba))) + (payload [ba] (Payloads/newByteArrayPayload ba))) (defn blobstore "Create a logged in context. diff --git a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java index 369aa4e6df..d3e56a0768 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java @@ -16,6 +16,8 @@ */ package org.jclouds.blobstore.strategy.internal; +import static org.jclouds.io.Payloads.newByteArrayPayload; + import javax.inject.Named; import javax.inject.Singleton; @@ -24,7 +26,6 @@ import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.blobstore.strategy.MkdirStrategy; -import com.google.common.io.ByteSource; import com.google.inject.Inject; /** @@ -49,8 +50,6 @@ public class MarkerFileMkdirStrategy implements MkdirStrategy { blobStore.putBlob( containerName, blobStore.blobBuilder(directory + directorySuffix).type(StorageType.RELATIVE_PATH) - .payload(ByteSource.empty()) - .contentLength(0L) - .contentType("application/directory").build()); + .payload(newByteArrayPayload(new byte[] {})).contentType("application/directory").build()); } } diff --git a/core/src/main/java/org/jclouds/http/HttpMessage.java b/core/src/main/java/org/jclouds/http/HttpMessage.java index 08b45ce940..a4669d55e4 100644 --- a/core/src/main/java/org/jclouds/http/HttpMessage.java +++ b/core/src/main/java/org/jclouds/http/HttpMessage.java @@ -68,7 +68,7 @@ public class HttpMessage extends PayloadEnclosingImpl { */ @Deprecated public T payload(byte [] payload) { - this.payload = Payloads.newPayload(checkNotNull(payload, "payload")); + this.payload = Payloads.newByteArrayPayload(checkNotNull(payload, "payload")); return self(); } diff --git a/core/src/main/java/org/jclouds/io/Payloads.java b/core/src/main/java/org/jclouds/io/Payloads.java index 106c037c3f..1b4bb7a194 100644 --- a/core/src/main/java/org/jclouds/io/Payloads.java +++ b/core/src/main/java/org/jclouds/io/Payloads.java @@ -45,10 +45,7 @@ public class Payloads { } else if (data instanceof InputStream) { return newInputStreamPayload((InputStream) data); } else if (data instanceof byte[]) { - byte[] array = (byte[]) data; - Payload payload = newByteSourcePayload(ByteSource.wrap(array)); - payload.getContentMetadata().setContentLength((long) array.length); - return payload; + return newByteArrayPayload((byte[]) data); } else if (data instanceof ByteSource) { return newByteSourcePayload((ByteSource) data); } else if (data instanceof String) { diff --git a/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java b/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java index b9fa973813..d3a41f3c05 100644 --- a/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java +++ b/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java @@ -33,9 +33,9 @@ import javax.inject.Singleton; import org.jclouds.io.ContentMetadata; import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; import org.jclouds.io.PayloadSlicer; import org.jclouds.io.payloads.BaseMutableContentMetadata; +import org.jclouds.io.payloads.ByteArrayPayload; import org.jclouds.io.payloads.ByteSourcePayload; import org.jclouds.io.payloads.InputStreamPayload; @@ -119,7 +119,7 @@ public class BasePayloadSlicer implements PayloadSlicer { Payload payload = null; if (content.length > 0) { - payload = Payloads.newPayload(content); + payload = new ByteArrayPayload(content); ContentMetadata cm = metaData.toBuilder().contentLength((long)content.length).contentMD5((HashCode) null).build(); payload.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(cm)); } diff --git a/core/src/main/java/org/jclouds/io/payloads/StringPayload.java b/core/src/main/java/org/jclouds/io/payloads/StringPayload.java index 8342324688..38650622af 100644 --- a/core/src/main/java/org/jclouds/io/payloads/StringPayload.java +++ b/core/src/main/java/org/jclouds/io/payloads/StringPayload.java @@ -23,7 +23,7 @@ import com.google.common.base.Charsets; /** * This implementation converts the String to a byte array using UTF-8 encoding. If you wish to use - * a different encoding, please use {@link ByteSourcePayload}. + * a different encoding, please use {@link ByteArrayPayload}. * * @deprecated see ByteSourcePayload */ diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index 7915ac18e5..74b1ac17c4 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -300,7 +300,7 @@ public class RestAnnotationProcessor implements Function headers = LinkedHashMultimap.create(); String message = null; 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 9545e75136..c0db91977d 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 @@ -18,6 +18,7 @@ package org.jclouds.aws.s3; import static com.google.common.hash.Hashing.md5; import static org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions.Builder.storageClass; +import static org.jclouds.io.Payloads.newByteArrayPayload; import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -40,7 +41,6 @@ import org.jclouds.blobstore.options.PutOptions; import org.jclouds.domain.Location; import org.jclouds.io.ByteStreams2; import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; import org.jclouds.s3.S3Client; import org.jclouds.s3.S3ClientLiveTest; import org.jclouds.s3.domain.ListBucketResponse; @@ -92,7 +92,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { byte[] buffer = oneHundredOneConstitutions.read(); assertEquals(oneHundredOneConstitutions.size(), (long) buffer.length); - Payload part1 = Payloads.newPayload(buffer); + Payload part1 = newByteArrayPayload(buffer); part1.getContentMetadata().setContentLength((long) buffer.length); part1.getContentMetadata().setContentMD5(oneHundredOneConstitutionsMD5); diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java index 5ad73d1360..831ecebc7e 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java @@ -44,7 +44,7 @@ import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.http.HttpResponseException; import org.jclouds.http.options.GetOptions; -import org.jclouds.io.Payloads; +import org.jclouds.io.payloads.ByteArrayPayload; import org.jclouds.util.Strings2; import org.jclouds.util.Throwables2; import org.testng.annotations.Test; @@ -358,9 +358,9 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { String blockIdB = BaseEncoding.base64().encode((blockBlob + "-" + B).getBytes()); String blockIdC = BaseEncoding.base64().encode((blockBlob + "-" + C).getBytes()); getApi().createContainer(blockContainer); - getApi().putBlock(blockContainer, blockBlob, blockIdA, Payloads.newPayload(A.getBytes())); - getApi().putBlock(blockContainer, blockBlob, blockIdB, Payloads.newPayload(B.getBytes())); - getApi().putBlock(blockContainer, blockBlob, blockIdC, Payloads.newPayload(C.getBytes())); + getApi().putBlock(blockContainer, blockBlob, blockIdA, new ByteArrayPayload(A.getBytes())); + getApi().putBlock(blockContainer, blockBlob, blockIdB, new ByteArrayPayload(B.getBytes())); + getApi().putBlock(blockContainer, blockBlob, blockIdC, new ByteArrayPayload(C.getBytes())); getApi().putBlockList(blockContainer, blockBlob, Arrays.asList(blockIdA, blockIdB, blockIdC)); ListBlobBlocksResponse blocks = getApi().getBlockList(blockContainer, blockBlob); assertEquals(3, blocks.getBlocks().size());