diff --git a/blobstore-basics/README.md b/blobstore-basics/README.md index 32cb8fde..e61e9c23 100755 --- a/blobstore-basics/README.md +++ b/blobstore-basics/README.md @@ -10,14 +10,17 @@ Ensure you have maven 3.02 or higher installed, then execute 'mvn install' to bu Invoke the jar, passing the name of the cloud provider you with to access (ex. aws-s3, googlestorage), identity (ex. accesskey, username), credential (ex. secretkey, password), then the name of the container you'd like to create. -Ex. for Amazon S3 +For Amazon S3 -java -jar target/blobstore-basics-jar-with-dependencies.jar aws-s3 accesskey secretkey myfavoritecontainer + java -jar target/blobstore-basics-jar-with-dependencies.jar aws-s3 accesskey secretkey myfavoritecontainer -Ex. for Rackspace CloudFiles +For Rackspace CloudFiles -java -jar target/blobstore-basics-jar-with-dependencies.jar cloudfiles-us username apikey myfavoritecontainer + java -jar target/blobstore-basics-jar-with-dependencies.jar cloudfiles-us username apikey myfavoritecontainer +For IBM SoftLayer ObjectStore in `ams01` + + java -Djclouds.keystone.credential-type=tempAuthCredentials -Djclouds.endpoint=https://ams01.objectstorage.softlayer.net/auth/v1.0/ -jar target/blobstore-basics-jar-with-dependencies.jar openstack-swift username apikey myfavoritecontainer https://ams01.objectstorage.softlayer.net/auth/v1.0/ ## License diff --git a/blobstore-basics/pom.xml b/blobstore-basics/pom.xml index 7861ef76..4a635680 100644 --- a/blobstore-basics/pom.xml +++ b/blobstore-basics/pom.xml @@ -22,12 +22,12 @@ 4.0.0 org.apache.jclouds.examples blobstore-basics - 1.8.0 + 2.0.0 blobstore-basics jclouds blobstore example that creates a container, then displays the size of each container - 1.9.1 + 2.0.0 diff --git a/blobstore-basics/src/main/java/org/jclouds/examples/blobstore/basics/MainApp.java b/blobstore-basics/src/main/java/org/jclouds/examples/blobstore/basics/MainApp.java index 91d67770..b72f0bd8 100755 --- a/blobstore-basics/src/main/java/org/jclouds/examples/blobstore/basics/MainApp.java +++ b/blobstore-basics/src/main/java/org/jclouds/examples/blobstore/basics/MainApp.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Iterables.contains; + import java.io.IOException; import java.util.Map; import java.util.Set; @@ -36,8 +37,8 @@ import org.jclouds.domain.Location; import org.jclouds.googlecloudstorage.GoogleCloudStorageApi; import org.jclouds.googlecloudstorage.GoogleCloudStorageApiMetadata; -import org.jclouds.openstack.swift.SwiftApiMetadata; import org.jclouds.openstack.swift.v1.SwiftApi; +import org.jclouds.openstack.swift.v1.SwiftApiMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; import org.jclouds.s3.S3ApiMetadata; @@ -65,34 +66,36 @@ public class MainApp { public static final Set allKeys = ImmutableSet.copyOf(Iterables.concat(appProviders.keySet(), allApis.keySet())); public static int PARAMETERS = 4; - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"provider\" \"identity\" \"credential\" \"containerName\" "; + public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"provider\" \"identity\" \"credential\" \"containerName\"."; public static void main(String[] args) throws IOException { + String provider; + String identity; + String credential; + String containerName; + if (args.length < PARAMETERS) throw new IllegalArgumentException(INVALID_SYNTAX); // Args - - String provider = args[0]; - + provider = args[0]; // note that you can check if a provider is present ahead of time checkArgument(contains(allKeys, provider), "provider %s not in supported list: %s", provider, allKeys); - - String identity = args[1]; - String credential = args[2]; - String containerName = args[3]; + identity = args[1]; + credential = args[2]; + containerName = args[3]; // Init BlobStoreContext context = ContextBuilder.newBuilder(provider) - .credentials(identity, credential) - .buildView(BlobStoreContext.class); + .credentials(identity, credential) + .buildView(BlobStoreContext.class); + BlobStore blobStore = null; try { - ApiMetadata apiMetadata = context.unwrap().getProviderMetadata().getApiMetadata(); + blobStore = context.getBlobStore(); // Create Container - BlobStore blobStore = context.getBlobStore(); Location location = null; if (apiMetadata instanceof SwiftApiMetadata) { location = Iterables.getFirst(blobStore.listAssignableLocations(), null); @@ -138,6 +141,8 @@ public static void main(String[] args) throws IOException { } } finally { + // delete cointainer + blobStore.deleteContainer(containerName); // Close connecton context.close(); }