public void addBucket(final BucketMetaData bucketMetaData) { LOG.debug(String.format("addBucketMetaDataEntity(%s)", bucketMetaData)); PId bucketId = piIdBuilder.getPId(bucketMetaData); // create BucketMetaData blockingDhtCache.update( bucketId, new UpdateResolver<BucketMetaData>() { @Override public BucketMetaData update( BucketMetaData existingEntity, BucketMetaData requestedEntity) { if (existingEntity == null) return bucketMetaData; if (!existingEntity.isDeleted()) { throw new BucketAlreadyExistsException(); } // TODO create a copy constructor in BucketMetaData existingEntity.setCannedAccessPolicy(bucketMetaData.getCannedAclPolicy()); existingEntity.setLocation(bucketMetaData.getLocation()); existingEntity.setUsername(bucketMetaData.getUsername()); existingEntity.resetCreationDate(); existingEntity.setDeleted(false); existingEntity.setName(bucketMetaData.getName()); return existingEntity; } }); }
public void removeBucketFromUser(final String userName, final String bucketName) { LOG.debug(String.format("removeBucketFromUser(%s, %s)", userName, bucketName)); PId userId = piIdBuilder.getPId(User.getUrl(userName)); blockingDhtCache.update( userId, new UpdateResolver<User>() { @Override public User update(User existingEntity, User requestedEntity) { existingEntity.getBucketNames().remove(bucketName); return existingEntity; } }); }
public void deleteBucket(final String bucketName) { LOG.debug(String.format("deleteBucket(%s)", bucketName)); PId id = piIdBuilder.getPId(BucketMetaData.getUrl(bucketName.toLowerCase(Locale.getDefault()))); blockingDhtCache.update( id, new UpdateResolver<BucketMetaData>() { @Override public BucketMetaData update( BucketMetaData existingEntity, BucketMetaData requestedEntity) { existingEntity.setDeleted(true); return existingEntity; } }); }
public void addBucketToUser( final String userName, final String bucketName, final CannedAclPolicy cannedAclPolicy) { LOG.debug(String.format("addBucketToUser(%s, %s, %s)", userName, bucketName, cannedAclPolicy)); // update user record PId userId = piIdBuilder.getPId(User.getUrl(userName)); blockingDhtCache.update( userId, new UpdateResolver<User>() { @Override public User update(User existingEntity, User requestedEntity) { existingEntity.getBucketNames().add(bucketName); return existingEntity; } }); }
public boolean updateCannedAcl(final String bucketName, final CannedAclPolicy cannedAclPolicy) { LOG.debug(String.format("updateCannedAcl(%s, %s)", bucketName, cannedAclPolicy)); PId bucketId = piIdBuilder.getPId(BucketMetaData.getUrl(bucketName.toLowerCase(Locale.getDefault()))); blockingDhtCache.update( bucketId, new UpdateResolver<BucketMetaData>() { @Override public BucketMetaData update( BucketMetaData existingEntity, BucketMetaData requestedEntity) { existingEntity.setCannedAccessPolicy(cannedAclPolicy); return existingEntity; } }); return true; }