Java 类com.amazonaws.services.s3.model.BucketWebsiteConfiguration 实例源码

项目:aws-doc-sdk-examples    文件:GetWebsiteConfiguration.java   
public static void getWebsiteConfig(String bucket_name)
{
    final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
    try {
        BucketWebsiteConfiguration config =
            s3.getBucketWebsiteConfiguration(bucket_name);
        if (config == null) {
            System.out.println("No website configuration found!");
        } else {
            System.out.format("Index document: %s\n",
                config.getIndexDocumentSuffix());
            System.out.format("Error document: %s\n",
                config.getErrorDocument());
        }
    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.out.println("Failed to get website configuration!");
        System.exit(1);
    }
}
项目:cloudExplorer    文件:Acl.java   
void setBUCKETwebsite(String object, String access_key, String secret_key, String endpoint, String bucket) {
    try {
        AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key);
        AmazonS3 s3Client = new AmazonS3Client(credentials,
                new ClientConfiguration());
        if (endpoint.contains("amazonaws.com")) {
            String aws_endpoint = s3Client.getBucketLocation(new GetBucketLocationRequest(bucket));
            if (aws_endpoint.contains("US")) {
                s3Client.setEndpoint("https://s3.amazonaws.com");
            } else if (aws_endpoint.contains("us-west")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else if (aws_endpoint.contains("eu-west")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else if (aws_endpoint.contains("ap-")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else if (aws_endpoint.contains("sa-east-1")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else {
                s3Client.setEndpoint("https://s3." + aws_endpoint + ".amazonaws.com");
            }
        } else {
            s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
            s3Client.setEndpoint(endpoint);
        }
        BucketWebsiteConfiguration bucketWebsiteConfiguration = s3Client.getBucketWebsiteConfiguration(bucket);
        s3Client.setBucketAcl(bucket, CannedAccessControlList.PublicRead);
        s3Client.setBucketWebsiteConfiguration(bucket, new BucketWebsiteConfiguration("index.html", "error.html"));
    } catch (Exception setACLpublic) {
        mainFrame.jTextArea1.append("\nException occurred in ACL");
    }
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(
    GetBucketWebsiteConfigurationRequest getBucketWebsiteConfigurationRequest) throws AmazonClientException,
    AmazonServiceException {
  // TODO Auto-generated method stub
  return null;
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(String bucketName) throws AmazonClientException, AmazonServiceException {
    return delegate.getBucketWebsiteConfiguration(bucketName);
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(GetBucketWebsiteConfigurationRequest getBucketWebsiteConfigurationRequest) throws AmazonClientException, AmazonServiceException {
    return delegate.getBucketWebsiteConfiguration(getBucketWebsiteConfigurationRequest);
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public void setBucketWebsiteConfiguration(String bucketName, BucketWebsiteConfiguration configuration) throws AmazonClientException, AmazonServiceException {
    delegate.setBucketWebsiteConfiguration(bucketName, configuration);
}
项目:ibm-cos-sdk-java    文件:BucketConfigurationXmlFactory.java   
/**
 * Converts the specified website configuration into an XML byte array to
 * send to S3.
 *
 * Sample XML:
 * <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
 *    <IndexDocument>
 *      <Suffix>index.html</Suffix>
 *    </IndexDocument>
 *    <ErrorDocument>
 *      <Key>404.html</Key>
 *    </ErrorDocument>
 *  </WebsiteConfiguration>
 *
 * @param websiteConfiguration
 *            The configuration to convert.
 * @return The XML byte array representation.
 */
public byte[] convertToXmlByteArray(BucketWebsiteConfiguration websiteConfiguration) {
    XmlWriter xml = new XmlWriter();
    xml.start("WebsiteConfiguration", "xmlns", Constants.XML_NAMESPACE);

    if (websiteConfiguration.getIndexDocumentSuffix() != null) {
        XmlWriter indexDocumentElement = xml.start("IndexDocument");
        indexDocumentElement.start("Suffix").value(websiteConfiguration.getIndexDocumentSuffix()).end();
        indexDocumentElement.end();
    }

    if (websiteConfiguration.getErrorDocument() != null) {
        XmlWriter errorDocumentElement = xml.start("ErrorDocument");
        errorDocumentElement.start("Key").value(websiteConfiguration.getErrorDocument()).end();
        errorDocumentElement.end();
    }

    RedirectRule redirectAllRequestsTo = websiteConfiguration.getRedirectAllRequestsTo();
    if (redirectAllRequestsTo != null) {
        XmlWriter redirectAllRequestsElement = xml.start("RedirectAllRequestsTo");
        if (redirectAllRequestsTo.getprotocol() != null) {
            xml.start("Protocol").value(redirectAllRequestsTo.getprotocol()).end();
        }

        if (redirectAllRequestsTo.getHostName() != null) {
            xml.start("HostName").value(redirectAllRequestsTo.getHostName()).end();
        }

        if (redirectAllRequestsTo.getReplaceKeyPrefixWith() != null) {
            xml.start("ReplaceKeyPrefixWith").value(redirectAllRequestsTo.getReplaceKeyPrefixWith()).end();
        }

        if (redirectAllRequestsTo.getReplaceKeyWith() != null) {
            xml.start("ReplaceKeyWith").value(redirectAllRequestsTo.getReplaceKeyWith()).end();
        }
        redirectAllRequestsElement.end();
    }

    if (websiteConfiguration.getRoutingRules() != null && websiteConfiguration.getRoutingRules().size() > 0) {

        XmlWriter routingRules = xml.start("RoutingRules");
        for (RoutingRule rule : websiteConfiguration.getRoutingRules()) {
            writeRule(routingRules, rule);
        }

        routingRules.end();
    }

    xml.end();
    return xml.getBytes();
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(String bucketName) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().getBucketWebsiteConfiguration(bucketName));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(GetBucketWebsiteConfigurationRequest getBucketWebsiteConfigurationRequest) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().getBucketWebsiteConfiguration(getBucketWebsiteConfigurationRequest));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public void setBucketWebsiteConfiguration(String bucketName, BucketWebsiteConfiguration configuration) throws SdkClientException, AmazonServiceException {
  run(() -> getDelegate().setBucketWebsiteConfiguration(bucketName, configuration));
}
项目:java-translatebot    文件:WebsiteDeployer.java   
public void deploy() {

        /*
         * check for existence because once created, we aren't going to delete
         * it. Amazon could give the name to someone else. This won't matter
         * when we move CDN.
         */
        final Optional<Bucket> maybeBucket = this.s3.listBuckets()
                .stream()
                .filter(b -> b.getName().equals(BucketName))
                .findAny();
        if (!maybeBucket.isPresent()) {
            this.s3.createBucket(new CreateBucketRequest(BucketName));
        }

        this.s3.setBucketWebsiteConfiguration(BucketName, new BucketWebsiteConfiguration("index.html"));

        /*
         * Zone must exist
         */
        final HostedZone zone = this.route53.listHostedZonesByName(new ListHostedZonesByNameRequest().withDNSName(Tld))
                .getHostedZones()
                .stream()
                .findAny()
                .get();

        final String zoneId = zone.getId().replaceAll("/.*/", "");
        final ResourceRecord record = new ResourceRecord().withValue(Domain + ".s3.amazonaws.com");
        final ResourceRecordSet records = new ResourceRecordSet().withName(Domain + ".")
                .withType(RRType.CNAME)
                .withTTL(60L)
                .withResourceRecords(record);
        final Change change = new Change().withAction(ChangeAction.UPSERT).withResourceRecordSet(records);
        final List<Change> changes = Collections.singletonList(change);

        final ChangeBatch changeBatch = new ChangeBatch().withChanges(changes);
        final ChangeResourceRecordSetsRequest changeRecordsRequest = new ChangeResourceRecordSetsRequest()
                .withHostedZoneId(zoneId).withChangeBatch(changeBatch);
        this.route53.changeResourceRecordSets(changeRecordsRequest);

        upload(SignupObjectName);
        upload(ThankYouObjectName);

    }
项目:presto    文件:MockAmazonS3.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(String bucketName)
        throws AmazonClientException
{
    return null;
}
项目:presto    文件:MockAmazonS3.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(GetBucketWebsiteConfigurationRequest getBucketWebsiteConfigurationRequest)
        throws AmazonClientException
{
    return null;
}
项目:presto    文件:MockAmazonS3.java   
@Override
public void setBucketWebsiteConfiguration(String bucketName, BucketWebsiteConfiguration configuration)
        throws AmazonClientException
{
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public BucketWebsiteConfiguration getBucketWebsiteConfiguration(String bucketName) throws AmazonClientException,
    AmazonServiceException {
  // TODO Auto-generated method stub
  return null;
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public void setBucketWebsiteConfiguration(String bucketName, BucketWebsiteConfiguration configuration)
    throws AmazonClientException, AmazonServiceException {
  // TODO Auto-generated method stub

}