# HG changeset patch # User Ingo Weinzierl # Date 1303978203 0 # Node ID efbad8c5c0e52e7b4f3b72d4c901ad8bfdbf9d65 # Parent 6cf9560bd2496511a8b4b991fc3f83ea2c5328a8 Improved the ClientProtocolUtils - new function to create a document that is used to set the attribute of a CollectionItem. artifacts/trunk@1753 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6cf9560bd249 -r efbad8c5c0e5 ChangeLog --- a/ChangeLog Wed Apr 27 16:57:20 2011 +0000 +++ b/ChangeLog Thu Apr 28 08:10:03 2011 +0000 @@ -1,3 +1,9 @@ +2011-04-28 Ingo Weinzierl + + * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java: + Added a function that creates the document that is used to set the + attribute of a CollectionItem (setCollectionItemAttribute() operation). + 2011-04-27 Ingo Weinzierl * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: diff -r 6cf9560bd249 -r efbad8c5c0e5 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 Wed Apr 27 16:57:20 2011 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Thu Apr 28 08:10:03 2011 +0000 @@ -370,6 +370,49 @@ /** + * This function creates a document that is used to set the attribute of a + * CollectionItem. + * + * @param uuid The identifier of the CollectionItem. + * @param attr The new attribute value for the CollectionItem. + * + * @return the document that is used to set the attribute. + */ + public static Document newSetItemAttributeDocument( + String uuid, + Document attr) + { + Node root = attr.getFirstChild(); + + if (root == null) { + return null; + } + + 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 artifact = ec.create("artifact"); + + ec.addAttr(type, "name", "setitemattribute"); + ec.addAttr(artifact, "uuid", uuid); + + doc.appendChild(action); + action.appendChild(type); + type.appendChild(artifact); + + artifact.appendChild(doc.importNode(root, true)); + + return doc; + } + + + /** * Returns string value found by {@link XPATH_LABEL} relative to * node. *