/** * This implementation invokes {@link S3Client#deleteBucketIfEmpty} followed by * {@link S3Client#bucketExists} until it is true. */ public static boolean deleteAndVerifyContainerGone(S3Client sync, String container) { sync.deleteBucketIfEmpty(container); return sync.bucketExists(container); } }
/** * This implementation invokes {@link S3Client#deleteObject} * * @param container * bucket name * @param key * object key */ @Override public void removeBlob(String container, String key) { sync.deleteObject(container, key); }
/** * This implementation invokes {@link S3Client#objectExists} * * @param container * bucket name * @param key * object key */ @Override public boolean blobExists(String container, String key) { return sync.objectExists(container, key); }
/** * This implementation invokes {@link S3Client#bucketExists} * * @param container * bucket name */ @Override public boolean containerExists(String container) { return sync.bucketExists(container); }
/** * This implementation invokes {@link S3Client#headObject} * * @param container * bucket name * @param key * object key */ @Override public BlobMetadata blobMetadata(String container, String key) { return object2BlobMd.apply(sync.headObject(container, key)); }
/** * This implementation invokes {@link S3Client#listOwnedBuckets} */ @Override public PageSet<? extends StorageMetadata> list() { return new Function<Set<BucketMetadata>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() { public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(Set<BucketMetadata> from) { return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucket2ResourceMd), null); } }.apply(sync.listOwnedBuckets()); }
/** * This implementation invokes {@link S3Client#putBucketInRegion} * * @param location * corresponds to {@link Region#fromValue} * @param container * bucket name */ @Override public boolean createContainerInLocation(Location location, String container) { location = location != null ? location : defaultLocation.get(); return sync.putBucketInRegion(location.getId(), container); }
/** * This implementation invokes {@link S3Client#getObject} * * @param container * bucket name * @param key * object key */ @Override public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions optionsList) { GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList); return object2Blob.apply(sync.getObject(container, key, httpOptions)); }
/** * This implementation invokes {@link S3Client#listBucket} * * @param container * bucket name */ @Override public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) { ListBucketOptions httpOptions = container2BucketListOptions.apply(options); PageSet<? extends StorageMetadata> list = bucket2ResourceList.apply(sync.listBucket(container, httpOptions)); return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list; }
private Location getLocation(BucketMetadata from) { try { Set<? extends Location> locations = this.locations.get(); final String region = client.getBucketLocation(from.getName()); assert region != null : String.format("could not get region for %s", from.getName()); if (region != null) { try { return Iterables.find(locations, new Predicate<Location>() { @Override public boolean apply(Location input) { return input.getId().equalsIgnoreCase(region.toString()); } }); } catch (NoSuchElementException e) { logger.error("could not get location for region %s in %s", region, locations); } } else { logger.error("could not get region for %s", from.getName()); } } catch (ContainerNotFoundException e) { logger.error(e, "could not get region for %s, as service suggests the bucket doesn't exist", from.getName()); } return null; } }