# HG changeset patch # User Ingo Weinzierl # Date 1299745568 0 # Node ID b5e1949bc25596ea94eaeb922dc14fb4d98c71ec # Parent c03d3a872cd2f6c145ffe1d453b9b07971b38192 Implemented a new method in the ClientProtocolUtils that creates the document for a FEED operation. artifacts/trunk@1448 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c03d3a872cd2 -r b5e1949bc255 ChangeLog --- a/ChangeLog Thu Mar 10 08:25:30 2011 +0000 +++ b/ChangeLog Thu Mar 10 08:26:08 2011 +0000 @@ -1,3 +1,8 @@ +2011-03-10 Ingo Weinzierl + + * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java: + New method that creates the document for a FEED operation. + 2011-03-10 Ingo Weinzierl * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/XMLUtils.java: diff -r c03d3a872cd2 -r b5e1949bc255 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 Thu Mar 10 08:25:30 2011 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Thu Mar 10 08:26:08 2011 +0000 @@ -90,6 +90,59 @@ /** + * This method creates a new FEED document. + * + * @param theUuid The identifier of the artifact. + * @param theHash The hash of the artifact. + * @param theData An array that contains key/value pairs that represent the + * data that should be included in the FEED document. + * + * @return the FEED document. + */ + public static Document newFeedDocument( + String theUuid, + String theHash, + String[][] theData) + { + 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 uuid = cr.create("uuid"); + Element hash = cr.create("hash"); + Element data = cr.create("data"); + + // XXX It is not nice that the type has no attribute namespace, but to + // be backward compatible, we don't change this now. + cr.addAttr(type, "name", "feed", false); + cr.addAttr(uuid, "value", theUuid, true); + cr.addAttr(hash, "value", theHash, true); + + for (String[] kvp: theData) { + Element input = cr.create("input"); + cr.addAttr(input, "name", kvp[0], true); + cr.addAttr(input, "value", kvp[1], true); + + data.appendChild(input); + } + + action.appendChild(type); + action.appendChild(uuid); + action.appendChild(hash); + action.appendChild(data); + + doc.appendChild(action); + + return doc; + } + + + /** * This method creates a new document that is used to create new artifact * collections in the artifact server. *