Example usage for com.amazonaws.services.s3 AmazonS3Client getBucketLoggingConfiguration

List of usage examples for com.amazonaws.services.s3 AmazonS3Client getBucketLoggingConfiguration

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3Client getBucketLoggingConfiguration.

Prototype

@Override
    public BucketLoggingConfiguration getBucketLoggingConfiguration(
            GetBucketLoggingConfigurationRequest getBucketLoggingConfigurationRequest)
            throws SdkClientException, AmazonServiceException 

Source Link

Usage

From source file:com.eucalyptus.objectstorage.providers.s3.S3ProviderClient.java

License:Open Source License

@Override
public GetBucketLoggingStatusResponseType getBucketLoggingStatus(GetBucketLoggingStatusType request)
        throws S3Exception {
    GetBucketLoggingStatusResponseType reply = request.getReply();
    User requestUser = getRequestUser(request);
    OsgInternalS3Client internalS3Client = null;

    try {//from ww w .j  a  v a  2s. c om
        internalS3Client = getS3Client(requestUser);
        AmazonS3Client s3Client = internalS3Client.getS3Client();
        BucketLoggingConfiguration loggingConfig = s3Client.getBucketLoggingConfiguration(request.getBucket());
        LoggingEnabled loggingEnabled = new LoggingEnabled();
        if (loggingConfig == null || !loggingConfig.isLoggingEnabled()) {
            //Do nothing, logging is disabled
        } else {
            //S3 SDK does not provide a way to fetch the grants on the destination logging
            loggingEnabled.setTargetBucket(loggingConfig.getDestinationBucketName());
            loggingEnabled.setTargetPrefix(loggingConfig.getLogFilePrefix());
        }
        reply.setLoggingEnabled(loggingEnabled);
    } catch (AmazonServiceException e) {
        LOG.debug("Error from backend", e);
        throw S3ExceptionMapper.fromAWSJavaSDK(e);
    }
    return reply;
}