@Override public void setLifecycleConfigImpl(String bucketName, LifecycleConfig config) throws S3ServiceException { Map<String, String> requestParameters = new HashMap<String, String>(); requestParameters.put("lifecycle", ""); String xml; String xmlMd5Hash; try { xml = config.toXml(); xmlMd5Hash = ServiceUtils.toBase64( ServiceUtils.computeMD5Hash(xml.getBytes(Constants.DEFAULT_ENCODING))); } catch (Exception e) { throw new S3ServiceException("Unable to build LifecycleConfig XML document", e); } Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("Content-MD5", xmlMd5Hash); try { performRestPut(bucketName, null, metadata, requestParameters, new StringEntity(xml, "text/plain", Constants.DEFAULT_ENCODING), true); } catch (ServiceException se) { throw new S3ServiceException(se); } catch (UnsupportedEncodingException e) { throw new S3ServiceException("Unable to encode XML document", e); } }
@Override public void setLifecycleConfigImpl(String bucketName, LifecycleConfig config) throws S3ServiceException { Map<String, String> requestParameters = new HashMap<String, String>(); requestParameters.put("lifecycle", ""); String xml; String xmlMd5Hash; try { xml = config.toXml(); xmlMd5Hash = ServiceUtils.toBase64( ServiceUtils.computeMD5Hash(xml.getBytes(Constants.DEFAULT_ENCODING))); } catch (Exception e) { throw new S3ServiceException("Unable to build LifecycleConfig XML document", e); } Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("Content-MD5", xmlMd5Hash); try { performRestPut(bucketName, null, metadata, requestParameters, new StringEntity(xml, "text/plain", Constants.DEFAULT_ENCODING), true); } catch (ServiceException se) { throw new S3ServiceException(se); } catch (UnsupportedEncodingException e) { throw new S3ServiceException("Unable to encode XML document", e); } }