# HG changeset patch # User Ingo Weinzierl # Date 1306483894 0 # Node ID 72de5c373c9b111c89b6fabfaf5076c8851d1352 # Parent c42a07be9aeed8a39809099bbd17e146e1fa0403 Enhanced the ClientProtocolUtils with a method to create a document that sets the attribute of a collection. artifacts/trunk@2014 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c42a07be9aee -r 72de5c373c9b ChangeLog --- a/ChangeLog Mon May 23 10:04:31 2011 +0000 +++ b/ChangeLog Fri May 27 08:11:34 2011 +0000 @@ -1,3 +1,9 @@ +2011-05-27 Ingo Weinzierl + + * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java: + New method that creates the document that is used to set an attribute of + a collection. + 2011-04-23 Sascha L. Teichmann * artifact-database/src/main/java/de/intevation/artifactdatabase/rest/JettyServer.java: diff -r c42a07be9aee -r 72de5c373c9b 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 Mon May 23 10:04:31 2011 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Fri May 27 08:11:34 2011 +0000 @@ -407,6 +407,48 @@ /** * This function creates a document that is used to set the attribute of a + * Collection. + * + * @param uuid The identifier of the Collection. + * @param attr The new attribute value for the Collection. + * + * @return the document that is used to set the attribute. + */ + public static Document newSetAttributeDocument( + String uuid, + Document attr) + { + Node root = attr != null ? attr.getFirstChild() : null; + + 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 collection = ec.create("collection"); + + ec.addAttr(type, "name", "setattribute", false); + ec.addAttr(collection, "uuid", uuid, false); + + doc.appendChild(action); + action.appendChild(type); + type.appendChild(collection); + + collection.appendChild(doc.importNode(root, true)); + + return doc; + } + + /** + * This function creates a document that is used to set the attribute of a * CollectionItem. * * @param uuid The identifier of the CollectionItem.