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

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

Introduction

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

Prototype

@Override
    public void setBucketLoggingConfiguration(
            SetBucketLoggingConfigurationRequest setBucketLoggingConfigurationRequest)
            throws SdkClientException, AmazonServiceException 

Source Link

Usage

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

License:Open Source License

@Override
public SetBucketLoggingStatusResponseType setBucketLoggingStatus(SetBucketLoggingStatusType request)
        throws S3Exception {
    SetBucketLoggingStatusResponseType reply = request.getReply();
    User requestUser = getRequestUser(request);
    OsgInternalS3Client internalS3Client = null;

    try {/*from w w  w . j  a v  a2 s  .c  om*/
        internalS3Client = getS3Client(requestUser);
        AmazonS3Client s3Client = internalS3Client.getS3Client();
        BucketLoggingConfiguration config = new BucketLoggingConfiguration();
        LoggingEnabled requestConfig = request.getLoggingEnabled();
        config.setDestinationBucketName(requestConfig == null ? null : requestConfig.getTargetBucket());
        config.setLogFilePrefix(requestConfig == null ? null : requestConfig.getTargetPrefix());

        SetBucketLoggingConfigurationRequest loggingRequest = new SetBucketLoggingConfigurationRequest(
                request.getBucket(), config);
        s3Client.setBucketLoggingConfiguration(loggingRequest);
        reply.setStatus(HttpResponseStatus.OK);
        reply.setStatusMessage("OK");
    } catch (AmazonServiceException e) {
        LOG.debug("Error from backend", e);
        throw S3ExceptionMapper.fromAWSJavaSDK(e);
    }
    return reply;
}