Mercurial > dive4elements > framework
changeset 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 | 401dd251fbf4 |
children | 940ed629419f |
files | ChangeLog artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java |
diffstat | 2 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <sascha.teichmann@intevation.de> * artifact-database/pom.xml: Lifted H2 to version 1.3.152.
--- 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>. *