/** * Throws an exception if a bucket is null or contains a null/empty name. * @param bucket * @param action * the action being attempted which this assertion is applied, for debugging purposes. * @throws ServiceException */ protected void assertValidBucket(StorageBucket bucket, String action) throws ServiceException { if (bucket == null || bucket.getName() == null || bucket.getName().length() == 0) { throw new ServiceException("The action " + action + " cannot be performed with an invalid bucket: " + bucket); } }
/** * Throws an exception if a bucket is null or contains a null/empty name. * @param bucket * @param action * the action being attempted which this assertion is applied, for debugging purposes. * @throws ServiceException */ protected void assertValidBucket(StorageBucket bucket, String action) throws ServiceException { if (bucket == null || bucket.getName() == null || bucket.getName().length() == 0) { throw new ServiceException("The action " + action + " cannot be performed with an invalid bucket: " + bucket); } }
public static void registerMBeans(StorageBucket[] buckets) { if (!isEnabled) { return; } for (int i=0; i<buckets.length; i++) { getInstance(buckets[i].getName()); } }
public static void registerMBeans(StorageBucket[] buckets) { if (!isEnabled) { return; } for (int i=0; i<buckets.length; i++) { getInstance(buckets[i].getName()); } }
@Override public String toString() { return "StorageBucket [name=" + getName() + "] Metadata=" + getMetadataMap(); }
@Override public String toString() { return "StorageBucket [name=" + getName() + "] Metadata=" + getMetadataMap(); }
/** * Deletes a bucket. Only the owner of a bucket may delete it. * <p> * This method cannot be performed by anonymous services. * * @param bucket * the bucket to delete. * @throws ServiceException */ public void deleteBucket(StorageBucket bucket) throws ServiceException { assertValidBucket(bucket, "Delete bucket"); deleteBucketImpl(bucket.getName()); }
/** * Deletes a bucket. Only the owner of a bucket may delete it. * <p> * This method cannot be performed by anonymous services. * * @param bucket * the bucket to delete. * @throws ServiceException */ public void deleteBucket(StorageBucket bucket) throws ServiceException { assertValidBucket(bucket, "Delete bucket"); deleteBucketImpl(bucket.getName()); }
/** * Returns a bucket in your account by listing all your buckets * (using {@link #listAllBuckets()}), and looking for the named bucket in * this list. * <p> * This method cannot be performed by anonymous services. * * @param bucketName * @return * the bucket in your account, or null if you do not own the named bucket. * * @throws ServiceException */ public StorageBucket getBucket(String bucketName) throws ServiceException { assertAuthenticatedConnection("Get Bucket"); // List existing buckets and return the named bucket if it exists. StorageBucket[] existingBuckets = listAllBuckets(); for (int i = 0; i < existingBuckets.length; i++) { if (existingBuckets[i].getName().equals(bucketName)) { return existingBuckets[i]; } } return null; }
/** * Returns a bucket in your account by listing all your buckets * (using {@link #listAllBuckets()}), and looking for the named bucket in * this list. * <p> * This method cannot be performed by anonymous services. * * @param bucketName * @return * the bucket in your account, or null if you do not own the named bucket. * * @throws ServiceException */ public StorageBucket getBucket(String bucketName) throws ServiceException { assertAuthenticatedConnection("Get Bucket"); // List existing buckets and return the named bucket if it exists. StorageBucket[] existingBuckets = listAllBuckets(); for (int i = 0; i < existingBuckets.length; i++) { if (existingBuckets[i].getName().equals(bucketName)) { return existingBuckets[i]; } } return null; }
/** * Applies access control settings to a bucket. The ACL settings must be included * inside the bucket. * * This method can be performed by anonymous services, but can only succeed if the * bucket's existing ACL already allows write access by the anonymous user. * In general, you can only access the ACL of a bucket if the ACL already in place * for that bucket allows you to do so. * * @param bucket * a bucket with ACL settings to apply. * @throws ServiceException */ public void putBucketAcl(StorageBucket bucket) throws ServiceException { assertValidBucket(bucket, "Put Bucket Access Control List"); putBucketAcl(bucket.getName(), bucket.getAcl()); }
/** * Applies access control settings to a bucket. The ACL settings must be included * inside the bucket. * * This method can be performed by anonymous services, but can only succeed if the * bucket's existing ACL already allows write access by the anonymous user. * In general, you can only access the ACL of a bucket if the ACL already in place * for that bucket allows you to do so. * * @param bucket * a bucket with ACL settings to apply. * @throws ServiceException */ public void putBucketAcl(StorageBucket bucket) throws ServiceException { assertValidBucket(bucket, "Put Bucket Access Control List"); putBucketAcl(bucket.getName(), bucket.getAcl()); }
/** * Create a bucket with the Access Control List settings of the bucket object (if any). * <p> * <b>Caution:</b> Performing this operation unnecessarily when a bucket already * exists may cause OperationAborted errors with the message "A conflicting conditional * operation is currently in progress against this resource.". To avoid this error, use the * {@link #getOrCreateBucket(String)} in situations where the bucket may already exist. * <p> * This method cannot be performed by anonymous services. * * @param bucket * the bucket to create, including optional ACL settings. * @return * the created bucket object. <b>Note:</b> the object returned has minimal information about * the bucket that was created, including only the bucket's name. * @throws ServiceException */ public StorageBucket createBucket(StorageBucket bucket) throws ServiceException { return createBucketImpl(bucket.getName(), bucket.getLocation(), bucket.getAcl()); }
/** * Create a bucket with the Access Control List settings of the bucket object (if any). * <p> * <b>Caution:</b> Performing this operation unnecessarily when a bucket already * exists may cause OperationAborted errors with the message "A conflicting conditional * operation is currently in progress against this resource.". To avoid this error, use the * {@link #getOrCreateBucket(String)} in situations where the bucket may already exist. * <p> * This method cannot be performed by anonymous services. * * @param bucket * the bucket to create, including optional ACL settings. * @return * the created bucket object. <b>Note:</b> the object returned has minimal information about * the bucket that was created, including only the bucket's name. * @throws ServiceException */ public StorageBucket createBucket(StorageBucket bucket) throws ServiceException { return createBucketImpl(bucket.getName(), bucket.getLocation(), bucket.getAcl()); }
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); new DownloadPackage[downloadPackagesList.size()]); (new ThreadedStorageService(storageService, serviceEventAdaptor)).downloadObjects( bucket.getName(), downloadPackages); serviceEventAdaptor.throwErrorIfPresent(); new StorageObject[objectsMoved.size()]); (new ThreadedStorageService(storageService, serviceEventAdaptor)).deleteObjects( bucket.getName(), objects); serviceEventAdaptor.throwErrorIfPresent();
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); new DownloadPackage[downloadPackagesList.size()]); (new ThreadedStorageService(storageService, serviceEventAdaptor)).downloadObjects( bucket.getName(), downloadPackages); serviceEventAdaptor.throwErrorIfPresent(); new StorageObject[objectsMoved.size()]); (new ThreadedStorageService(storageService, serviceEventAdaptor)).deleteObjects( bucket.getName(), objects); serviceEventAdaptor.throwErrorIfPresent();
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); priorLastKey = result.priorLastKey; bucket.getName(), objectsForStandardPut.toArray(new StorageObject[] {})); serviceEventAdaptor.throwErrorIfPresent(); bucket.getName(), (S3Service)storageService, objectsForMultipartUpload, serviceEventAdaptor); (new ThreadedStorageService(storageService, serviceEventAdaptor)).deleteObjects(bucket.getName(), objects); serviceEventAdaptor.throwErrorIfPresent();
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); priorLastKey = result.priorLastKey; bucket.getName(), objectsForStandardPut.toArray(new StorageObject[] {})); serviceEventAdaptor.throwErrorIfPresent(); bucket.getName(), (S3Service)storageService, objectsForMultipartUpload, serviceEventAdaptor); (new ThreadedStorageService(storageService, serviceEventAdaptor)).deleteObjects(bucket.getName(), objects); serviceEventAdaptor.throwErrorIfPresent();
final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); if(b.getOwner() != null) {