comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 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 8ce06db80857
children 5c93fb142970
comparison
equal deleted inserted replaced
202:c03d3a872cd2 203:b5e1949bc255
88 return doc; 88 return doc;
89 } 89 }
90 90
91 91
92 /** 92 /**
93 * This method creates a new FEED document.
94 *
95 * @param theUuid The identifier of the artifact.
96 * @param theHash The hash of the artifact.
97 * @param theData An array that contains key/value pairs that represent the
98 * data that should be included in the FEED document.
99 *
100 * @return the FEED document.
101 */
102 public static Document newFeedDocument(
103 String theUuid,
104 String theHash,
105 String[][] theData)
106 {
107 Document doc = XMLUtils.newDocument();
108
109 XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator(
110 doc,
111 ArtifactNamespaceContext.NAMESPACE_URI,
112 ArtifactNamespaceContext.NAMESPACE_PREFIX);
113
114 Element action = cr.create("action");
115 Element type = cr.create("type");
116 Element uuid = cr.create("uuid");
117 Element hash = cr.create("hash");
118 Element data = cr.create("data");
119
120 // XXX It is not nice that the type has no attribute namespace, but to
121 // be backward compatible, we don't change this now.
122 cr.addAttr(type, "name", "feed", false);
123 cr.addAttr(uuid, "value", theUuid, true);
124 cr.addAttr(hash, "value", theHash, true);
125
126 for (String[] kvp: theData) {
127 Element input = cr.create("input");
128 cr.addAttr(input, "name", kvp[0], true);
129 cr.addAttr(input, "value", kvp[1], true);
130
131 data.appendChild(input);
132 }
133
134 action.appendChild(type);
135 action.appendChild(uuid);
136 action.appendChild(hash);
137 action.appendChild(data);
138
139 doc.appendChild(action);
140
141 return doc;
142 }
143
144
145 /**
93 * This method creates a new document that is used to create new artifact 146 * This method creates a new document that is used to create new artifact
94 * collections in the artifact server. 147 * collections in the artifact server.
95 * 148 *
96 * @param name <b>Optional</b> name of the collection. 149 * @param name <b>Optional</b> name of the collection.
97 * 150 *

http://dive4elements.wald.intevation.org