List of usage examples for com.amazonaws.services.s3 AmazonS3Client getBucketLocation
@Override public String getBucketLocation(String bucketName) throws SdkClientException, AmazonServiceException
From source file:com.eucalyptus.objectstorage.providers.s3.S3ProviderClient.java
License:Open Source License
@Override public GetBucketLocationResponseType getBucketLocation(GetBucketLocationType request) throws S3Exception { GetBucketLocationResponseType reply = request.getReply(); User requestUser = getRequestUser(request); OsgInternalS3Client internalS3Client = null; try {/*w w w .j av a 2 s . c o m*/ internalS3Client = getS3Client(requestUser); AmazonS3Client s3Client = internalS3Client.getS3Client(); String bucketLocation = s3Client.getBucketLocation(request.getBucket()); reply.setLocationConstraint(bucketLocation); } catch (AmazonServiceException e) { LOG.debug("Error from backend", e); throw S3ExceptionMapper.fromAWSJavaSDK(e); } return reply; }
From source file:org.openflamingo.fs.s3.S3Utils.java
License:Apache License
/** * Bucket ./*w w w .ja v a 2 s . c om*/ * * @param client Amazon S3 Client * @param bucketName Bucket Name */ public static Map<String, String> getBucketInfo(AmazonS3Client client, String bucketName) { Bucket bucket = getBucket(client, bucketName); if (bucket == null) { return null; } ObjectMetadata objectMetadata = client.getObjectMetadata(bucketName, ""); Map<String, String> map = new HashMap<String, String>(); map.put("name", bucket.getName()); map.put("ownerName", bucket.getOwner().getDisplayName()); map.put("ownerId", bucket.getOwner().getId()); setValue("create", bucket.getCreationDate(), map); setValue("location", client.getBucketLocation(bucketName), map); setValue("version", objectMetadata.getVersionId(), map); setValue("contentDisposition", objectMetadata.getContentDisposition(), map); setValue("contentType", objectMetadata.getContentType(), map); setValue("etag", objectMetadata.getETag(), map); setValue("contentEncoding", objectMetadata.getContentEncoding(), map); setValue("contentLength", objectMetadata.getContentLength(), map); setValue("lastModified", objectMetadata.getLastModified(), map); return map; }
From source file:temp.zAmazonServiceProvider.java
License:BSD License
@Override public void checkAvailable() { try {// w w w .j av a2 s. c om final AmazonS3Client client = amazonConfig.client(); final String bucket = amazonConfig.bucket(); final GetBucketLocationRequest request = // new GetBucketLocationRequest(bucket); final String result = client.getBucketLocation(request); if (!setAvailable(true)) { log.info("amazon service available"); } } catch (final Exception e) { if (setAvailable(false)) { log.error("amazon service unavailable"); } } }