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, RoutingRule rule) {
xml.start("RoutingRule");
final RoutingRuleCondition condition = rule.getCondition();
if (condition != null) {
xml.start("Condition");
xml.start("KeyPrefixEquals");
if (condition.getKeyPrefixEquals() != null) {
xml.value(condition.getKeyPrefixEquals());
}
// </KeyPrefixEquals">
xml.end();
if (condition.getHttpErrorCodeReturnedEquals() != null) {
xml.start("HttpErrorCodeReturnedEquals ").value(condition.getHttpErrorCodeReturnedEquals()).end();
}
// </Condition>
xml.end();
}
xml.start("Redirect");
final RedirectRule redirect = rule.getRedirect();
if (redirect != null) {
if (redirect.getprotocol() != null) {
xml.start("Protocol").value(redirect.getprotocol()).end();
}
if (redirect.getHostName() != null) {
xml.start("HostName").value(redirect.getHostName()).end();
}
if (redirect.getReplaceKeyPrefixWith() != null) {
xml.start("ReplaceKeyPrefixWith").value(redirect.getReplaceKeyPrefixWith()).end();
}
if (redirect.getReplaceKeyWith() != null) {
xml.start("ReplaceKeyWith").value(redirect.getReplaceKeyWith()).end();
}
if (redirect.getHttpRedirectCode() != null) {
xml.start("HttpRedirectCode").value(redirect.getHttpRedirectCode()).end();
}
}
// </Redirect>
xml.end();
// </CORSRule>
xml.end();
}
use of com.amazonaws.services.s3.internal.XmlWriter 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();
}
}
use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
public byte[] convertToXmlByteArray(BucketReplicationConfiguration replicationConfiguration) {
final XmlWriter xml = new XmlWriter();
xml.start("ReplicationConfiguration");
final Map<String, ReplicationRule> rules = replicationConfiguration.getRules();
final String role = replicationConfiguration.getRoleARN();
xml.start("Role").value(role).end();
for (final Map.Entry<String, ReplicationRule> entry : rules.entrySet()) {
final String ruleId = entry.getKey();
final ReplicationRule rule = entry.getValue();
xml.start("Rule");
xml.start("ID").value(ruleId).end();
xml.start("Prefix").value(rule.getPrefix()).end();
xml.start("Status").value(rule.getStatus()).end();
final ReplicationDestinationConfig config = rule.getDestinationConfig();
xml.start("Destination");
xml.start("Bucket").value(config.getBucketARN()).end();
if (config.getStorageClass() != null) {
xml.start("StorageClass").value(config.getStorageClass()).end();
}
xml.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 MultiObjectDeleteXmlFactory method convertToXmlByteArray.
/**
* Converts the specified {@link DeleteObjectsRequest} object to an XML
* fragment that can be sent to Amazon S3.
*
* @param rq The {@link DeleteObjectsRequest}
*/
public byte[] convertToXmlByteArray(DeleteObjectsRequest rq) throws AmazonClientException {
XmlWriter xml = new XmlWriter();
xml.start("Delete");
if (rq.getQuiet()) {
xml.start("Quiet").value("true").end();
}
for (KeyVersion keyVersion : rq.getKeys()) {
writeKeyVersion(xml, keyVersion);
}
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.internal.XmlWriter in project aws-sdk-android by aws-amplify.
the class RequestXmlFactory method convertToXmlByteArray.
/**
* Converts the specified list of PartETags to an XML fragment that can be
* sent to the CompleteMultipartUpload operation of Amazon S3.
*
* @param partETags The list of part ETags containing the data to include in
* the new XML fragment.
* @return A byte array containing the data
*/
public static byte[] convertToXmlByteArray(List<PartETag> partETags) {
XmlWriter xml = new XmlWriter();
xml.start("CompleteMultipartUpload");
if (partETags != null) {
Collections.sort(partETags, new Comparator<PartETag>() {
@Override
public int compare(PartETag tag1, PartETag tag2) {
if (tag1.getPartNumber() < tag2.getPartNumber())
return -1;
if (tag1.getPartNumber() > tag2.getPartNumber())
return 1;
return 0;
}
});
for (PartETag partEtag : partETags) {
xml.start("Part");
xml.start("PartNumber").value(Integer.toString(partEtag.getPartNumber())).end();
xml.start("ETag").value(partEtag.getETag()).end();
xml.end();
}
}
xml.end();
return xml.getBytes();
}
Aggregations