org.jclouds.blobstore.ContainerNotFoundException Java Examples
The following examples show how to use
org.jclouds.blobstore.ContainerNotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectStoreFileStorage.java From multiapps-controller with Apache License 2.0 | 6 votes |
@Override public void addFile(FileEntry fileEntry, File file) throws FileStorageException { String entryName = fileEntry.getId(); long fileSize = fileEntry.getSize() .longValue(); Blob blob = blobStore.blobBuilder(entryName) .payload(file) .contentDisposition(fileEntry.getName()) .contentType(MediaType.OCTET_STREAM.toString()) .userMetadata(createFileEntryMetadata(fileEntry)) .build(); try { putBlobWithRetries(blob, 3); LOGGER.debug(MessageFormat.format(Messages.STORED_FILE_0_WITH_SIZE_1_SUCCESSFULLY_2, fileEntry.getId(), fileSize)); } catch (ContainerNotFoundException e) { throw new FileStorageException(MessageFormat.format(Messages.FILE_UPLOAD_FAILED, fileEntry.getName(), fileEntry.getNamespace())); } }
Example #2
Source File: ImportCollectionIT.java From usergrid with Apache License 2.0 | 5 votes |
private static void deleteBucketsWithPrefix() { logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix ); String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR); String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR); Properties overrides = new Properties(); overrides.setProperty("s3" + ".identity", accessId); overrides.setProperty("s3" + ".credential", secretKey); final Iterable<? extends Module> MODULES = ImmutableSet .of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule()); BlobStoreContext context = ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES) .overrides(overrides).buildView(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore(); final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list(); for ( Object o : blobStoreList.toArray() ) { StorageMetadata s = (StorageMetadata)o; if ( s.getName().startsWith( bucketPrefix )) { try { blobStore.deleteContainer(s.getName()); } catch ( ContainerNotFoundException cnfe ) { logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe ); } logger.debug("Deleted bucket {}", s.getName()); } } }
Example #3
Source File: ImportResourceIT.java From usergrid with Apache License 2.0 | 5 votes |
private static void deleteBucketsWithPrefix() { logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix); String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ); String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ); Properties overrides = new Properties(); overrides.setProperty("s3" + ".identity", accessId); overrides.setProperty("s3" + ".credential", secretKey); final Iterable<? extends Module> MODULES = ImmutableSet .of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule()); BlobStoreContext context = ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES) .overrides(overrides ).buildView(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore(); final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list(); for (Object o : blobStoreList.toArray()) { StorageMetadata s = (StorageMetadata) o; if (s.getName().startsWith(bucketPrefix)) { try { blobStore.deleteContainer(s.getName()); } catch (ContainerNotFoundException cnfe) { logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe); } logger.debug("Deleted bucket {}", s.getName()); } } }