use of com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method writeRule.
private void writeRule(XmlWriter xml, RoutingRule rule) {
xml.start("RoutingRule");
final RoutingRuleCondition condition = rule.getCondition();
if (condition != null) {
xml.start("Condition");
xml.start("KeyPrefixEquals");
if (condition.getKeyPrefixEquals() != null) {
xml.value(condition.getKeyPrefixEquals());
}
// </KeyPrefixEquals">
xml.end();
if (condition.getHttpErrorCodeReturnedEquals() != null) {
xml.start("HttpErrorCodeReturnedEquals ").value(condition.getHttpErrorCodeReturnedEquals()).end();
}
// </Condition>
xml.end();
}
xml.start("Redirect");
final RedirectRule redirect = rule.getRedirect();
if (redirect != null) {
if (redirect.getprotocol() != null) {
xml.start("Protocol").value(redirect.getprotocol()).end();
}
if (redirect.getHostName() != null) {
xml.start("HostName").value(redirect.getHostName()).end();
}
if (redirect.getReplaceKeyPrefixWith() != null) {
xml.start("ReplaceKeyPrefixWith").value(redirect.getReplaceKeyPrefixWith()).end();
}
if (redirect.getReplaceKeyWith() != null) {
xml.start("ReplaceKeyWith").value(redirect.getReplaceKeyWith()).end();
}
if (redirect.getHttpRedirectCode() != null) {
xml.start("HttpRedirectCode").value(redirect.getHttpRedirectCode()).end();
}
}
// </Redirect>
xml.end();
// </CORSRule>
xml.end();
}
use of com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
public byte[] convertToXmlByteArray(BucketReplicationConfiguration replicationConfiguration) {
final XmlWriter xml = new XmlWriter();
xml.start("ReplicationConfiguration");
final Map<String, ReplicationRule> rules = replicationConfiguration.getRules();
final String role = replicationConfiguration.getRoleARN();
xml.start("Role").value(role).end();
for (final Map.Entry<String, ReplicationRule> entry : rules.entrySet()) {
final String ruleId = entry.getKey();
final ReplicationRule rule = entry.getValue();
xml.start("Rule");
xml.start("ID").value(ruleId).end();
xml.start("Prefix").value(rule.getPrefix()).end();
xml.start("Status").value(rule.getStatus()).end();
final ReplicationDestinationConfig config = rule.getDestinationConfig();
xml.start("Destination");
xml.start("Bucket").value(config.getBucketARN()).end();
if (config.getStorageClass() != null) {
xml.start("StorageClass").value(config.getStorageClass()).end();
}
xml.end();
xml.end();
}
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule in project aws-sdk-android by aws-amplify.
the class ExpirationHeaderParsingTest method testParseExpirationHeader1.
@Test
public void testParseExpirationHeader1() {
MockObjectExpirationResult result = new MockObjectExpirationResult();
ObjectExpirationHeaderHandler<MockObjectExpirationResult> handler = new ObjectExpirationHeaderHandler<MockObjectExpirationResult>();
HttpResponse response = HttpResponse.builder().header("x-amz-expiration", "expiry-date=\"Tue, 01 Jan 2013 00:00:00 GMT\", rule-id=\"Test\"").build();
handler.handle(result, response);
Assert.assertEquals(1356998400000L, result.getExpirationTime().getTime());
Assert.assertEquals("Test", result.getExpirationTimeRuleId());
}
use of com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule in project aws-sdk-android by aws-amplify.
the class AbstractS3ResponseHandlerTest method testPopulateObjectMetadata.
@Test
public void testPopulateObjectMetadata() {
HttpResponse response = new HttpResponse.Builder().header(Headers.REQUEST_ID, "testId").header(Headers.EXTENDED_REQUEST_ID, "extendedId").header(Headers.S3_USER_METADATA_PREFIX + "userKey", "userValue").header(Headers.LAST_MODIFIED, "Sun, 1 Jan 2006 12:00:00 GMT").header(Headers.CONTENT_LENGTH, "5").header(Headers.ETAG, "Etag").header(Headers.EXPIRES, "Sun, 1 Jan 2006 12:00:00 GMT").header(Headers.EXPIRATION, "expiry-date=\"Fri, 21 Dec 2012 00:00:00 GMT\", rule-id=\"Rule for testfile.txt\"").header(Headers.RESTORE, "ongoing-request=\"false\", expiry-date=\"Wed, 07 Nov 2012 00:00:00 GMT\"").header("UndefinedKey", "UndefinedValue").header(Headers.STORAGE_CLASS, "STANDARD_IA").build();
ObjectMetadata om = new ObjectMetadata();
TClass handler = new TClass();
handler.populateObjectMetadata(response, om);
assertNull(om.getRawMetadataValue(Headers.REQUEST_ID));
assertNull(om.getRawMetadataValue(Headers.EXTENDED_REQUEST_ID));
assertEquals(om.getUserMetaDataOf("userKey"), "userValue");
assertEquals(1136116800000L, om.getLastModified().getTime());
assertEquals(om.getContentLength(), 5);
assertEquals(om.getETag(), "Etag");
assertEquals(1356048000000L, om.getExpirationTime().getTime());
assertEquals(1136116800000L, om.getHttpExpiresDate().getTime());
assertEquals("Rule for testfile.txt", om.getExpirationTimeRuleId());
assertEquals(1352246400000L, om.getRestoreExpirationTime().getTime());
assertFalse(om.getOngoingRestore());
assertEquals(om.getStorageClass(), StorageClass.StandardInfrequentAccess.toString());
}
use of com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule in project aws-sdk-android by aws-amplify.
the class BucketLifecycleSaxUnmarshallerTest method unmarshalls_filter_with_emptyPrefix.
@Test
public void unmarshalls_filter_with_emptyPrefix() throws Exception {
Rule rule = getRule(parseLifecycleConfiguration(UNKNOWN_STORAGE_CLASS_RESPONSE), 2);
LifecyclePrefixPredicate predicate = (LifecyclePrefixPredicate) rule.getFilter().getPredicate();
assertEquals("", predicate.getPrefix());
}
Aggregations