changeset 198:6370369412e9

Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend. artifacts/trunk@1436 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Mar 2011 11:03:25 +0000
parents 94654cbf8db2
children face2302387c
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 09 10:24:56 2011 +0000
+++ b/ChangeLog	Wed Mar 09 11:03:25 2011 +0000
@@ -1,3 +1,10 @@
+2011-03-09  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	  Parse the collection attribute that is contained in the incoming
+	  document while creating a new collection and use this document as parameter
+	  for calling createCollection() of the Backend.
+
 2011-03-09  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Wed Mar 09 10:24:56 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Wed Mar 09 11:03:25 2011 +0000
@@ -215,6 +215,12 @@
         "/art:action/art:type/art:collection/@name";
 
     /**
+     * XPath to figure out the attributes for a collection.
+     */
+    public static final String XPATH_COLLECTION_ATTRIBUTE =
+        "/art:action/art:type/art:collection/art:attribute";
+
+    /**
      * XPath to figure out the attributes for an artifact that is put into a
      * collection.
      */
@@ -1192,8 +1198,20 @@
 
         logger.debug("Create new collection with name: " + name);
 
+        Document attr = XMLUtils.newDocument();
+
+        Node attrNode = (Node) XMLUtils.xpath(
+            data,
+            XPATH_COLLECTION_ATTRIBUTE,
+            XPathConstants.NODE,
+            ArtifactNamespaceContext.INSTANCE);
+
+        if (attrNode != null) {
+            attr.appendChild(attr.importNode(attrNode, true));
+        }
+
         ArtifactCollection ac = backend.createCollection(
-            ownerId, name, acf, data, context);
+            ownerId, name, acf, attr, context);
 
         if (ac == null) {
             throw new ArtifactDatabaseException(COLLECTION_CREATION_FAILED);

http://dive4elements.wald.intevation.org