changeset 240:c0bc172ec7b2

Improved the ClientProtocolUtils with a method that returns a document that is used to trigger the DESCRIBE operation of artifacts. artifacts/trunk@1665 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Apr 2011 07:51:42 +0000
parents ab196a861796
children 4253995c970e
files ChangeLog artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java
diffstat 2 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 07 11:25:00 2011 +0000
+++ b/ChangeLog	Tue Apr 12 07:51:42 2011 +0000
@@ -1,3 +1,9 @@
+2011-04-12  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java:
+	  Added a method that returns a document that is used to trigger the
+	  artifact's DESCRIBE operation.
+
 2011-04-07  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 Apr 07 11:25:00 2011 +0000
+++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Tue Apr 12 07:51:42 2011 +0000
@@ -148,6 +148,52 @@
 
 
     /**
+     * This method creates a new DESCRIBE document.
+     *
+     * @param theUuid The identifier of the artifact.
+     * @param theHash The hash of the artifact.
+     * @param ui If true, the UI part is included.
+     *
+     * @return the DESCRIBE document.
+     */
+    public static Document newDescribeDocument(
+        String  theUuid,
+        String  theHash,
+        boolean incUI)
+    {
+        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 ui     = cr.create("include-ui");
+
+        // 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", "describe", false);
+        cr.addAttr(uuid, "value", theUuid, true);
+        cr.addAttr(hash, "value", theHash, true);
+
+        ui.setTextContent(incUI ? "true" : "false");
+
+        action.appendChild(type);
+        action.appendChild(uuid);
+        action.appendChild(hash);
+        action.appendChild(ui);
+
+        doc.appendChild(action);
+
+        return doc;
+    }
+
+
+    /**
      * This method creates a new ADVANCE document.
      *
      * @param theUuid The identifier of the artifact.

http://dive4elements.wald.intevation.org