# HG changeset patch # User Ingo Weinzierl # Date 1299239247 0 # Node ID 8ce06db80857703f5acd119d1214531136a913b0 # Parent 401dd251fbf40dc38f82e7d556213243f08b2a89 Added a new method to the ProtocolUtils that creates the necessary CREATE document for creating new artifact collections. artifacts/trunk@1397 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 401dd251fbf4 -r 8ce06db80857 ChangeLog --- a/ChangeLog Fri Mar 04 11:13:24 2011 +0000 +++ b/ChangeLog Fri Mar 04 11:47:27 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-04 Ingo Weinzierl + + * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java: + Added a method that creates the CREATE document for creating new + artifact collections. + 2011-03-04 Sascha L. Teichmann * artifact-database/pom.xml: Lifted H2 to version 1.3.152. diff -r 401dd251fbf4 -r 8ce06db80857 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 Fri Mar 04 11:13:24 2011 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Fri Mar 04 11:47:27 2011 +0000 @@ -90,6 +90,38 @@ /** + * This method creates a new document that is used to create new artifact + * collections in the artifact server. + * + * @param name Optional name of the collection. + * + * @return the document to create new collections. + */ + public static Document newCreateCollectionDocument(String name) { + 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 collection = cr.create("artifact-collection"); + + cr.addAttr(type, "name", "create"); + cr.addAttr(collection, "name", name != null ? name : ""); + + action.appendChild(type); + action.appendChild(collection); + + doc.appendChild(action); + + return doc; + } + + + /** * Returns string value found by {@link XPATH_LABEL} relative to * node. *