Search in sources :

Example 6 with BlobStoreContext

use of org.jclouds.blobstore.BlobStoreContext in project legacy-jclouds-examples by jclouds.

the class DeleteObjectsAndContainer method init.

private void init(String[] args) {
    // The provider configures jclouds To use the Rackspace Cloud (US)
    // To use the Rackspace Cloud (UK) set the provider to "cloudfiles-uk"
    String provider = "cloudfiles-us";
    String username = args[0];
    String apiKey = args[1];
    BlobStoreContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).buildView(BlobStoreContext.class);
    storage = context.getBlobStore();
    swift = context.unwrap();
}
Also used : BlobStoreContext(org.jclouds.blobstore.BlobStoreContext)

Example 7 with BlobStoreContext

use of org.jclouds.blobstore.BlobStoreContext in project legacy-jclouds-examples by jclouds.

the class ListContainers method init.

private void init(String[] args) {
    // The provider configures jclouds To use the Rackspace Cloud (US)
    // To use the Rackspace Cloud (UK) set the provider to "cloudfiles-uk"
    String provider = "cloudfiles-us";
    String username = args[0];
    String apiKey = args[1];
    BlobStoreContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).buildView(BlobStoreContext.class);
    storage = context.getBlobStore();
    swift = context.unwrap();
}
Also used : BlobStoreContext(org.jclouds.blobstore.BlobStoreContext)

Example 8 with BlobStoreContext

use of org.jclouds.blobstore.BlobStoreContext in project legacy-jclouds-examples by jclouds.

the class ListObjects method init.

private void init(String[] args) {
    // The provider configures jclouds To use the Rackspace Cloud (US)
    // To use the Rackspace Cloud (UK) set the provider to "cloudfiles-uk"
    String provider = "cloudfiles-us";
    String username = args[0];
    String apiKey = args[1];
    BlobStoreContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).buildView(BlobStoreContext.class);
    storage = context.getBlobStore();
    swift = context.unwrap();
}
Also used : BlobStoreContext(org.jclouds.blobstore.BlobStoreContext)

Example 9 with BlobStoreContext

use of org.jclouds.blobstore.BlobStoreContext in project dhis2-core by dhis2.

the class JCloudsFileResourceContentStore method init.

// -------------------------------------------------------------------------
// Life cycle management
// -------------------------------------------------------------------------
@PostConstruct
public void init() {
    // ---------------------------------------------------------------------
    // Bootstrap config
    // ---------------------------------------------------------------------
    config = new BlobStoreProperties(configurationProvider.getProperty(ConfigurationKey.FILESTORE_PROVIDER), configurationProvider.getProperty(ConfigurationKey.FILESTORE_LOCATION), configurationProvider.getProperty(ConfigurationKey.FILESTORE_CONTAINER));
    Pair<Credentials, Properties> providerConfig = configureForProvider(config.provider, configurationProvider.getProperty(ConfigurationKey.FILESTORE_IDENTITY), configurationProvider.getProperty(ConfigurationKey.FILESTORE_SECRET));
    // ---------------------------------------------------------------------
    // Set up JClouds context
    // ---------------------------------------------------------------------
    blobStoreContext = ContextBuilder.newBuilder(config.provider).credentials(providerConfig.getLeft().identity, providerConfig.getLeft().credential).overrides(providerConfig.getRight()).build(BlobStoreContext.class);
    blobStore = blobStoreContext.getBlobStore();
    Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id(config.provider).description(config.provider).build();
    try {
        blobStore.createContainerInLocation(createRegionLocation(config, provider), config.container);
        log.info(String.format("File store configured with provider: '%s', container: '%s' and location: '%s'.", config.provider, config.container, config.location));
    } catch (HttpResponseException ex) {
        log.error(String.format("Could not configure file store with provider '%s' and container '%s'.\n" + "File storage will not be available.", config.provider, config.container), ex);
    } catch (AuthorizationException ex) {
        log.error(String.format("Could not authenticate with file store provider '%s' and container '%s'. " + "File storage will not be available.", config.provider, config.location), ex);
    }
}
Also used : LocationBuilder(org.jclouds.domain.LocationBuilder) AuthorizationException(org.jclouds.rest.AuthorizationException) HttpResponseException(org.jclouds.http.HttpResponseException) BlobStoreContext(org.jclouds.blobstore.BlobStoreContext) Properties(java.util.Properties) Credentials(org.jclouds.domain.Credentials) Location(org.jclouds.domain.Location) PostConstruct(javax.annotation.PostConstruct)

Example 10 with BlobStoreContext

use of org.jclouds.blobstore.BlobStoreContext in project legacy-jclouds-examples by jclouds.

the class CreateContainer method init.

private void init(String[] args) {
    // The provider configures jclouds To use the Rackspace Cloud (US)
    // To use the Rackspace Cloud (UK) set the provider to "cloudfiles-uk"
    String provider = "cloudfiles-us";
    String username = args[0];
    String apiKey = args[1];
    BlobStoreContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).buildView(BlobStoreContext.class);
    storage = context.getBlobStore();
    swift = context.unwrap();
}
Also used : BlobStoreContext(org.jclouds.blobstore.BlobStoreContext)

Aggregations

BlobStoreContext (org.jclouds.blobstore.BlobStoreContext)11 Properties (java.util.Properties)4 Blob (org.jclouds.blobstore.domain.Blob)3 BlobStore (org.jclouds.blobstore.BlobStore)2 BlobStoreContextFactory (org.jclouds.blobstore.BlobStoreContextFactory)2 File (java.io.File)1 InputStream (java.io.InputStream)1 ExecutionException (java.util.concurrent.ExecutionException)1 PostConstruct (javax.annotation.PostConstruct)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 AtmosClient (org.jclouds.atmos.AtmosClient)1 AzureBlobAsyncClient (org.jclouds.azureblob.AzureBlobAsyncClient)1 AzureBlobClient (org.jclouds.azureblob.AzureBlobClient)1 AsyncBlobStore (org.jclouds.blobstore.AsyncBlobStore)1 StorageMetadata (org.jclouds.blobstore.domain.StorageMetadata)1 Credentials (org.jclouds.domain.Credentials)1 Location (org.jclouds.domain.Location)1 LocationBuilder (org.jclouds.domain.LocationBuilder)1 HdfsPayload (org.jclouds.examples.blobstore.hdfs.io.payloads.HdfsPayload)1