diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/internal/BaseAtmosBlobStore.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/internal/BaseAtmosBlobStore.java index f91f415a46..94e8043524 100644 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/internal/BaseAtmosBlobStore.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/internal/BaseAtmosBlobStore.java @@ -88,8 +88,10 @@ public class BaseAtmosBlobStore { .getClass().getName())); } - public Blob newBlob() { - return blobFactory.create(null); + public Blob newBlob(String name) { + Blob blob = blobFactory.create(null); + blob.getMetadata().setName(name); + return blob; } } diff --git a/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStoreContextBuilderTest.java b/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStoreContextBuilderTest.java index 541e7668fe..cbe1b94764 100644 --- a/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStoreContextBuilderTest.java +++ b/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStoreContextBuilderTest.java @@ -75,7 +75,7 @@ public class AtmosBlobStoreContextBuilderTest { assertEquals(context.getAsyncApi().getClass(), StubAtmosStorageAsyncClient.class); assertEquals(context.getAsyncBlobStore().getClass(), AtmosAsyncBlobStore.class); assertEquals(context.getAsyncApi().newObject().getClass(), AtmosObjectImpl.class); - assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class); + assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class); assertEquals(context.getAccount(), "id"); assertEquals(context.getEndPoint(), URI.create("https://localhost/azurestub")); } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java b/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java index fe5230c82d..cd8ef5bc23 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/services/InstanceClient.java @@ -508,6 +508,55 @@ public interface InstanceClient { * {@link InstanceState#STOPPING} to {@link InstanceState#STOPPED} * * + * The {@code blockDeviceMapping} option takes a value in the following format: + * =[:[:]] + *
    + *
  1. device-name - this is the device name as it should be exposed to the instance, for example + * /dev/sdb. This is the same as the device field specified in the AttachVolume call today. This + * field also serves as the key for the structure.
  2. + *
  3. snapshot-id - the ID of the EBS snapshot to be used when creating the volume. This field + * is optional. If it is not specified, the volume-size field must be present to create a blank + * volume of the specified size.
  4. + *
  5. volume-size - the size (GiBs) of the volume. This field is optional unless no snapshot-id + * is present. If a snapshot-id is present, the size must be equal to or larger than the + * snapshot's volume size.
  6. + *
  7. delete-on-termination - this indicates whether the volume should be deleted on + * termination. It defaults to ' true '.
  8. + *
+ *

+ * Note that the device names between Linux and Windows differ. For Linux, ensure that your + * device name is in the form /dev/sd[a-z] . For example, /dev/sda , /dev/sdb and /dev/sdh are + * all valid device names. + *

+ * For Windows, the root device is still referred to as /dev/sda1 . For other devices, ensure + * that they are in the form /xvd[c-p] . For example, /xvde , /xvdf and /xvdp are all valid + * Windows device names. + *

+ * Here are a few extra examples on how this functionality can be used. + * + *

    + *
  1. + * resize the root volume: @{code /dev/sda1=:100}
  2. + *
  3. + * don't delete the root volume: {@code /dev/sda1=:100:false}
  4. + *
  5. + * TODO: unverified: create and attach an additional volume at launch: {@code + * /dev/sdb=snap-e8a23d81,/dev/sdc=:200} + *

    + * The above example will create and attach the following EBS volumes at launch time: + *

      + *
    1. + * /dev/sdb - a 10 GiBs EBS volume containing an ext3 file system; this is an Amazon shared + * snapshot.
    2. + *
    3. + * /dev/sdc - an empty 200 GiB EBS volume.
    4. + *
    + *
  6. + *
  7. + * TODO: unverified: cresize the root partition of a Windows 2008 image and add an additional 100 + * GiB device: {@code /dev/sda1=:100,/dev/xvdc=:100}
  8. + *
+ * * @param region * Instances are tied to Availability Zones. However, the instance ID is tied to the * Region. diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/internal/BaseS3BlobStore.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/internal/BaseS3BlobStore.java index 0397ebacec..83d57cfe00 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/internal/BaseS3BlobStore.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/internal/BaseS3BlobStore.java @@ -93,8 +93,10 @@ public class BaseS3BlobStore { .getClass().getName())); } - public Blob newBlob() { - return blobFactory.create(null); + public Blob newBlob(String name) { + Blob blob = blobFactory.create(null); + blob.getMetadata().setName(name); + return blob; } } diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/S3BlobStoreContextBuilderTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/S3BlobStoreContextBuilderTest.java index 0967782ff0..b7e894db36 100644 --- a/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/S3BlobStoreContextBuilderTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/S3BlobStoreContextBuilderTest.java @@ -72,7 +72,7 @@ public class S3BlobStoreContextBuilderTest { assertEquals(context.getAsyncApi().getClass(), StubS3AsyncClient.class); assertEquals(context.getAsyncBlobStore().getClass(), S3AsyncBlobStore.class); assertEquals(context.getAsyncApi().newS3Object().getClass(), S3ObjectImpl.class); - assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class); + assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class); assertEquals(context.getAccount(), "id"); assertEquals(context.getEndPoint(), URI.create("https://localhost/s3stub")); } diff --git a/aws/demos/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java b/aws/demos/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java index cbba4fe6aa..d2ab9e0af7 100755 --- a/aws/demos/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java +++ b/aws/demos/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java @@ -58,8 +58,7 @@ public class MainApp { BlobStore blobStore = context.getBlobStore(); blobStore.createContainer(containerName); - Blob blob = blobStore.newBlob(); - blob.getMetadata().setName("test"); + Blob blob = blobStore.newBlob("test"); blob.setPayload("testdata"); blobStore.putBlob(containerName, blob); diff --git a/aws/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java b/aws/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java index 904acd468b..716f742948 100755 --- a/aws/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java +++ b/aws/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java @@ -127,8 +127,7 @@ public class JCloudsS3ServiceLiveTest extends BaseBlobStoreIntegrationTest>() { - })) != null; + assert i.getInstance(Key + .get(new TypeLiteral>() { + })) != null; assert i.getInstance(AzureBlob.class) != null; assert i.getInstance(Blob.class) != null; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 1d984350b9..56cc8d8475 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -35,7 +35,7 @@ import org.jclouds.blobstore.options.ListContainerOptions; */ public interface AsyncBlobStore { - Blob newBlob(); + Blob newBlob(String name); /** * Lists all root-level resources available to the account. diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobMap.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobMap.java index 693dc0cc7e..6fa88f880c 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobMap.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobMap.java @@ -34,7 +34,7 @@ import com.google.inject.ImplementedBy; @ImplementedBy(BlobMapImpl.class) public interface BlobMap extends ListableMap { - Blob newBlob(); + Blob newBlob(String name); public static interface Factory { BlobMap create(String containerName, ListContainerOptions listOptions); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 2e2f979288..71495e70f9 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -33,7 +33,7 @@ import org.jclouds.blobstore.options.ListContainerOptions; */ public interface BlobStore { - Blob newBlob(); + Blob newBlob(String name); /** * Lists all root-level resources available to the account. diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobMapImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobMapImpl.java index 4019704c5a..c534ca93c8 100755 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobMapImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobMapImpl.java @@ -213,8 +213,8 @@ public class BlobMapImpl extends BaseBlobMap implements BlobMap { }); } - public Blob newBlob() { - return connection.newBlob(); + public Blob newBlob(String name) { + return connection.newBlob(name); } } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/InputStreamMapImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/InputStreamMapImpl.java index f55bda46ea..6336ba976d 100755 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/InputStreamMapImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/InputStreamMapImpl.java @@ -225,8 +225,7 @@ public class InputStreamMapImpl extends BaseBlobMap implements Inpu try { Set> puts = Sets.newHashSet(); for (Map.Entry entry : map.entrySet()) { - Blob object = connection.newBlob(); - object.getMetadata().setName(prefixer.apply(entry.getKey())); + Blob object = connection.newBlob(prefixer.apply(entry.getKey())); object.setPayload(Payloads.newPayload(entry.getValue())); object.generateMD5(); puts.add(connection.putBlob(containerName, object)); @@ -286,11 +285,10 @@ public class InputStreamMapImpl extends BaseBlobMap implements Inpu * @see S3Client#put(String, Blob) */ @VisibleForTesting - InputStream putInternal(String s, Payload payload) { - Blob object = connection.newBlob(); - object.getMetadata().setName(prefixer.apply(s)); + InputStream putInternal(String name, Payload payload) { + Blob object = connection.newBlob(prefixer.apply(name)); try { - InputStream returnVal = containsKey(s) ? get(s) : null; + InputStream returnVal = containsKey(name) ? get(name) : null; object.setPayload(payload); object.generateMD5(); connection.putBlob(containerName, object).get(requestTimeoutMilliseconds, 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 8ea94307f8..c382eef27c 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 @@ -58,8 +58,7 @@ public class MarkerFileMkdirStrategy implements MkdirStrategy { try { if (!connection.directoryExists(containerName, directory).get(requestTimeoutMilliseconds, TimeUnit.MILLISECONDS)) { - Blob blob = connection.newBlob(); - blob.getMetadata().setName(directory + directorySuffix); + Blob blob = connection.newBlob(directory + directorySuffix); blob.setPayload(""); blob.getMetadata().setContentType("application/directory"); connection.putBlob(containerName, blob).get(requestTimeoutMilliseconds, diff --git a/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java b/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java index a342a9fc98..79ec52e0b0 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java @@ -37,7 +37,7 @@ import org.jclouds.util.Utils; public class BlobStoreUtils { public static Blob newBlob(BlobStore blobStore, ResourceMetadata blobMeta) { - Blob blob = blobStore.newBlob(); + Blob blob = blobStore.newBlob(blobMeta.getName()); if (blobMeta instanceof BlobMetadata) { blob.getMetadata().setContentMD5(((BlobMetadata) blobMeta).getContentMD5()); blob.getMetadata().setContentType(((BlobMetadata) blobMeta).getContentType()); @@ -46,17 +46,10 @@ public class BlobStoreUtils { blob.getMetadata().setId(blobMeta.getId()); blob.getMetadata().setLastModified(blobMeta.getLastModified()); blob.getMetadata().setLocation(blobMeta.getLocation()); - blob.getMetadata().setName(blobMeta.getName()); blob.getMetadata().setUserMetadata(blobMeta.getUserMetadata()); return blob; } - public static Blob newBlob(BlobStore blobStore, String name) { - Blob blob = blobStore.newBlob(); - blob.getMetadata().setName(name); - return blob; - } - public static String parseContainerFromPath(String path) { String container = path; if (path.indexOf('/') != -1) diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java index 3e2cab19ec..9865d50369 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java @@ -296,7 +296,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest< @Test(groups = { "integration", "live" }, dataProvider = "putTests") public void testPutObject(String key, String type, Object content, Object realObject) throws InterruptedException, IOException { - Blob object = newBlob(key); + Blob object = context.getBlobStore().newBlob(key); object.getMetadata().setContentType(type); object.setPayload(Payloads.newPayload(content)); if (content instanceof InputStream) { @@ -318,7 +318,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest< public void testMetadata() throws InterruptedException { String key = "hello"; - Blob object = newBlob(key); + Blob object = context.getBlobStore().newBlob(key); object.setPayload(TEST_STRING); object.getMetadata().setContentType("text/plain"); object.getMetadata().setSize(new Long(TEST_STRING.length())); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java index a446d5d8bc..92aabeb3e7 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java @@ -65,7 +65,7 @@ public class BaseBlobLiveTest extends BaseBlobStoreIntegrationTest { int length = connection.getContentLength(); InputStream input = connection.getInputStream(); - Blob object = newBlob(key); + Blob object = context.getBlobStore().newBlob(key); object.setPayload(input); object.setContentLength(length); object.getMetadata().setContentMD5(md5); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java index a9718def30..dd8dacab52 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java @@ -129,7 +129,7 @@ public class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest map = createMap(context, bucketName); putStringWithMD5(map, "one", "apple"); - Blob object = newBlob("one"); + Blob object = context.getBlobStore().newBlob("one"); object.setPayload("apple"); object.generateMD5(); assertConsistencyAwareContainsValue(map, object); @@ -157,7 +157,7 @@ public class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest map = createMap(context, bucketName); - Blob object = newBlob("one"); + Blob object = context.getBlobStore().newBlob("one"); object.setPayload(Utils.toInputStream("apple")); object.generateMD5(); Blob old = map.put(object.getMetadata().getName(), object); @@ -178,7 +178,7 @@ public class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest map = createMap(context, bucketName); Map newMap = new HashMap(); for (String key : fiveInputs.keySet()) { - Blob object = newBlob(key); + Blob object = context.getBlobStore().newBlob(key); object.setPayload(fiveInputs.get(key)); object.setContentLength(new Long(fiveBytes.get(key).length)); newMap.put(key, object); @@ -194,7 +194,7 @@ public class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest map, String key, String value) { - Blob object = newBlob(key); + Blob object = context.getBlobStore().newBlob(key); object.setPayload(value); object.generateMD5(); map.put(key, object); @@ -203,7 +203,7 @@ public class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest map) { Map newMap = new HashMap(); for (Map.Entry entry : fiveStrings.entrySet()) { - Blob object = newBlob(entry.getKey()); + Blob object = context.getBlobStore().newBlob(entry.getKey()); object.setPayload(entry.getValue()); newMap.put(entry.getKey(), object); } @@ -213,7 +213,7 @@ public class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest map) { Map newMap = new HashMap(); for (Map.Entry entry : fiveStringsUnderPath.entrySet()) { - Blob object = newBlob(entry.getKey()); + Blob object = context.getBlobStore().newBlob(entry.getKey()); object.setPayload(entry.getValue()); newMap.put(entry.getKey(), object); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index 50d6e1e0f7..48f67f2e52 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -125,12 +125,6 @@ public class BaseBlobStoreIntegrationTest { private static volatile boolean initialized = false; - protected Blob newBlob(String key) { - Blob object = context.getBlobStore().newBlob(); - object.getMetadata().setName(key); - return object; - } - protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext) throws Exception { while (!initialized) { @@ -256,7 +250,7 @@ public class BaseBlobStoreIntegrationTest { } protected String addBlobToContainer(String sourceContainer, String key) { - Blob sourceObject = newBlob(key); + Blob sourceObject = context.getBlobStore().newBlob(key); sourceObject.getMetadata().setContentType("text/xml"); sourceObject.setPayload(TEST_STRING); return addBlobToContainer(sourceContainer, sourceObject); @@ -265,7 +259,7 @@ public class BaseBlobStoreIntegrationTest { protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) { for (Entry entry : Iterables.concat(fiveStrings.entrySet(), fiveStringsUnderPath.entrySet())) { - Blob sourceObject = newBlob(entry.getKey()); + Blob sourceObject = context.getBlobStore().newBlob(entry.getKey()); sourceObject.getMetadata().setContentType("text/xml"); sourceObject.setPayload(entry.getValue()); addBlobToContainer(sourceContainer, sourceObject); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index 32155f2c35..66345f602c 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -197,7 +197,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration protected void addAlphabetUnderRoot(String containerName) throws InterruptedException { for (char letter = 'a'; letter <= 'z'; letter++) { - Blob blob = newBlob(letter + ""); + Blob blob = context.getBlobStore().newBlob(letter + ""); blob.setPayload(letter + "content"); context.getBlobStore().putBlob(containerName, blob); } @@ -205,7 +205,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration protected void add15UnderRoot(String containerName) throws InterruptedException { for (int i = 0; i < 15; i++) { - Blob blob = newBlob(i + ""); + Blob blob = context.getBlobStore().newBlob(i + ""); blob.setPayload(i + "content"); context.getBlobStore().putBlob(containerName, blob); } @@ -214,7 +214,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException { for (int i = 0; i < 10; i++) { - Blob blob = newBlob(prefix + "/" + i); + Blob blob = context.getBlobStore().newBlob(prefix + "/" + i); blob.setPayload(i + "content"); context.getBlobStore().putBlob(containerName, blob); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java index 425c922f84..21707d1688 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java @@ -681,8 +681,10 @@ public class StubAsyncBlobStore implements AsyncBlobStore { }); } - public Blob newBlob() { - return blobProvider.create(null); + public Blob newBlob(String name) { + Blob blob = blobProvider.create(null); + blob.getMetadata().setName(name); + return blob; } } diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index e2514a3576..9a1b711968 100644 --- a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -61,9 +61,8 @@ public class StoreTweetsController extends HttpServlet { } public Blob apply(Status from) { - Blob to = map.newBlob(); + Blob to = map.newBlob(from.getId() + ""); to.getMetadata().setContentType(MediaType.TEXT_PLAIN); - to.getMetadata().setName(from.getId() + ""); to.setPayload(from.getText()); to.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, from.getUser().getScreenName()); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index f001a6683d..e31ec2f10d 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -54,8 +54,7 @@ public class AddTweetsControllerTest { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); context.getAsyncBlobStore().createContainer(container).get(); - Blob blob = context.getAsyncBlobStore().newBlob(); - blob.getMetadata().setName("1"); + Blob blob = context.getAsyncBlobStore().newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); context.getAsyncBlobStore().putBlob(container, blob).get(); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index f65ed387d1..01346f4dfc 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -50,8 +50,7 @@ public class KeyToStoredTweetStatusTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { BlobMap map = createMap(); - Blob blob = map.newBlob(); - blob.getMetadata().setName("1"); + Blob blob = map.newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); map.put("1", blob); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index cde5f15a47..18b05a0ade 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -51,8 +51,7 @@ public class ServiceToStoredTweetStatusesTest { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); context.getAsyncBlobStore().createContainer(container).get(); - Blob blob = context.getAsyncBlobStore().newBlob(); - blob.getMetadata().setName("1"); + Blob blob = context.getAsyncBlobStore().newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); context.getAsyncBlobStore().putBlob(container, blob).get(); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/internal/BaseCloudFilesBlobStore.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/internal/BaseCloudFilesBlobStore.java index ee5025d5d6..a79f4115b7 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/internal/BaseCloudFilesBlobStore.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/internal/BaseCloudFilesBlobStore.java @@ -81,8 +81,7 @@ public class BaseCloudFilesBlobStore { this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions, "container2ContainerListOptions"); this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); - this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy, - "getDirectoryStrategy"); + this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy, "getDirectoryStrategy"); this.mkdirStrategy = checkNotNull(mkdirStrategy, "mkdirStrategy"); this.container2ResourceMd = checkNotNull(container2ResourceMd, "container2ResourceMd"); this.container2ResourceList = checkNotNull(container2ResourceList, "container2ResourceList"); @@ -94,8 +93,10 @@ public class BaseCloudFilesBlobStore { .getClass().getName())); } - public Blob newBlob() { - return blobFactory.create(null); + public Blob newBlob(String name) { + Blob blob = blobFactory.create(null); + blob.getMetadata().setName(name); + return blob; } } diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStoreContextBuilderTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStoreContextBuilderTest.java index f34e2806e7..60499d1e27 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStoreContextBuilderTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStoreContextBuilderTest.java @@ -78,7 +78,7 @@ public class CloudFilesBlobStoreContextBuilderTest { assertEquals(context.getAsyncApi().getClass(), StubCloudFilesAsyncClient.class); assertEquals(context.getAsyncBlobStore().getClass(), CloudFilesAsyncBlobStore.class); assertEquals(context.getAsyncApi().newCFObject().getClass(), CFObjectImpl.class); - assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class); + assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class); assertEquals(context.getAccount(), "id"); assertEquals(context.getEndPoint(), URI.create("http://localhost/rackspacestub/cloudfiles")); } diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java index 18746fb625..5fee1862e0 100644 --- a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java @@ -246,8 +246,8 @@ public class BlobStoreFileObject extends AbstractFileObject { return new BlobStoreOutputStream(file, getBlobStore(), BlobStoreUtils.newBlob( getBlobStore(), metadata)); } else { - return new BlobStoreOutputStream(file, getBlobStore(), BlobStoreUtils.newBlob( - getBlobStore(), getNameTrimLeadingSlashes())); + return new BlobStoreOutputStream(file, getBlobStore(), getBlobStore().newBlob( + getNameTrimLeadingSlashes())); } }