Example usage for com.amazonaws.services.s3.model CORSRule setAllowedMethods

List of usage examples for com.amazonaws.services.s3.model CORSRule setAllowedMethods

Introduction

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

Prototype

public void setAllowedMethods(AllowedMethods... allowedMethods) 

Source Link

Document

Convenience array style method for #setAllowedMethods(List)

Usage

From source file:com.eucalyptus.cloudformation.resources.standard.actions.AWSS3BucketResourceAction.java

License:Open Source License

private BucketCrossOriginConfiguration convertCrossOriginConfiguration(S3CorsConfiguration corsConfiguration) {
    BucketCrossOriginConfiguration bucketCrossOriginConfiguration = new BucketCrossOriginConfiguration();
    if (corsConfiguration.getCorsRule() != null) {
        List<CORSRule> rules = Lists.newArrayList();
        for (S3CorsConfigurationRule s3CorsConfigurationRule : corsConfiguration.getCorsRule()) {
            CORSRule rule = new CORSRule();
            rule.setAllowedHeaders(s3CorsConfigurationRule.getAllowedHeaders());
            if (s3CorsConfigurationRule.getAllowedMethods() != null) {
                List<CORSRule.AllowedMethods> allowedMethods = Lists.newArrayList();
                for (String allowedMethodStr : s3CorsConfigurationRule.getAllowedMethods()) {
                    allowedMethods.add(CORSRule.AllowedMethods.valueOf(allowedMethodStr));
                }/*from  w w  w.  j  a  va  2 s.  co  m*/
                rule.setAllowedMethods(allowedMethods);
            }
            rule.setAllowedOrigins(s3CorsConfigurationRule.getAllowedOrigins());
            rule.setExposedHeaders(s3CorsConfigurationRule.getExposedHeaders());
            rule.setId(s3CorsConfigurationRule.getId());
            rule.setMaxAgeSeconds(s3CorsConfigurationRule.getMaxAge());
            rules.add(rule);
        }
        bucketCrossOriginConfiguration.setRules(rules);
    }
    return bucketCrossOriginConfiguration;
}