Example usage for com.amazonaws.services.s3.model BucketLoggingConfiguration getLogFilePrefix

List of usage examples for com.amazonaws.services.s3.model BucketLoggingConfiguration getLogFilePrefix

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model BucketLoggingConfiguration getLogFilePrefix.

Prototype

public String getLogFilePrefix() 

Source Link

Document

Returns the optional log file prefix.

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 {/*  ww w .  ja v  a  2  s  . c  o  m*/
        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;
}