use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method writeStorageClassAnalysis.
private void writeStorageClassAnalysis(XmlWriter xml, StorageClassAnalysis storageClassAnalysis) {
if (storageClassAnalysis == null) {
return;
}
xml.start("StorageClassAnalysis");
if (storageClassAnalysis.getDataExport() != null) {
final StorageClassAnalysisDataExport dataExport = storageClassAnalysis.getDataExport();
xml.start("DataExport");
addParameterIfNotNull(xml, "OutputSchemaVersion", dataExport.getOutputSchemaVersion());
writeAnalyticsExportDestination(xml, dataExport.getDestination());
// </DataExport>
xml.end();
}
// </StorageClassAnalysis>
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 BucketLifecycleConfiguration} object to an
* XML fragment that can be sent to Amazon S3.
*
* @param config The {@link BucketLifecycleConfiguration}
*/
/*
* <LifecycleConfiguration> <Rule> <ID>logs-rule</ID>
* <Status>Enabled</Status> <Transition> <Days>30</Days>
* <StorageClass>GLACIER</StorageClass> </Transition> <Expiration>
* <Days>365</Days> </Expiration> <NoncurrentVersionTransition>
* <NoncurrentDays>7</NoncurrentDays> <StorageClass>GLACIER</StorageClass>
* </NoncurrentVersionTransition> <NoncurrentVersionExpiration>
* <NoncurrentDays>14</NoncurrentDays> </NoncurrentVersionExpiration>
* <Filter> <!-- A filter can have only one of Prefix, Tag or And. -->
* <Prefix>logs/</Prefix> <Tag> <Key>key1</Key> <Value>value1</Value> </Tag>
* <And> <Prefix>logs/</Prefix> <Tag> <Key>key1</Key> <Value>value1</Value>
* </Tag> <Tag> <Key>key1</Key> <Value>value1</Value> </Tag> </And>
* </Filter> </Rule> <Rule> <ID>image-rule</ID> <Prefix>image/</Prefix>
* <Status>Enabled</Status> <Transition>
* <Date>2012-12-31T00:00:00.000Z</Date>
* <StorageClass>GLACIER</StorageClass> </Transition> <Expiration>
* <Date>2020-12-31T00:00:00.000Z</Date> </Expiration>
* <AbortIncompleteMultipartUpload>
* <DaysAfterInitiation>10</DaysAfterInitiation>
* </AbortIncompleteMultipartUpload> </Rule> </LifecycleConfiguration>
*/
public byte[] convertToXmlByteArray(BucketLifecycleConfiguration config) throws AmazonClientException {
final XmlWriter xml = new XmlWriter();
xml.start("LifecycleConfiguration");
for (final Rule rule : config.getRules()) {
writeRule(xml, rule);
}
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 website configuration into an XML byte array to
* send to S3. Sample XML:
* <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
* <IndexDocument> <Suffix>index.html</Suffix> </IndexDocument>
* <ErrorDocument> <Key>404.html</Key> </ErrorDocument>
* </WebsiteConfiguration>
*
* @param websiteConfiguration The configuration to convert.
* @return The XML byte array representation.
*/
public byte[] convertToXmlByteArray(BucketWebsiteConfiguration websiteConfiguration) {
final XmlWriter xml = new XmlWriter();
xml.start("WebsiteConfiguration", "xmlns", Constants.XML_NAMESPACE);
if (websiteConfiguration.getIndexDocumentSuffix() != null) {
final XmlWriter indexDocumentElement = xml.start("IndexDocument");
indexDocumentElement.start("Suffix").value(websiteConfiguration.getIndexDocumentSuffix()).end();
indexDocumentElement.end();
}
if (websiteConfiguration.getErrorDocument() != null) {
final XmlWriter errorDocumentElement = xml.start("ErrorDocument");
errorDocumentElement.start("Key").value(websiteConfiguration.getErrorDocument()).end();
errorDocumentElement.end();
}
final RedirectRule redirectAllRequestsTo = websiteConfiguration.getRedirectAllRequestsTo();
if (redirectAllRequestsTo != null) {
final XmlWriter redirectAllRequestsElement = xml.start("RedirectAllRequestsTo");
if (redirectAllRequestsTo.getprotocol() != null) {
xml.start("Protocol").value(redirectAllRequestsTo.getprotocol()).end();
}
if (redirectAllRequestsTo.getHostName() != null) {
xml.start("HostName").value(redirectAllRequestsTo.getHostName()).end();
}
if (redirectAllRequestsTo.getReplaceKeyPrefixWith() != null) {
xml.start("ReplaceKeyPrefixWith").value(redirectAllRequestsTo.getReplaceKeyPrefixWith()).end();
}
if (redirectAllRequestsTo.getReplaceKeyWith() != null) {
xml.start("ReplaceKeyWith").value(redirectAllRequestsTo.getReplaceKeyWith()).end();
}
redirectAllRequestsElement.end();
}
if (websiteConfiguration.getRoutingRules() != null && websiteConfiguration.getRoutingRules().size() > 0) {
final XmlWriter routingRules = xml.start("RoutingRules");
for (final RoutingRule rule : websiteConfiguration.getRoutingRules()) {
writeRule(routingRules, rule);
}
routingRules.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 logging configuration into an XML byte array.
*
* @param loggingConfiguration The configuration to convert.
* @return The XML byte array representation.
*/
public byte[] convertToXmlByteArray(BucketLoggingConfiguration loggingConfiguration) {
// Default log file prefix to the empty string if none is specified
String logFilePrefix = loggingConfiguration.getLogFilePrefix();
if (logFilePrefix == null) {
logFilePrefix = "";
}
final XmlWriter xml = new XmlWriter();
xml.start("BucketLoggingStatus", "xmlns", Constants.XML_NAMESPACE);
if (loggingConfiguration.isLoggingEnabled()) {
xml.start("LoggingEnabled");
xml.start("TargetBucket").value(loggingConfiguration.getDestinationBucketName()).end();
xml.start("TargetPrefix").value(loggingConfiguration.getLogFilePrefix()).end();
xml.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 versioning configuration into an XML byte array.
*
* @param versioningConfiguration The configuration to convert.
* @return The XML byte array representation.
*/
public byte[] convertToXmlByteArray(BucketVersioningConfiguration versioningConfiguration) {
final XmlWriter xml = new XmlWriter();
xml.start("VersioningConfiguration", "xmlns", Constants.XML_NAMESPACE);
xml.start("Status").value(versioningConfiguration.getStatus()).end();
final Boolean mfaDeleteEnabled = versioningConfiguration.isMfaDeleteEnabled();
if (mfaDeleteEnabled != null) {
if (mfaDeleteEnabled) {
xml.start("MfaDelete").value("Enabled").end();
} else {
xml.start("MfaDelete").value("Disabled").end();
}
}
xml.end();
return xml.getBytes();
}
Aggregations