From: Ray Lee Date: Mon, 27 Jul 2020 22:10:18 +0000 (-0400) Subject: DRYD-889: When converting json to xml, convert properties named '.' to xml element... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=e58cfac4ed460b3b07a746d61eee76df08d741ea;p=tmp%2Fjakarta-migration.git DRYD-889: When converting json to xml, convert properties named '.' to xml element content. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/xmljson/ConversionUtils.java b/services/common/src/main/java/org/collectionspace/services/common/xmljson/ConversionUtils.java index e3e17ec1a..0f22031ed 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/xmljson/ConversionUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/xmljson/ConversionUtils.java @@ -13,28 +13,28 @@ public class ConversionUtils { * field names. */ public static final String XML_ATTRIBUTE_PREFIX = "@"; - + /** * Prefix to prepend to XML namespace prefixes when converting to * JSON field names. */ public static final String XML_NAMESPACE_PREFIX = XML_ATTRIBUTE_PREFIX + "xmlns:"; - + /** * Converts an XML attribute name to a JSON field name. - * + * * @param xmlAttributeName the XML attribute name * @return the JSON field name */ public static String xmlAttributeNameToJsonFieldName(String xmlAttributeName) { return XML_ATTRIBUTE_PREFIX + xmlAttributeName; } - + /** * Converts a JSON field name to an XML attribute name. * The field name must be in the expected format, as determined by * isXmlAttribute(). - * + * * @param jsonFieldName the JSON field name * @return the XML attribute name */ @@ -44,19 +44,19 @@ public class ConversionUtils { /** * Converts an XML namespace prefix to a JSON field name. - * + * * @param xmlNamespacePrefix the XML namespace prefix * @return the JSON field name */ public static String xmlNamespacePrefixToJsonFieldName(String xmlNamespacePrefix) { return XML_NAMESPACE_PREFIX + xmlNamespacePrefix; } - + /** * Converts a JSON field name to an XML namespace prefix. * The field name must be in the expected format, as determined by * isXmlNamespace(). - * + * * @param jsonFieldName the JSON field name * @return the XML namespace prefix */ @@ -67,7 +67,7 @@ public class ConversionUtils { /** * Determines if a JSON field name represents an XML * attribute. - * + * * @param jsonFieldName the field name to test * @return true if the field name represents an XML attribute, * false otherwise @@ -75,11 +75,11 @@ public class ConversionUtils { public static boolean isXmlAttribute(String jsonFieldName) { return jsonFieldName.startsWith(XML_ATTRIBUTE_PREFIX); } - + /** * Determines if a JSON field name represents an XML * namespace prefix. - * + * * @param jsonFieldName the field name to test * @return true if the field name represents an XML namespace prefix, * false otherwise @@ -87,21 +87,32 @@ public class ConversionUtils { public static boolean isXmlNamespace(String jsonFieldName) { return jsonFieldName.startsWith(XML_NAMESPACE_PREFIX); } - + + /** + * Determines if a JSON field name represents XML element content. + * + * @param jsonFieldName the field name to test + * @return true if the field name represents XML element content, + * false otherwise + */ + public static boolean isXmlContent(String jsonFieldName) { + return jsonFieldName.equals("."); + } + /** * Converts an XML element QName to a JSON field name. - * + * * @param name the XML element QName * @return the JSON field name */ public static String jsonFieldNameFromXMLQName(QName name) { String prefix = name.getPrefix(); String localPart = name.getLocalPart(); - + if (StringUtils.isNotEmpty(prefix)) { return prefix + ":" + localPart; } - + return localPart; } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/xmljson/JsonToXmlStreamConverter.java b/services/common/src/main/java/org/collectionspace/services/common/xmljson/JsonToXmlStreamConverter.java index 2e0575a5d..e6130b247 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/xmljson/JsonToXmlStreamConverter.java +++ b/services/common/src/main/java/org/collectionspace/services/common/xmljson/JsonToXmlStreamConverter.java @@ -29,6 +29,8 @@ import com.fasterxml.jackson.core.JsonToken; *