# HG changeset patch # User Ingo Weinzierl # Date 1299753171 0 # Node ID 5c93fb14297049d3729f679baccffa85bbd083d4 # Parent b5e1949bc25596ea94eaeb922dc14fb4d98c71ec Implemented a new method in the ClientProtocolUtils that creates the document for a ADVANCE operation. artifacts/trunk@1450 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b5e1949bc255 -r 5c93fb142970 ChangeLog --- a/ChangeLog Thu Mar 10 08:26:08 2011 +0000 +++ b/ChangeLog Thu Mar 10 10:32:51 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 ADVANCE operation. + 2011-03-10 Ingo Weinzierl * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java: diff -r b5e1949bc255 -r 5c93fb142970 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:26:08 2011 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Thu Mar 10 10:32:51 2011 +0000 @@ -143,6 +143,51 @@ /** + * This method creates a new ADVANCE document. + * + * @param theUuid The identifier of the artifact. + * @param theHash The hash of the artifact. + * @param theTarget The target state identifier. + * + * @return the ADVANCE document. + */ + public static Document newAdvanceDocument( + String theUuid, + String theHash, + String theTarget) + { + 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 target = cr.create("target"); + + // 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", "advance", false); + cr.addAttr(uuid, "value", theUuid, true); + cr.addAttr(hash, "value", theHash, true); + cr.addAttr(target, "name", theTarget, true); + + action.appendChild(type); + action.appendChild(uuid); + action.appendChild(hash); + action.appendChild(target); + + doc.appendChild(action); + + return doc; + } + + + /** * This method creates a new document that is used to create new artifact * collections in the artifact server. *