/** * Sets filter rule to list. * As per Amazon AWS S3 server behavior, its not possible to set more than one rule for "prefix" or "suffix". * However the spec http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html * is not clear about this behavior. */ private void setRule(String name, String value) throws InvalidArgumentException, XmlPullParserException { if (value.length() > 1024) { throw new InvalidArgumentException("value '" + value + "' is more than 1024 long"); } for (FilterRule rule: filterRuleList) { // Remove rule.name is same as given name. if (rule.name().equals(name)) { filterRuleList.remove(rule); } } FilterRule newRule = new FilterRule(); newRule.setName(name); newRule.setValue(value); filterRuleList.add(newRule); }
/** * Sets filter rule to list. * As per Amazon AWS S3 server behavior, its not possible to set more than one rule for "prefix" or "suffix". * However the spec http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html * is not clear about this behavior. */ private void setRule(String name, String value) throws InvalidArgumentException, XmlPullParserException { if (value.length() > 1024) { throw new InvalidArgumentException("value '" + value + "' is more than 1024 long"); } for (FilterRule rule: filterRuleList) { // Remove rule.name is same as given name. if (rule.name().equals(name)) { filterRuleList.remove(rule); } } FilterRule newRule = new FilterRule(); newRule.setName(name); newRule.setValue(value); filterRuleList.add(newRule); }