You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2010/02/20 04:05:50 UTC

svn commit: r912072 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java

Author: adrianc
Date: Sat Feb 20 03:05:49 2010
New Revision: 912072

URL: http://svn.apache.org/viewvc?rev=912072&view=rev
Log:
Have XmlSerializer delegate object deserialization to XStream if the serialization method is not from XmlSerializer.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java?rev=912072&r1=912071&r2=912072&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java Sat Feb 20 03:05:49 2010
@@ -75,11 +75,26 @@
         return UtilXml.writeXmlDocument(document);
     }
 
+    /** Deserialize a Java object from an XML string. <p>This method should be used with caution.
+     * If the XML string contains a serialized <code>GenericValue</code> or <code>GenericPK</code>
+     * then it is possible to unintentionally corrupt the database.</p>
+     * 
+     * @param content
+     * @param delegator
+     * @return
+     * @throws SerializeException
+     * @throws SAXException
+     * @throws ParserConfigurationException
+     * @throws IOException
+     */
     public static Object deserialize(String content, Delegator delegator)
         throws SerializeException, SAXException, ParserConfigurationException, IOException {
         // readXmlDocument with false second parameter to disable validation
         Document document = UtilXml.readXmlDocument(content, false);
         if (document != null) {
+            if (!"ofbiz-ser".equals(document.getDocumentElement().getTagName())) {
+                return UtilXml.fromXml(content);
+            }
             return deserialize(document, delegator);
         } else {
             Debug.logWarning("Serialized document came back null", module);
@@ -87,6 +102,16 @@
         }
     }
 
+    /** Deserialize a Java object from a DOM <code>Document</code>.
+     * <p>This method should be used with caution. If the DOM <code>Document</code>
+     * contains a serialized <code>GenericValue</code> or <code>GenericPK</code>
+     * then it is possible to unintentionally corrupt the database.</p>
+     * 
+     * @param document
+     * @param delegator
+     * @return
+     * @throws SerializeException
+     */
     public static Object deserialize(Document document, Delegator delegator) throws SerializeException {
         Element rootElement = document.getDocumentElement();
         // find the first element below the root element, that should be the object