changeset 204:5c93fb142970

Implemented a new method in the ClientProtocolUtils that creates the document for a ADVANCE operation. artifacts/trunk@1450 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Mar 2011 10:32:51 +0000 (2011-03-10)
parents b5e1949bc255
children 2a9591f76270
files ChangeLog artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java
diffstat 2 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 10 08:26:08 2011 +0000
+++ b/ChangeLog	Thu Mar 10 10:32:51 2011 +0000
@@ -1,3 +1,8 @@
+2011-03-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java:
+	  New method that creates the document for a ADVANCE operation.
+
 2011-03-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java:
--- a/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Thu Mar 10 08:26:08 2011 +0000
+++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Thu Mar 10 10:32:51 2011 +0000
@@ -143,6 +143,51 @@
 
 
     /**
+     * This method creates a new ADVANCE document.
+     *
+     * @param theUuid The identifier of the artifact.
+     * @param theHash The hash of the artifact.
+     * @param theTarget The target state identifier.
+     *
+     * @return the ADVANCE document.
+     */
+    public static Document newAdvanceDocument(
+        String theUuid,
+        String theHash,
+        String theTarget)
+    {
+        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 uuid   = cr.create("uuid");
+        Element hash   = cr.create("hash");
+        Element target = cr.create("target");
+
+        // XXX It is not nice that the type has no attribute namespace, but to
+        // be backward compatible, we don't change this now.
+        cr.addAttr(type, "name", "advance", false);
+        cr.addAttr(uuid, "value", theUuid, true);
+        cr.addAttr(hash, "value", theHash, true);
+        cr.addAttr(target, "name", theTarget, true);
+
+        action.appendChild(type);
+        action.appendChild(uuid);
+        action.appendChild(hash);
+        action.appendChild(target);
+
+        doc.appendChild(action);
+
+        return doc;
+    }
+
+
+    /**
      * This method creates a new document that is used to create new artifact
      * collections in the artifact server.
      *

http://dive4elements.wald.intevation.org