Search in sources :

Example 1 with FilterRule

use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method addEventsAndFilterCriteria.

private void addEventsAndFilterCriteria(XmlWriter xml, NotificationConfiguration config) {
    for (final String event : config.getEvents()) {
        xml.start("Event").value(event).end();
    }
    final Filter filter = config.getFilter();
    if (filter != null) {
        validateFilter(filter);
        xml.start("Filter");
        if (filter.getS3KeyFilter() != null) {
            validateS3KeyFilter(filter.getS3KeyFilter());
            xml.start("S3Key");
            for (final FilterRule filterRule : filter.getS3KeyFilter().getFilterRules()) {
                xml.start("FilterRule");
                xml.start("Name").value(filterRule.getName()).end();
                xml.start("Value").value(filterRule.getValue()).end();
                xml.end();
            }
            xml.end();
        }
        xml.end();
    }
}
Also used : Filter(com.amazonaws.services.s3.model.Filter) AnalyticsFilter(com.amazonaws.services.s3.model.analytics.AnalyticsFilter) LifecycleFilter(com.amazonaws.services.s3.model.lifecycle.LifecycleFilter) InventoryFilter(com.amazonaws.services.s3.model.inventory.InventoryFilter) S3KeyFilter(com.amazonaws.services.s3.model.S3KeyFilter) MetricsFilter(com.amazonaws.services.s3.model.metrics.MetricsFilter) FilterRule(com.amazonaws.services.s3.model.FilterRule)

Example 2 with FilterRule

use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.

the class FilterRuleStaxUnmarshaller method unmarshall.

@Override
public FilterRule unmarshall(StaxUnmarshallerContext context) throws Exception {
    final int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;
    if (context.isStartOfDocument()) {
        targetDepth += 2;
    }
    final FilterRule filter = new FilterRule();
    while (true) {
        final int xmlEvent = context.nextEvent();
        if (xmlEvent == XmlPullParser.END_DOCUMENT) {
            break;
        } else if (xmlEvent == XmlPullParser.START_TAG) {
            if (context.testExpression("Name", targetDepth)) {
                filter.setName(StringStaxUnmarshaller.getInstance().unmarshall(context));
            } else if (context.testExpression("Value", targetDepth)) {
                filter.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context));
            }
        } else if (xmlEvent == XmlPullParser.END_TAG) {
            if (context.getCurrentDepth() < originalDepth) {
                return filter;
            }
        }
    }
    return filter;
}
Also used : FilterRule(com.amazonaws.services.s3.model.FilterRule)

Example 3 with FilterRule

use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.

the class S3KeyFilterStaxUnmarshaller method unmarshall.

@Override
public S3KeyFilter unmarshall(StaxUnmarshallerContext context) throws Exception {
    final int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;
    if (context.isStartOfDocument()) {
        targetDepth += 1;
    }
    final S3KeyFilter filter = new S3KeyFilter();
    while (true) {
        final int xmlEvent = context.nextEvent();
        if (xmlEvent == XmlPullParser.END_DOCUMENT) {
            break;
        } else if (xmlEvent == XmlPullParser.START_TAG) {
            if (context.testExpression("FilterRule", targetDepth)) {
                filter.addFilterRule(FilterRuleStaxUnmarshaller.getInstance().unmarshall(context));
            }
        } else if (xmlEvent == XmlPullParser.END_TAG) {
            if (context.getCurrentDepth() < originalDepth) {
                return filter;
            }
        }
    }
    return filter;
}
Also used : S3KeyFilter(com.amazonaws.services.s3.model.S3KeyFilter)

Example 4 with FilterRule

use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.

the class BucketNotificationConfigurationStaxUnmarshallerTest method assertFilterRulesUnmarshalledCorrectly.

private void assertFilterRulesUnmarshalledCorrectly(List<FilterRule> rules) {
    final FilterRule ruleOne = rules.get(0);
    assertThat(ruleOne.getName(), Matchers.equalTo("Prefix"));
    assertThat(ruleOne.getValue(), Matchers.equalTo("some-prefix"));
    final FilterRule ruleTwo = rules.get(1);
    assertThat(ruleTwo.getName(), Matchers.equalTo("Suffix"));
    assertThat(ruleTwo.getValue(), Matchers.equalTo("some-suffix"));
}
Also used : FilterRule(com.amazonaws.services.s3.model.FilterRule)

Aggregations

FilterRule (com.amazonaws.services.s3.model.FilterRule)3 S3KeyFilter (com.amazonaws.services.s3.model.S3KeyFilter)2 Filter (com.amazonaws.services.s3.model.Filter)1 AnalyticsFilter (com.amazonaws.services.s3.model.analytics.AnalyticsFilter)1 InventoryFilter (com.amazonaws.services.s3.model.inventory.InventoryFilter)1 LifecycleFilter (com.amazonaws.services.s3.model.lifecycle.LifecycleFilter)1 MetricsFilter (com.amazonaws.services.s3.model.metrics.MetricsFilter)1