diff artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 258:c41b300b02c3

Improved the ClientProtocolUtils: collections OUT document contains attributes now. artifacts/trunk@1907 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 12 May 2011 09:06:34 +0000
parents efbad8c5c0e5
children f3d970a832ff
line wrap: on
line diff
--- a/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Thu Apr 28 10:30:30 2011 +0000
+++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Thu May 12 09:06:34 2011 +0000
@@ -351,6 +351,26 @@
      * @return the request document.
      */
     public static Document newOutCollectionDocument(String uuid, String type) {
+        return newOutCollectionDocument(uuid, type, null);
+    }
+
+
+    /**
+     * This function builds a document that is used as request document of the
+     * out() operation of Collections. The document <i>attr</i> might be used to
+     * adjust some settings specific to the output.
+     *
+     * @param uuid The identifier of the collection.
+     * @param type The name of the desired output type.
+     * @param attr A document that contains settings specific to the output.
+     *
+     * @return the request document.
+     */
+    public static Document newOutCollectionDocument(
+        String   uuid,
+        String   type,
+        Document attr)
+    {
         Document doc = XMLUtils.newDocument();
 
         XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator(
@@ -358,13 +378,23 @@
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
-        Element action = cr.create("action");
+        Element action     = cr.create("action");
+        Element attributes = cr.create("attributes");
 
         cr.addAttr(action, "name", type, true);
         cr.addAttr(action, "type", type, true);
 
         doc.appendChild(action);
 
+        if (attr != null) {
+            Node root = attr.getFirstChild();
+
+            if (root != null) {
+                action.appendChild(attributes);
+                attributes.appendChild(doc.importNode(root, true));
+            }
+        }
+
         return doc;
     }
 

http://dive4elements.wald.intevation.org