@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest) { getBucketCrossOriginConfigurationRequest = beforeClientExecution(getBucketCrossOriginConfigurationRequest); rejectNull(getBucketCrossOriginConfigurationRequest, "The request object parameter getBucketCrossOriginConfigurationRequest must be specified."); String bucketName = getBucketCrossOriginConfigurationRequest.getBucketName(); rejectNull(bucketName, "The bucket name must be specified when retrieving the bucket cross origin configuration."); Request<GetBucketCrossOriginConfigurationRequest> request = createRequest(bucketName, null, getBucketCrossOriginConfigurationRequest, HttpMethodName.GET); request.addParameter("cors", null); try { return invoke(request, new Unmarshallers.BucketCrossOriginConfigurationUnmarshaller(), bucketName, null); } catch (AmazonServiceException ase) { switch (ase.getStatusCode()) { case 404: return null; default: throw ase; } } }
/** * Converts the specified {@link BucketCrossOriginConfiguration} object to an XML fragment that * can be sent to Amazon S3. * * @param config * The {@link BucketCrossOriginConfiguration} */ /* * <CORSConfiguration> <CORSRule> <AllowedOrigin>http://www.foobar.com</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSec> <ExposeHeader>x-amz-server-side-encryption</ExposeHeader> </CORSRule> </CORSConfiguration> */ public byte[] convertToXmlByteArray(BucketCrossOriginConfiguration config) throws SdkClientException { XmlWriter xml = new XmlWriter(); xml.start("CORSConfiguration", "xmlns", Constants.XML_NAMESPACE); for (CORSRule rule : config.getRules()) { writeRule(xml, rule); } xml.end(); return xml.getBytes(); }
@Override public void setBucketCrossOriginConfiguration( SetBucketCrossOriginConfigurationRequest setBucketCrossOriginConfigurationRequest) { setBucketCrossOriginConfigurationRequest = beforeClientExecution(setBucketCrossOriginConfigurationRequest); rejectNull(setBucketCrossOriginConfigurationRequest, "The set bucket cross origin configuration request object must be specified."); String bucketName = setBucketCrossOriginConfigurationRequest.getBucketName(); BucketCrossOriginConfiguration bucketCrossOriginConfiguration = setBucketCrossOriginConfigurationRequest.getCrossOriginConfiguration(); rejectNull(bucketName, "The bucket name parameter must be specified when setting bucket cross origin configuration."); rejectNull(bucketCrossOriginConfiguration, "The cross origin configuration parameter must be specified when setting bucket cross origin configuration."); Request<SetBucketCrossOriginConfigurationRequest> request = createRequest(bucketName, null, setBucketCrossOriginConfigurationRequest, HttpMethodName.PUT); request.addParameter("cors", null); byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketCrossOriginConfiguration); request.addHeader("Content-Length", String.valueOf(content.length)); request.addHeader("Content-Type", "application/xml"); request.setContent(new ByteArrayInputStream(content)); try { byte[] md5 = Md5Utils.computeMD5Hash(content); String md5Base64 = BinaryUtils.toBase64(md5); request.addHeader("Content-MD5", md5Base64); } catch ( Exception e ) { throw new SdkClientException("Couldn't compute md5 sum", e); } invoke(request, voidResponseHandler, bucketName, null); }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(String bucketName) { return delegate.getBucketCrossOriginConfiguration(bucketName); }
@Override public void setBucketCrossOriginConfiguration(String bucketName, BucketCrossOriginConfiguration bucketCrossOriginConfiguration) { delegate.setBucketCrossOriginConfiguration(bucketName, bucketCrossOriginConfiguration); }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest) { return delegate.getBucketCrossOriginConfiguration(getBucketCrossOriginConfigurationRequest); }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(String bucketName) { return getBucketCrossOriginConfiguration(new GetBucketCrossOriginConfigurationRequest(bucketName)); }
@Override public void setBucketCrossOriginConfiguration(String bucketName, BucketCrossOriginConfiguration bucketCrossOriginConfiguration) { setBucketCrossOriginConfiguration(new SetBucketCrossOriginConfigurationRequest(bucketName, bucketCrossOriginConfiguration)); }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(String bucketName) { return call(() -> getDelegate().getBucketCrossOriginConfiguration(bucketName)); }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest) { return call(() -> getDelegate().getBucketCrossOriginConfiguration(getBucketCrossOriginConfigurationRequest)); }
@Override public void setBucketCrossOriginConfiguration(String bucketName, BucketCrossOriginConfiguration bucketCrossOriginConfiguration) { run(() -> getDelegate().setBucketCrossOriginConfiguration(bucketName, bucketCrossOriginConfiguration)); }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(String bucketName) { return null; }
@Override public void setBucketCrossOriginConfiguration(String bucketName, BucketCrossOriginConfiguration bucketCrossOriginConfiguration) { }
@Override public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(String bucketName) { // TODO Auto-generated method stub return null; }
@Override public void setBucketCrossOriginConfiguration(String bucketName, BucketCrossOriginConfiguration bucketCrossOriginConfiguration) { // TODO Auto-generated method stub }