Example usage for com.amazonaws.services.s3.model Owner getDisplayName

List of usage examples for com.amazonaws.services.s3.model Owner getDisplayName

Introduction

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

Prototype

public String getDisplayName() 

Source Link

Document

Gets the display name of the owner.

Usage

From source file:com.cirrus.server.osgi.service.amazon.s3.AmazonS3StorageService.java

License:Apache License

@Override
public String getAccountName() throws ServiceRequestFailedException {
    final Owner s3AccountOwner = this.amazonS3Client.getS3AccountOwner();
    return s3AccountOwner.getDisplayName();
}

From source file:eu.stratosphere.nephele.fs.s3.S3FileSystem.java

License:Apache License

private void initializeDirectoryStructure(final URI name) throws IOException {

    String basePath = name.getPath();
    while (true) {

        try {//from  w  ww  .  j av  a  2 s. c  o  m
            final String endpoint = new URL(HTTP_PREFIX, this.host, this.port, basePath).toString();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Trying S3 endpoint " + endpoint);
            }

            this.s3Client.setEndpoint(endpoint);
            final Owner owner = this.s3Client.getS3AccountOwner();
            LOG.info("Successfully established connection to Amazon S3 using the endpoint " + endpoint);
            LOG.info("Amazon S3 user is " + owner.getDisplayName());

            break;
        } catch (MalformedURLException e) {
            throw new IOException(StringUtils.stringifyException(e));
        } catch (AmazonClientException e) {

            // Truncate path
            if (basePath.isEmpty()) {
                throw new IOException(
                        "Cannot establish connection to Amazon S3: " + StringUtils.stringifyException(e));
            } else {
                final int pos = basePath.lastIndexOf(Path.SEPARATOR);
                if (pos < 0) {
                    basePath = "";
                } else {
                    basePath = basePath.substring(0, pos);
                }
            }
        }
    }

    // Set the S3 URI
    try {
        this.s3Uri = new URI(S3_SCHEME, (String) null, this.host, this.port, basePath, null, null);
    } catch (URISyntaxException e) {
        throw new IOException(StringUtils.stringifyException(e));
    }

    // Finally, create directory structure object
    this.directoryStructure = new S3DirectoryStructure(basePath);
}