# HG changeset patch # User Ingo Weinzierl # Date 1308747144 0 # Node ID f5a0f90bcc6fd86acb52f9909ed27d61be7257b0 # Parent 084d68974d4ae934b87bba52a43260a043662aed Improved the ClientProtocolUtils: new methods to create collection action specific documents. artifacts/trunk@2204 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 084d68974d4a -r f5a0f90bcc6f ChangeLog --- 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 + + * 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 * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: diff -r 084d68974d4a -r f5a0f90bcc6f 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 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 * node. *