Search in sources :

Example 1 with BlobStore

use of org.jclouds.blobstore.BlobStore in project camel by apache.

the class JcloudsSpringBlobstoreTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    BlobStore blobStore = ContextBuilder.newBuilder("transient").credentials("id", "credential").buildView(BlobStoreContext.class).getBlobStore();
    blobStore.createContainerInLocation(null, "foo");
    blobStore.createContainerInLocation(null, "bar");
}
Also used : BlobStoreContext(org.jclouds.blobstore.BlobStoreContext) BlobStore(org.jclouds.blobstore.BlobStore) BeforeClass(org.junit.BeforeClass)

Example 2 with BlobStore

use of org.jclouds.blobstore.BlobStore in project artifact-manager-s3-plugin by jenkinsci.

the class JCloudsArtifactManager method copyAllArtifactsAndStashes.

@Override
public void copyAllArtifactsAndStashes(Run<?, ?> to, TaskListener listener) throws IOException, InterruptedException {
    ArtifactManager am = to.pickArtifactManager();
    if (!(am instanceof JCloudsArtifactManager)) {
        throw new AbortException("Cannot copy artifacts and stashes to " + to + " using " + am.getClass().getName());
    }
    JCloudsArtifactManager dest = (JCloudsArtifactManager) am;
    String prefix = getBlobPath("", PREFIX, key, id);
    BlobStore blobStore = getContext(BLOB_CONTAINER).getBlobStore();
    Iterator<StorageMetadata> it = new JCloudsBlobStore.PageSetIterable(blobStore, BLOB_CONTAINER, ListContainerOptions.Builder.prefix(prefix).recursive());
    while (it.hasNext()) {
        StorageMetadata sm = it.next();
        String path = sm.getName();
        assert path.startsWith(prefix);
        String destPath = getBlobPath(path.substring(prefix.length()), PREFIX, dest.key, dest.id);
        LOGGER.fine("copying " + path + " to " + destPath);
        blobStore.copyBlob(BLOB_CONTAINER, path, BLOB_CONTAINER, destPath, CopyOptions.NONE);
    }
// TODO print some summary to listener
}
Also used : StorageMetadata(org.jclouds.blobstore.domain.StorageMetadata) ArtifactManager(jenkins.model.ArtifactManager) BlobStore(org.jclouds.blobstore.BlobStore) AbortException(hudson.AbortException)

Example 3 with BlobStore

use of org.jclouds.blobstore.BlobStore in project artifact-manager-s3-plugin by jenkinsci.

the class JCloudsArtifactManager method delete.

@Override
public boolean delete() throws IOException, InterruptedException {
    BlobStore blobStore = getContext(BLOB_CONTAINER).getBlobStore();
    String prefix = getBlobPath("", PREFIX, key, id);
    Iterator<StorageMetadata> it = new JCloudsBlobStore.PageSetIterable(blobStore, BLOB_CONTAINER, ListContainerOptions.Builder.prefix(prefix).recursive());
    boolean found = false;
    while (it.hasNext()) {
        StorageMetadata sm = it.next();
        String path = sm.getName();
        assert path.startsWith(prefix);
        LOGGER.fine("deleting " + path);
        blobStore.removeBlob(BLOB_CONTAINER, path);
        found = true;
    }
    return found;
}
Also used : StorageMetadata(org.jclouds.blobstore.domain.StorageMetadata) BlobStore(org.jclouds.blobstore.BlobStore)

Example 4 with BlobStore

use of org.jclouds.blobstore.BlobStore in project wildfly-camel by wildfly-extras.

the class JCloudsBlobStoreIntegrationTest method testBlobStoreConsumerWithDirectory.

@Test
public void testBlobStoreConsumerWithDirectory() throws Exception {
    BlobStore blobStore = getBlobStore();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            fromF("jclouds:blobstore:transient?container=%s&directory=dir", CONTAINER_NAME_WITH_DIR).convertBodyTo(String.class).to("mock:result");
        }
    });
    List<BlobStore> blobStores = new ArrayList<>();
    blobStores.add(blobStore);
    JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.class);
    jclouds.setBlobStores(blobStores);
    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mockEndpoint.expectedBodiesReceived("Hello Kermit");
    camelctx.start();
    try {
        JcloudsBlobStoreHelper.writeBlob(blobStore, CONTAINER_NAME_WITH_DIR, BLOB_NAME_WITH_DIR, new StringPayload("Hello Kermit"));
        mockEndpoint.assertIsSatisfied();
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList) StringPayload(org.jclouds.io.payloads.StringPayload) BlobStore(org.jclouds.blobstore.BlobStore) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JcloudsComponent(org.apache.camel.component.jclouds.JcloudsComponent) Test(org.junit.Test)

Example 5 with BlobStore

use of org.jclouds.blobstore.BlobStore in project wildfly-camel by wildfly-extras.

the class JCloudsBlobStoreIntegrationTest method testBlobStoreConsumer.

@Test
public void testBlobStoreConsumer() throws Exception {
    BlobStore blobStore = getBlobStore();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            fromF("jclouds:blobstore:transient?container=%s", CONTAINER_NAME).convertBodyTo(String.class).to("mock:result");
        }
    });
    List<BlobStore> blobStores = new ArrayList<>();
    blobStores.add(blobStore);
    JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.class);
    jclouds.setBlobStores(blobStores);
    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mockEndpoint.expectedBodiesReceived("Hello Kermit");
    camelctx.start();
    try {
        JcloudsBlobStoreHelper.writeBlob(blobStore, CONTAINER_NAME, BLOB_NAME, new StringPayload("Hello Kermit"));
        mockEndpoint.assertIsSatisfied();
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList) StringPayload(org.jclouds.io.payloads.StringPayload) BlobStore(org.jclouds.blobstore.BlobStore) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JcloudsComponent(org.apache.camel.component.jclouds.JcloudsComponent) Test(org.junit.Test)

Aggregations

BlobStore (org.jclouds.blobstore.BlobStore)15 BlobStoreContext (org.jclouds.blobstore.BlobStoreContext)5 Blob (org.jclouds.blobstore.domain.Blob)5 StorageMetadata (org.jclouds.blobstore.domain.StorageMetadata)4 ArrayList (java.util.ArrayList)3 CamelContext (org.apache.camel.CamelContext)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)3 JcloudsComponent (org.apache.camel.component.jclouds.JcloudsComponent)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 BlobStoreContextFactory (org.jclouds.blobstore.BlobStoreContextFactory)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 StringPayload (org.jclouds.io.payloads.StringPayload)2 AbortException (hudson.AbortException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Properties (java.util.Properties)1