/** * 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()); }
/** * Sets the bucket's creation date - this should only be used internally by JetS3t * methods that retrieve information directly from a service. * * @param creationDate */ public void setCreationDate(Date creationDate) { addMetadata(METADATA_HEADER_CREATION_DATE, creationDate); }
/** * @return * the bucket's creation date, or null if it is unknown. */ public Date getCreationDate() { return (Date) getMetadata(METADATA_HEADER_CREATION_DATE); }
@Override public String toString() { return "StorageBucket [name=" + getName() + "] Metadata=" + getMetadataMap(); }
final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); if(b.getOwner() != null) { bucket.attributes().setOwner(b.getOwner().getId()); bucket.attributes().setCreationDate(b.getCreationDate().getTime()); if(b.isLocationKnown()) { bucket.attributes().setRegion(b.getLocation()); if(!b.isLocationKnown()) { location = session.getFeature(Location.class).getLocation(bucket).getIdentifier(); location = b.getLocation();
bucket.setName(bucketName); bucket.setLocation(location); bucket.setAcl(acl); bucket.replaceAllMetadata(map); return 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); } }
@Override public void endElement(String name, String elementText) { // Listing details. if (name.equals("ID")) { bucketsOwner.setId(elementText); } else if (name.equals("DisplayName")) { bucketsOwner.setDisplayName(elementText); } // Bucket item details. else if (name.equals("Bucket")) { if (log.isDebugEnabled()) { log.debug("Created new bucket from listing: " + currentBucket); } currentBucket.setOwner(bucketsOwner); buckets.add(currentBucket); } else if (name.equals("Name")) { currentBucket.setName(elementText); } else if (name.equals("CreationDate")) { elementText += ".000Z"; try { currentBucket.setCreationDate(ServiceUtils.parseIso8601Date(elementText)); } catch (ParseException e) { throw new RuntimeException( "Non-ISO8601 date for CreationDate in list buckets output: " + elementText, e); } } } }
/** * 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()); }
if (storageService.getProviderCredentials() == null) { bucket = new StorageBucket(bucketName); } else { bucket = storageService.createBucket(new StorageBucket(bucketName)); } catch (ServiceException e) { bucket = new StorageBucket(bucketName); } catch (ServiceException e2) {
bucket.setName(bucketName); bucket.setLocation(location); bucket.setAcl(acl); bucket.replaceAllMetadata(map); return 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); } }
@Override public void endElement(String name, String elementText) { // Listing details. if (name.equals("ID")) { bucketsOwner.setId(elementText); } else if (name.equals("DisplayName")) { bucketsOwner.setDisplayName(elementText); } // Bucket item details. else if (name.equals("Bucket")) { if (log.isDebugEnabled()) { log.debug("Created new bucket from listing: " + currentBucket); } currentBucket.setOwner(bucketsOwner); buckets.add(currentBucket); } else if (name.equals("Name")) { currentBucket.setName(elementText); } else if (name.equals("CreationDate")) { elementText += ".000Z"; try { currentBucket.setCreationDate(ServiceUtils.parseIso8601Date(elementText)); } catch (ParseException e) { throw new RuntimeException( "Non-ISO8601 date for CreationDate in list buckets output: " + elementText, e); } } } }
@Override public String toString() { return "StorageBucket [name=" + getName() + "] Metadata=" + getMetadataMap(); }
/** * 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()); }
if (storageService.getProviderCredentials() == null) { bucket = new StorageBucket(bucketName); } else { bucket = storageService.createBucket(new StorageBucket(bucketName)); } catch (ServiceException e) { bucket = new StorageBucket(bucketName); } catch (ServiceException e2) {
/** * 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()); }
public static void registerMBeans(StorageBucket[] buckets) { if (!isEnabled) { return; } for (int i=0; i<buckets.length; i++) { getInstance(buckets[i].getName()); } }
/** * Sets the bucket's creation date - this should only be used internally by JetS3t * methods that retrieve information directly from a service. * * @param creationDate */ public void setCreationDate(Date creationDate) { addMetadata(METADATA_HEADER_CREATION_DATE, creationDate); }
/** * @return * the bucket's creation date, or null if it is unknown. */ public Date getCreationDate() { return (Date) getMetadata(METADATA_HEADER_CREATION_DATE); }