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");
}
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
}
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;
}
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();
}
}
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();
}
}
Aggregations