public byte[] convertToXmlByteArray(ObjectTagging tagging) { XmlWriter writer = new XmlWriter(); writer.start("Tagging").start("TagSet"); for (Tag tag : tagging.getTagSet()) { writer.start("Tag"); writer.start("Key").value(tag.getKey()).end(); writer.start("Value").value(tag.getValue()).end(); writer.end(); // </Tag> } writer.end(); // </TagSet> writer.end(); // </Tagging> return writer.getBytes(); } }
private void writeInventoryEncryption(XmlWriter xml, InventoryEncryption encryption) { if (encryption == null) { return; } xml.start("Encryption"); if (encryption instanceof ServerSideEncryptionS3) { xml.start("SSE-S3").end(); } else if (encryption instanceof ServerSideEncryptionKMS) { xml.start("SSE-KMS"); addParameterIfNotNull(xml, "KeyId", ((ServerSideEncryptionKMS) encryption).getKeyId()); xml.end(); } xml.end(); }
@Test public void testEscapedCharacters() { XmlWriter w = new XmlWriter(); String[] attrs = { "tab", "newLine", "return", "ampersand", "quote", "lessthan", "greaterthan" }; String[] values = { "\t", "\n", "\r", "&", "\"", "<", ">" }; w.start("test", attrs, values); w.end(); String expected = "<test tab=\"	\" newLine=\" \" return=\" \" ampersand=\"&\" quote=\""\" lessthan=\"<\" greaterthan=\">\"></test>"; assertEquals(expected, w.toString()); }
/** * 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) { XmlWriter xml = new XmlWriter(); xml.start("AccelerateConfiguration", "xmlns", Constants.XML_NAMESPACE); xml.start("Status").value(accelerateConfiguration.getStatus()).end(); xml.end(); return xml.getBytes(); }
/** * 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) { XmlWriter xml = new XmlWriter(); xml.start("VersioningConfiguration", "xmlns", Constants.XML_NAMESPACE); xml.start("Status").value(versioningConfiguration.getStatus()).end(); 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(); }
public byte[] convertToXmlByteArray(ServerSideEncryptionConfiguration sseConfig) { XmlWriter xml = new XmlWriter(); xml.start("ServerSideEncryptionConfiguration", "xmlns", Constants.XML_NAMESPACE); for (ServerSideEncryptionRule rule : sseConfig.getRules()) { xml.start("Rule"); writeServerSideEncryptionByDefault(xml, rule.getApplyServerSideEncryptionByDefault()); xml.end(); } xml.end(); return xml.getBytes(); }
XmlWriter xml = new XmlWriter(); xml.start("CompleteMultipartUpload"); if (partETags != null) { List<PartETag> sortedPartETags = new ArrayList<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();
/** * 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", "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(); }