use of com.qcloud.cos.internal.XmlWriter in project cos-java-sdk-v5 by tencentyun.
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 = "";
XmlWriter xml = new XmlWriter();
xml.start("BucketLoggingStatus");
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.qcloud.cos.internal.XmlWriter in project cos-java-sdk-v5 by tencentyun.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
public byte[] convertToXmlByteArray(BucketReplicationConfiguration replicationConfiguration) {
XmlWriter xml = new XmlWriter();
xml.start("ReplicationConfiguration");
List<ReplicationRule> rules = replicationConfiguration.getRules();
final String role = replicationConfiguration.getRoleName();
xml.start("Role").value(role).end();
for (ReplicationRule rule : rules) {
final String ruleId = rule.getID();
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.getBucketQCS()).end();
if (config.getStorageClass() != null) {
xml.start("StorageClass").value(config.getStorageClass()).end();
}
xml.end();
xml.end();
}
xml.end();
return xml.getBytes();
}
use of com.qcloud.cos.internal.XmlWriter in project cos-java-sdk-v5 by tencentyun.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
public byte[] convertToXmlByteArray(BucketLifecycleConfiguration config) throws CosClientException {
XmlWriter xml = new XmlWriter();
xml.start("LifecycleConfiguration");
for (Rule rule : config.getRules()) {
writeRule(xml, rule);
}
xml.end();
return xml.getBytes();
}
Aggregations