]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-767: Do not attempt to unmarshal XML elements w/o a namespace URI.
authorRay Lee <ray.lee@lyrasis.org>
Wed, 2 Oct 2019 00:22:00 +0000 (17:22 -0700)
committerRay Lee <ray.lee@lyrasis.org>
Wed, 2 Oct 2019 00:22:00 +0000 (17:22 -0700)
services/client/pom.xml
services/client/src/main/java/org/collectionspace/services/client/PoxPayload.java
services/common-api/pom.xml

index 7b2b20eb4955aa51dd37e689e40ec190d73bc141..d9224d579d0eaffa54affa602369aca51986eef7 100644 (file)
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
         </dependency>
+       <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.2.1</version>
+            <scope>provided</scope>
+        </dependency>
         <dependency>
                        <groupId>org.apache.httpcomponents</groupId>
                        <artifactId>httpclient</artifactId>
index 6661db2273f371137250e3e2a7b4c74118a88f5c..827ceca1c4d6ea4be4ad4c0077b857af380d9697 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.transform.stream.StreamSource;
 import com.sun.xml.bind.api.impl.NameConverter;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.dom4j.Document;
 import org.dom4j.DocumentException;
 import org.dom4j.DocumentHelper;
@@ -329,29 +330,34 @@ public abstract class PoxPayload<PT extends PayloadPart> {
         return nc.toPackageName(namespaceURI);
     }
 
-    /**
-     * Attempts to unmarshal a DOM4j element (for a part) into an instance of a JAXB object
-     *
-     * @param elementInput the element input
-     * @return the object
-     */
-    public static Object toObject(Element elementInput) {
-       Object result = null;
-       try {
-               Namespace namespace = elementInput.getNamespace();
-               String thePackage = getPackage(namespace);
-               JAXBContext jc = JAXBContext.newInstance(thePackage);
-               Unmarshaller um = jc.createUnmarshaller();
-               result = um.unmarshal(
-                               new StreamSource(new StringReader(elementInput.asXML())));
-       } catch (Exception e) {
-               String msg = String.format("Could not unmarshal XML payload '%s' into a JAXB object.",
-                               elementInput.getName());
-               logger.warn(msg);
-       }
+               /**
+                * Attempts to unmarshal a DOM4j element (for a part) into an instance of a JAXB object
+                *
+                * @param elementInput the element input
+                * @return the object
+                */
+               public static Object toObject(Element elementInput) {
+                       Object result = null;
 
-       return result;
-    }
+                       try {
+                               Namespace namespace = elementInput.getNamespace();
+
+                               if (StringUtils.isNotEmpty(namespace.getURI())) {
+                                       String thePackage = getPackage(namespace);
+                                       JAXBContext jc = JAXBContext.newInstance(thePackage);
+                                       Unmarshaller um = jc.createUnmarshaller();
+
+                                       result = um.unmarshal(new StreamSource(new StringReader(elementInput.asXML())));
+                               }
+                       } catch (Exception e) {
+                               if (logger.isInfoEnabled()) {
+                                       String msg = String.format("Could not unmarshal XML element '%s' into a JAXB object.", elementInput.getName());
+                                       logger.info(msg);
+                               }
+                       }
+
+                       return result;
+               }
 
     /**
      * Attempts to unmarshal a JAXB object (for a part) to a DOM4j element.
index 10f4ba8c740154ba73c27cf14c7077a496f7cdca..38741f2089fcd0273a997b72fb0b4518817496c1 100644 (file)
@@ -14,7 +14,8 @@
        <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
+            <version>3.2.1</version>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>