changeset 285:f5a0f90bcc6f

Improved the ClientProtocolUtils: new methods to create collection action specific documents. artifacts/trunk@2204 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 22 Jun 2011 12:52:24 +0000
parents 084d68974d4a
children 715bdf990739
files ChangeLog artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java
diffstat 2 files changed, 94 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jun 21 16:16:16 2011 +0000
+++ b/ChangeLog	Wed Jun 22 12:52:24 2011 +0000
@@ -1,3 +1,9 @@
+2011-06-22  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java:
+	  Added functions that generate documents to set the name and ttl of a
+	  collection and to delete an existing collection.
+
 2011-06-21  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
--- a/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Tue Jun 21 16:16:16 2011 +0000
+++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Wed Jun 22 12:52:24 2011 +0000
@@ -489,6 +489,94 @@
 
 
     /**
+     * This function creates a document that is used to set the time-to-live
+     * of a collection.
+     *
+     * @param ttl The ttl for the Collection.
+     *
+     * @return the document that is used to set the time-to-live.
+     */
+    public static Document newSetCollectionTTLDocument(String ttl) {
+        Document doc = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element action = ec.create("action");
+        Element type   = ec.create("type");
+        Element ttlEl  = ec.create("ttl");
+
+        ec.addAttr(type, "name", "settimetolive");
+        ec.addAttr(ttlEl, "value", ttl);
+
+        doc.appendChild(action);
+        action.appendChild(type);
+        type.appendChild(ttlEl);
+
+        return doc;
+    }
+
+
+    /**
+     * This function creates a document that is used to set the name of a
+     * collection.
+     *
+     * @param name The name for the Collection.
+     *
+     * @return the document that is used to set the name of a collection.
+     */
+    public static Document newSetCollectionNameDocument(String name) {
+        Document doc = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element action = ec.create("action");
+        Element type   = ec.create("type");
+        Element coll   = ec.create("collection");
+
+        ec.addAttr(type, "name", "setname");
+        ec.addAttr(coll, "name", name);
+
+        doc.appendChild(action);
+        action.appendChild(type);
+        type.appendChild(coll);
+
+        return doc;
+    }
+
+
+    /**
+     * This function creates a document that is used to delete an existing
+     * collection.
+     *
+     * @return the document that is used to delete an existing collection.
+     */
+    public static Document newDeleteCollectionDocument() {
+        Document doc = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element action = ec.create("action");
+        Element type   = ec.create("type");
+
+        ec.addAttr(type, "name", "delete");
+
+        doc.appendChild(action);
+        action.appendChild(type);
+
+        return doc;
+    }
+
+
+    /**
      * Returns string value found by {@link XPATH_LABEL} relative to
      * <i>node</i>.
      *

http://dive4elements.wald.intevation.org