Mercurial > dive4elements > framework
changeset 203:b5e1949bc255
Implemented a new method in the ClientProtocolUtils that creates the document for a FEED operation.
artifacts/trunk@1448 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Mar 2011 08:26:08 +0000 |
parents | c03d3a872cd2 |
children | 5c93fb142970 |
files | ChangeLog artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java |
diffstat | 2 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <ingo@intevation.de> * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/XMLUtils.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. *