List of usage examples for com.amazonaws.services.s3.internal Constants S3_HOSTNAME
String S3_HOSTNAME
To view the source code for com.amazonaws.services.s3.internal Constants S3_HOSTNAME.
Click Source Link
From source file:com.emc.vipr.services.s3.ViPRS3Client.java
License:Open Source License
/** * ViPR-specific create bucket command. This version of the command adds some * options specific to EMC ViPR, specifically the ability to set the ViPR project ID * and Object Virtual Pool ID on the new bucket. * @param createBucketRequest the configuration parameters for the new bucket. *///from ww w. j a va 2 s . c o m public Bucket createBucket(ViPRCreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException { assertParameterNotNull(createBucketRequest, "The CreateBucketRequest parameter must be specified when creating a bucket"); String bucketName = createBucketRequest.getBucketName(); String region = createBucketRequest.getRegion(); assertParameterNotNull(bucketName, "The bucket name parameter must be specified when creating a bucket"); if (bucketName != null) bucketName = bucketName.trim(); BucketNameUtils.validateBucketName(bucketName); Request<ViPRCreateBucketRequest> request = createRequest(bucketName, null, createBucketRequest, HttpMethodName.PUT); if (createBucketRequest.getAccessControlList() != null) { addAclHeaders(request, createBucketRequest.getAccessControlList()); } else if (createBucketRequest.getCannedAcl() != null) { request.addHeader(Headers.S3_CANNED_ACL, createBucketRequest.getCannedAcl().toString()); } // ViPR specific: projectId, vpoolId and fsAccessEnabled. if (createBucketRequest.getProjectId() != null) { request.addHeader(ViPRConstants.PROJECT_HEADER, createBucketRequest.getProjectId()); } if (createBucketRequest.getVpoolId() != null) { request.addHeader(ViPRConstants.VPOOL_HEADER, createBucketRequest.getVpoolId()); } if (createBucketRequest.isFsAccessEnabled()) { request.addHeader(ViPRConstants.FS_ACCESS_ENABLED, "true"); } /* * If we're talking to a region-specific endpoint other than the US, we * *must* specify a location constraint. Try to derive the region from * the endpoint. */ if (!(this.endpoint.getHost().equals(Constants.S3_HOSTNAME)) && (region == null || region.isEmpty())) { try { region = RegionUtils.getRegionByEndpoint(this.endpoint.getHost()).getName(); } catch (IllegalArgumentException exception) { // Endpoint does not correspond to a known region; send the // request with no location constraint and hope for the best. } } /* * We can only send the CreateBucketConfiguration if we're *not* * creating a bucket in the US region. */ if (region != null && !region.toUpperCase().equals(Region.US_Standard.toString())) { XmlWriter xml = new XmlWriter(); xml.start("CreateBucketConfiguration", "xmlns", Constants.XML_NAMESPACE); xml.start("LocationConstraint").value(region).end(); xml.end(); request.setContent(new ByteArrayInputStream(xml.getBytes())); } invoke(request, voidResponseHandler, bucketName, null); return new Bucket(bucketName); }
From source file:com.hivemq.plugin.configuration.Configuration.java
License:Apache License
public String getEndpoint() { final String property = getProperty("s3-endpoint"); if (property == null) { return Constants.S3_HOSTNAME; }/*from w w w. ja v a 2 s .c o m*/ return property; }
From source file:com.mesosphere.dcos.cassandra.executor.backup.S3StorageDriver.java
License:Apache License
String getEndpoint(BackupRestoreContext ctx) throws URISyntaxException { URI uri = new URI(ctx.getExternalLocation()); String scheme = uri.getScheme(); if (scheme.equals(AmazonS3Client.S3_SERVICE_NAME)) { return Constants.S3_HOSTNAME; } else {//from w w w .ja v a 2 s . c o m String endpoint = scheme + "://" + uri.getHost(); int port = uri.getPort(); if (port != -1) { endpoint += ":" + Integer.toString(port); } return endpoint; } }