changeset 214:fc435da7f471

Enhanced the ClientProtocolUtils with a method that creates a document that is used to add an artifact to a collection. artifacts/trunk@1551 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 23 Mar 2011 16:23:52 +0000
parents 199f0e553e3a
children a9c8fa38ba03
files ChangeLog artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java
diffstat 2 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 23 16:20:11 2011 +0000
+++ b/ChangeLog	Wed Mar 23 16:23:52 2011 +0000
@@ -1,3 +1,9 @@
+2011-03-23  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java:
+	  Added a method that creates a document that is used to add an artifact
+	  to a collection.
+
 2011-03-23  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
--- a/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Wed Mar 23 16:20:11 2011 +0000
+++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Wed Mar 23 16:23:52 2011 +0000
@@ -225,6 +225,46 @@
 
 
     /**
+     * This method creates a new Document that is used to add an artifact to a
+     * collection in the artifact server.
+     *
+     * @param artId The identifier of the artifact that should be added.
+     * @param attr A document that contains attributes for the attribute's
+     * life in the collection.
+     *
+     * @return the document to add an artifact into a collection.
+     */
+    public static Document newAddArtifactDocument(String artId, Document attr) {
+        Document doc = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element action    = cr.create("action");
+        Element type      = cr.create("type");
+        Element artifact  = cr.create("artifact");
+        Element attribute = cr.create("attribute");
+
+        cr.addAttr(artifact, "uuid", artId);
+        cr.addAttr(type, "name", "addartifact");
+
+        if (attr != null) {
+            attr.appendChild(attr);
+        }
+
+        action.appendChild(type);
+        type.appendChild(artifact);
+        artifact.appendChild(attribute);
+
+        doc.appendChild(action);
+
+        return doc;
+    }
+
+
+    /**
      * Returns string value found by {@link XPATH_LABEL} relative to
      * <i>node</i>.
      *

http://dive4elements.wald.intevation.org