diff artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 254:6cf9560bd249

Bugfix: do not write empty xml documents into database any longer - caused exceptions while serialization/deserialization. artifacts/trunk@1752 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 27 Apr 2011 16:57:20 +0000
parents a2df2b48d2aa
children 4edaf3073109
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Tue Apr 26 07:43:40 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Wed Apr 27 16:57:20 2011 +0000
@@ -1171,7 +1171,7 @@
 
         logger.debug("Create new collection with name: " + name);
 
-        Document attr = XMLUtils.newDocument();
+        Document attr = null;
 
         Node attrNode = (Node) XMLUtils.xpath(
             data,
@@ -1180,6 +1180,7 @@
             ArtifactNamespaceContext.INSTANCE);
 
         if (attrNode != null) {
+            attr = XMLUtils.newDocument();
             attr.appendChild(attr.importNode(attrNode, true));
         }
 
@@ -1285,7 +1286,7 @@
     {
         logger.debug("Set the attribute for the collection: " + collectionId);
 
-        Document attributes = XMLUtils.newDocument();
+        Document attributes = null;
 
         Node attr = (Node) XMLUtils.xpath(
             attribute,
@@ -1294,6 +1295,7 @@
             ArtifactNamespaceContext.INSTANCE);
 
         if (attr != null) {
+            attributes = XMLUtils.newDocument();
             attributes.appendChild(attributes.importNode(attr, true));
         }
 
@@ -1329,7 +1331,7 @@
     {
         logger.debug("Set the attribute for the artifact: " + artifactId);
 
-        Document attribute = XMLUtils.newDocument();
+        Document attribute = null;
 
         Node attr = (Node) XMLUtils.xpath(
             source,
@@ -1338,6 +1340,7 @@
             ArtifactNamespaceContext.INSTANCE);
 
         if (attr != null) {
+            attribute = XMLUtils.newDocument();
             attribute.appendChild(attribute.importNode(attr, true));
         }
 

http://dive4elements.wald.intevation.org