public void endRule(String text) { config.addRule(latestRule); } }
Integer expiration = null; String storageClass = null; for(LifecycleConfig.Rule rule : status.getRules()) { if(rule.getTransition() != null) { storageClass = rule.getTransition().getStorageClass();
@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 setConfiguration(final Path file, final LifecycleConfiguration configuration) throws BackgroundException { final Path container = containerService.getContainer(file); try { if(configuration.getTransition() != null || configuration.getExpiration() != null) { final LifecycleConfig config = new LifecycleConfig(); // Unique identifier for the rule. The value cannot be longer than 255 characters. When you specify an empty prefix, the rule applies to all objects in the bucket final LifecycleConfig.Rule rule = config.newRule( String.format("%s-%s", PreferencesFactory.get().getProperty("application.name"), new AlphanumericRandomStringService().random()), StringUtils.EMPTY, true); if(configuration.getTransition() != null) { rule.newTransition().setDays(configuration.getTransition()); } if(configuration.getExpiration() != null) { rule.newExpiration().setDays(configuration.getExpiration()); } session.getClient().setLifecycleConfig(container.getName(), config); } else { session.getClient().deleteLifecycleConfig(container.getName()); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to write attributes of {0}", e, container); } }
for (Rule rule: this.getRules()) { XMLBuilder b = builder.elem("Rule"); if (rule.id != null && rule.id.length() > 0) {
@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); } }
for (Rule rule: this.getRules()) { XMLBuilder b = builder.elem("Rule"); if (rule.id != null && rule.id.length() > 0) {
public void endRule(String text) { config.addRule(latestRule); } }