Search in sources :

Example 16 with XmlWriter

use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.

the class RequestXmlFactory method convertToXmlByteArray.

/**
 * Converts the RestoreObjectRequest to an XML fragment that can be sent to
 * the RestoreObject operation of Amazon S3.
 *
 * @param restoreObjectRequest The container which provides options for
 *            restoring an object, which was transitioned to the Glacier
 *            from S3 when it was expired, into S3 again.
 * @return A byte array containing the data
 * @throws AmazonClientException
 */
public static byte[] convertToXmlByteArray(RestoreObjectRequest restoreObjectRequest) throws AmazonClientException {
    XmlWriter xml = new XmlWriter();
    xml.start("RestoreRequest");
    xml.start("Days").value(Integer.toString(restoreObjectRequest.getExpirationInDays())).end();
    xml.end();
    return xml.getBytes();
}
Also used : XmlWriter(com.amazonaws.services.s3.internal.XmlWriter)

Example 17 with XmlWriter

use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method writeAnalyticsExportDestination.

private void writeAnalyticsExportDestination(XmlWriter xml, AnalyticsExportDestination destination) {
    if (destination == null) {
        return;
    }
    xml.start("Destination");
    if (destination.getS3BucketDestination() != null) {
        xml.start("S3BucketDestination");
        final AnalyticsS3BucketDestination s3BucketDestination = destination.getS3BucketDestination();
        addParameterIfNotNull(xml, "Format", s3BucketDestination.getFormat());
        addParameterIfNotNull(xml, "BucketAccountId", s3BucketDestination.getBucketAccountId());
        addParameterIfNotNull(xml, "Bucket", s3BucketDestination.getBucketArn());
        addParameterIfNotNull(xml, "Prefix", s3BucketDestination.getPrefix());
        // </S3BucketDestination>
        xml.end();
    }
    // </Destination>
    xml.end();
}
Also used : AnalyticsS3BucketDestination(com.amazonaws.services.s3.model.analytics.AnalyticsS3BucketDestination)

Example 18 with XmlWriter

use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method convertToXmlByteArray.

/**
 * Converts the specified {@link InventoryConfiguration} object to an XML
 * fragment that can be sent to Amazon S3.
 *
 * @param config The {@link InventoryConfiguration}
 */
/*
     * <?xml version="1.0" encoding="UTF-8"?> <InventoryConfiguration
     * xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Destination>
     * <S3BucketDestination> <AccountId>A2OCNCIEQW9MSG</AccountId>
     * <Bucket>s3-object-inventory-list-gamma-us-east-1</Bucket>
     * <Format>CSV</Format> <Prefix>string</Prefix> </S3BucketDestination>
     * </Destination> <IsEnabled>true</IsEnabled> <Filter>
     * <Prefix>string</Prefix> </Filter> <Id>configId</Id>
     * <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields>
     * <Field>Size</Field> <Field>LastModifiedDate</Field>
     * <Field>StorageClass</Field> <Field>ETag</Field>
     * <Field>IsMultipartUploaded</Field> <Field>ReplicationStatus</Field>
     * </OptionalFields> <Schedule> <Frequency>Daily</Frequency> </Schedule>
     * </InventoryConfiguration>
     */
public byte[] convertToXmlByteArray(InventoryConfiguration config) throws AmazonClientException {
    final XmlWriter xml = new XmlWriter();
    xml.start("InventoryConfiguration", "xmlns", Constants.XML_NAMESPACE);
    xml.start("Id").value(config.getId()).end();
    xml.start("IsEnabled").value(String.valueOf(config.isEnabled())).end();
    xml.start("IncludedObjectVersions").value(config.getIncludedObjectVersions()).end();
    writeInventoryDestination(xml, config.getDestination());
    writeInventoryFilter(xml, config.getInventoryFilter());
    addInventorySchedule(xml, config.getSchedule());
    addInventoryOptionalFields(xml, config.getOptionalFields());
    // </InventoryConfiguration>
    xml.end();
    return xml.getBytes();
}
Also used : XmlWriter(com.amazonaws.services.s3.internal.XmlWriter)

Example 19 with XmlWriter

use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method convertToXmlByteArray.

/**
 * Converts the specified {@link BucketTaggingConfiguration} object to an
 * XML fragment that can be sent to Amazon S3.
 *
 * @param config The {@link BucketTaggingConfiguration}
 */
/*
     * <Tagging> <TagSet> <Tag> <Key>Project</Key> <Value>Foo</Value> </Tag>
     * <Tag> <Key>User</Key> <Value>nschnarr</Value> </Tag> </TagSet> </Tagging>
     */
public byte[] convertToXmlByteArray(BucketTaggingConfiguration config) throws AmazonClientException {
    final XmlWriter xml = new XmlWriter();
    xml.start("Tagging");
    for (final TagSet tagset : config.getAllTagSets()) {
        writeRule(xml, tagset);
    }
    xml.end();
    return xml.getBytes();
}
Also used : TagSet(com.amazonaws.services.s3.model.TagSet) XmlWriter(com.amazonaws.services.s3.internal.XmlWriter)

Example 20 with XmlWriter

use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method writeInventoryDestination.

private void writeInventoryDestination(XmlWriter xml, InventoryDestination destination) {
    if (destination == null) {
        return;
    }
    xml.start("Destination");
    final InventoryS3BucketDestination s3BucketDestination = destination.getS3BucketDestination();
    if (s3BucketDestination != null) {
        xml.start("S3BucketDestination");
        addParameterIfNotNull(xml, "AccountId", s3BucketDestination.getAccountId());
        addParameterIfNotNull(xml, "Bucket", s3BucketDestination.getBucketArn());
        addParameterIfNotNull(xml, "Prefix", s3BucketDestination.getPrefix());
        addParameterIfNotNull(xml, "Format", s3BucketDestination.getFormat());
        // </S3BucketDestination>
        xml.end();
    }
    // </Destination>
    xml.end();
}
Also used : InventoryS3BucketDestination(com.amazonaws.services.s3.model.inventory.InventoryS3BucketDestination)

Aggregations

XmlWriter (com.amazonaws.services.s3.internal.XmlWriter)19 RedirectRule (com.amazonaws.services.s3.model.RedirectRule)3 NoncurrentVersionTransition (com.amazonaws.services.s3.model.BucketLifecycleConfiguration.NoncurrentVersionTransition)2 CORSRule (com.amazonaws.services.s3.model.CORSRule)2 FilterRule (com.amazonaws.services.s3.model.FilterRule)2 ReplicationRule (com.amazonaws.services.s3.model.ReplicationRule)2 RoutingRule (com.amazonaws.services.s3.model.RoutingRule)2 Map (java.util.Map)2 AmazonClientException (com.amazonaws.AmazonClientException)1 Rule (com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule)1 Transition (com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Transition)1 BucketNotificationConfiguration (com.amazonaws.services.s3.model.BucketNotificationConfiguration)1 TopicConfiguration (com.amazonaws.services.s3.model.BucketNotificationConfiguration.TopicConfiguration)1 AllowedMethods (com.amazonaws.services.s3.model.CORSRule.AllowedMethods)1 CloudFunctionConfiguration (com.amazonaws.services.s3.model.CloudFunctionConfiguration)1 KeyVersion (com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion)1 Filter (com.amazonaws.services.s3.model.Filter)1 Grant (com.amazonaws.services.s3.model.Grant)1 LambdaConfiguration (com.amazonaws.services.s3.model.LambdaConfiguration)1 NotificationConfiguration (com.amazonaws.services.s3.model.NotificationConfiguration)1