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 com.amazonaws.services.s3.model.metrics.MetricsConfiguration}
* object to an XML fragment that can be sent to Amazon S3.
*
* @param config The
* {@link com.amazonaws.services.s3.model.metrics.MetricsConfiguration}
* .
*/
/*
* <MetricsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
* <Id>metrics-id</Id> <Filter> <!-- A filter should have only one of
* Prefix, Tag or And--> <Prefix>prefix</Prefix> <Tag> <Key>Project</Key>
* <Value>Foo</Value> </Tag> <And> <Prefix>documents/</Prefix> <Tag>
* <Key>foo</Key> <Value>bar</Value> </Tag> </And> </Filter>
* </MetricsConfiguration>
*/
public byte[] convertToXmlByteArray(MetricsConfiguration config) throws AmazonClientException {
final XmlWriter xml = new XmlWriter();
xml.start("MetricsConfiguration", "xmlns", Constants.XML_NAMESPACE);
addParameterIfNotNull(xml, "Id", config.getId());
writeMetricsFilter(xml, config.getFilter());
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method writeRule.
private void writeRule(XmlWriter xml, CORSRule rule) {
xml.start("CORSRule");
if (rule.getId() != null) {
xml.start("ID").value(rule.getId()).end();
}
if (rule.getAllowedOrigins() != null) {
for (final String origin : rule.getAllowedOrigins()) {
xml.start("AllowedOrigin").value(origin).end();
}
}
if (rule.getAllowedMethods() != null) {
for (final AllowedMethods method : rule.getAllowedMethods()) {
xml.start("AllowedMethod").value(method.toString()).end();
}
}
if (rule.getMaxAgeSeconds() != 0) {
xml.start("MaxAgeSeconds").value(Integer.toString(rule.getMaxAgeSeconds())).end();
}
if (rule.getExposedHeaders() != null) {
for (final String header : rule.getExposedHeaders()) {
xml.start("ExposeHeader").value(header).end();
}
}
if (rule.getAllowedHeaders() != null) {
for (final String header : rule.getAllowedHeaders()) {
xml.start("AllowedHeader").value(header).end();
}
}
// </CORSRule>
xml.end();
}
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 com.amazonaws.services.s3.model.analytics.AnalyticsConfiguration}
* object to an XML fragment that can be sent to Amazon S3.
*
* @param config The
* {@link com.amazonaws.services.s3.model.analytics.AnalyticsConfiguration}
*/
/*
* <AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
* <Id>XXX</Id> <Filter> <And> <Prefix>documents/</Prefix> <Tag>
* <Key>foo</Key> <Value>bar</Value> </Tag> </And> </Filter>
* <StorageClassAnalysis> <DataExport>
* <OutputSchemaVersion>1</OutputSchemaVersion> <Destination>
* <S3BucketDestination> <Format>CSV</Format>
* <BucketAccountId>123456789</BucketAccountId>
* <Bucket>destination-bucket</Bucket> <Prefix>destination-prefix</Prefix>
* </S3BucketDestination> </Destination> </DataExport>
* </StorageClassAnalysis> </AnalyticsConfiguration>
*/
public byte[] convertToXmlByteArray(AnalyticsConfiguration config) throws AmazonClientException {
final XmlWriter xml = new XmlWriter();
xml.start("AnalyticsConfiguration", "xmlns", Constants.XML_NAMESPACE);
addParameterIfNotNull(xml, "Id", config.getId());
writeAnalyticsFilter(xml, config.getFilter());
writeStorageClassAnalysis(xml, config.getStorageClassAnalysis());
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
/**
* Converts the specified accelerate configuration into an XML byte array.
*
* @param accelerateConfiguration The configuration to convert.
* @return The XML byte array representation.
*/
public byte[] convertToXmlByteArray(BucketAccelerateConfiguration accelerateConfiguration) {
final XmlWriter xml = new XmlWriter();
xml.start("AccelerateConfiguration", "xmlns", Constants.XML_NAMESPACE);
xml.start("Status").value(accelerateConfiguration.getStatus()).end();
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
/**
* Converts the specified notification configuration into an XML byte array.
*
* @param notificationConfiguration The configuration to convert.
* @return The XML byte array representation.
*/
public byte[] convertToXmlByteArray(BucketNotificationConfiguration notificationConfiguration) {
final XmlWriter xml = new XmlWriter();
xml.start("NotificationConfiguration", "xmlns", Constants.XML_NAMESPACE);
final Map<String, NotificationConfiguration> configurations = notificationConfiguration.getConfigurations();
for (final Map.Entry<String, NotificationConfiguration> entry : configurations.entrySet()) {
final String configName = entry.getKey();
final NotificationConfiguration config = entry.getValue();
if (config instanceof TopicConfiguration) {
xml.start("TopicConfiguration");
xml.start("Id").value(configName).end();
xml.start("Topic").value(((TopicConfiguration) config).getTopicARN()).end();
addEventsAndFilterCriteria(xml, config);
xml.end();
} else if (config instanceof QueueConfiguration) {
xml.start("QueueConfiguration");
xml.start("Id").value(configName).end();
xml.start("Queue").value(((QueueConfiguration) config).getQueueARN()).end();
addEventsAndFilterCriteria(xml, config);
xml.end();
} else if (config instanceof CloudFunctionConfiguration) {
xml.start("CloudFunctionConfiguration");
xml.start("Id").value(configName).end();
xml.start("InvocationRole").value(((CloudFunctionConfiguration) config).getInvocationRoleARN()).end();
xml.start("CloudFunction").value(((CloudFunctionConfiguration) config).getCloudFunctionARN()).end();
addEventsAndFilterCriteria(xml, config);
xml.end();
} else if (config instanceof LambdaConfiguration) {
xml.start("CloudFunctionConfiguration");
xml.start("Id").value(configName).end();
xml.start("CloudFunction").value(((LambdaConfiguration) config).getFunctionARN()).end();
addEventsAndFilterCriteria(xml, config);
xml.end();
}
}
xml.end();
return xml.getBytes();
}
Aggregations