Search in sources :

Example 6 with BucketNotificationConfiguration

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

the class BucketNotificationConfigurationStaxUnmarshaller method unmarshall.

@Override
public BucketNotificationConfiguration unmarshall(InputStream inputStream) throws Exception {
    final XmlPullParser xpp = xmlPullParserFactory.newPullParser();
    xpp.setInput(inputStream, null);
    final StaxUnmarshallerContext context = new StaxUnmarshallerContext(xpp, null);
    final int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;
    if (context.isStartOfDocument()) {
        targetDepth += 1;
    }
    final BucketNotificationConfiguration config = new BucketNotificationConfiguration();
    while (true) {
        final int xmlEvent = context.nextEvent();
        if (xmlEvent == XmlPullParser.END_DOCUMENT) {
            break;
        } else if (xmlEvent == XmlPullParser.START_TAG) {
            if (context.testExpression("TopicConfiguration", targetDepth)) {
                final Entry<String, NotificationConfiguration> entry = TopicConfigurationStaxUnmarshaller.getInstance().unmarshall(context);
                config.addConfiguration(entry.getKey(), entry.getValue());
            } else if (context.testExpression("QueueConfiguration", targetDepth)) {
                final Entry<String, NotificationConfiguration> entry = QueueConfigurationStaxUnmarshaller.getInstance().unmarshall(context);
                config.addConfiguration(entry.getKey(), entry.getValue());
            } else if (context.testExpression("CloudFunctionConfiguration", targetDepth)) {
                final Entry<String, NotificationConfiguration> entry = LambdaConfigurationStaxUnmarshaller.getInstance().unmarshall(context);
                config.addConfiguration(entry.getKey(), entry.getValue());
            }
        } else if (xmlEvent == XmlPullParser.END_TAG) {
            if (context.getCurrentDepth() < originalDepth) {
                return config;
            }
        }
    }
    return config;
}
Also used : Entry(java.util.Map.Entry) StaxUnmarshallerContext(com.amazonaws.transform.StaxUnmarshallerContext) XmlPullParser(org.xmlpull.v1.XmlPullParser) NotificationConfiguration(com.amazonaws.services.s3.model.NotificationConfiguration) BucketNotificationConfiguration(com.amazonaws.services.s3.model.BucketNotificationConfiguration) BucketNotificationConfiguration(com.amazonaws.services.s3.model.BucketNotificationConfiguration)

Example 7 with BucketNotificationConfiguration

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

the class BucketNotificationConfigurationStaxUnmarshallerTest method unmarshall_ValidQueueConfiguration.

@Test
public void unmarshall_ValidQueueConfiguration() throws Exception {
    final BucketNotificationConfiguration config = unmarshaller.unmarshall(getResource(QUEUE_INPUT));
    final QueueConfiguration queueConfig = (QueueConfiguration) config.getConfigurationByName("QueueConfigId");
    assertEquals("some-queue-arn", queueConfig.getQueueARN());
    assertEventsUnmarshalledCorrectly(queueConfig.getEvents());
    assertFilterRulesUnmarshalledCorrectly(queueConfig.getFilter().getS3KeyFilter().getFilterRules());
}
Also used : QueueConfiguration(com.amazonaws.services.s3.model.QueueConfiguration) BucketNotificationConfiguration(com.amazonaws.services.s3.model.BucketNotificationConfiguration) Test(org.junit.Test)

Aggregations

BucketNotificationConfiguration (com.amazonaws.services.s3.model.BucketNotificationConfiguration)6 Test (org.junit.Test)4 CloudFunctionConfiguration (com.amazonaws.services.s3.model.CloudFunctionConfiguration)2 LambdaConfiguration (com.amazonaws.services.s3.model.LambdaConfiguration)2 NotificationConfiguration (com.amazonaws.services.s3.model.NotificationConfiguration)2 QueueConfiguration (com.amazonaws.services.s3.model.QueueConfiguration)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 SdkClientException (com.amazonaws.SdkClientException)1 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)1 Regions (com.amazonaws.regions.Regions)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 XmlWriter (com.amazonaws.services.s3.internal.XmlWriter)1 TopicConfiguration (com.amazonaws.services.s3.model.BucketNotificationConfiguration.TopicConfiguration)1 TopicConfiguration (com.amazonaws.services.s3.model.TopicConfiguration)1 StaxUnmarshallerContext (com.amazonaws.transform.StaxUnmarshallerContext)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1