Mercurial > dive4elements > framework
diff artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 172:8ce06db80857
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
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 Mar 2011 11:47:27 +0000 |
parents | 19b86e27d0c3 |
children | b5e1949bc255 |
line wrap: on
line diff
--- 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 <b>Optional</b> 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 * <i>node</i>. *