comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 341:e0efa2c28d19

Helper function to create a document to remove an artifact from an collection. artifacts/trunk@2958 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 13 Oct 2011 12:19:43 +0000
parents 4022ea69d1cb
children 6431b7efe240
comparison
equal deleted inserted replaced
340:560d2e6eaf9c 341:e0efa2c28d19
23 * 23 *
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
25 */ 25 */
26 public class ClientProtocolUtils { 26 public class ClientProtocolUtils {
27 27
28 /** The XPath to the current state in the DESCRIBE document.*/ 28 /** The XPath to the current state in the DESCRIBE document. */
29 public static final String XPATH_CURRENT_STATE = "/art:result/art:state"; 29 public static final String XPATH_CURRENT_STATE = "/art:result/art:state";
30 30
31 /** The XPath to the static UI part in the DESCRIBE document.*/ 31 /** The XPath to the static UI part in the DESCRIBE document. */
32 public static final String XPATH_STATIC = "/art:result/art:ui/art:static"; 32 public static final String XPATH_STATIC = "/art:result/art:ui/art:static";
33 33
34 /** The XPath to the dynamic UI part in the DESCRIBE document.*/ 34 /** The XPath to the dynamic UI part in the DESCRIBE document. */
35 public static final String XPATH_DYNAMIC = "/art:result/art:ui/art:dynamic"; 35 public static final String XPATH_DYNAMIC = "/art:result/art:ui/art:dynamic";
36 36
37 /** The XPath to the reachable states part in the DESCRIBE document.*/ 37 /** The XPath to the reachable states part in the DESCRIBE document. */
38 public static final String XPATH_STATES = 38 public static final String XPATH_STATES =
39 "/art:result/art:reachable-states"; 39 "/art:result/art:reachable-states";
40 40
41 /** The XPath to the output modes in the DESCRIBE document.*/ 41 /** The XPath to the output modes in the DESCRIBE document. */
42 public static final String XPATH_OUTPUT_MODES = 42 public static final String XPATH_OUTPUT_MODES =
43 "/art:result/art:outputmodes/art:output"; 43 "/art:result/art:outputmodes/art:output";
44 44
45 45
46 /** The XPath to the select node relative to the dynamic UI node in the 46 /** The XPath to the select node relative to the dynamic UI node in the
47 * DESCRIBE document.*/ 47 * DESCRIBE document. */
48 public static final String XPATH_DATA_SELECT = "art:select"; 48 public static final String XPATH_DATA_SELECT = "art:select";
49 49
50 /** The XPath to the choices nodes relative to the select node in the 50 /** The XPath to the choices nodes relative to the select node in the
51 * DESCRIBE document.*/ 51 * DESCRIBE document. */
52 public static final String XPATH_DATA_ITEMS = "art:choices/art:item"; 52 public static final String XPATH_DATA_ITEMS = "art:choices/art:item";
53 53
54 /** The XPath to a label in the artifact's DESCRIBE document.*/ 54 /** The XPath to a label in the artifact's DESCRIBE document. */
55 public static final String XPATH_LABEL = "art:label/text()"; 55 public static final String XPATH_LABEL = "art:label/text()";
56 56
57 /** The XPath to a value in the artifact's DESCRIBE document.*/ 57 /** The XPath to a value in the artifact's DESCRIBE document. */
58 public static final String XPATH_VALUE = "art:value/text()"; 58 public static final String XPATH_VALUE = "art:value/text()";
59 59
60 60
61 /** 61 /**
62 * It should not be necessary to create instances of this class. 62 * It should not be necessary to create instances of this class.
323 /** 323 /**
324 * This method creates a new Document that is used to add an artifact to a 324 * This method creates a new Document that is used to add an artifact to a
325 * collection in the artifact server. 325 * collection in the artifact server.
326 * 326 *
327 * @param artId The identifier of the artifact that should be added. 327 * @param artId The identifier of the artifact that should be added.
328 * @param attr A document that contains attributes for the attribute's 328 * @param attr A document that contains attributes for the artifact's
329 * life in the collection. 329 * life in the collection.
330 * 330 *
331 * @return the document to add an artifact into a collection. 331 * @return the document to add an artifact into a collection.
332 */ 332 */
333 public static Document newAddArtifactDocument(String artId, Document attr) { 333 public static Document newAddArtifactDocument(String artId, Document attr) {
351 } 351 }
352 352
353 action.appendChild(type); 353 action.appendChild(type);
354 type.appendChild(artifact); 354 type.appendChild(artifact);
355 artifact.appendChild(attribute); 355 artifact.appendChild(attribute);
356
357 doc.appendChild(action);
358
359 return doc;
360 }
361
362
363 /**
364 * Create a new Document that is used to remove an artifact from a
365 * collection in the artifact server.
366 *
367 * @param artId The identifier of the artifact that should be added.
368 *
369 * @return the document to add an artifact into a collection.
370 */
371 public static Document newRemoveArtifactDocument(String artId) {
372 Document doc = XMLUtils.newDocument();
373
374 XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator(
375 doc,
376 ArtifactNamespaceContext.NAMESPACE_URI,
377 ArtifactNamespaceContext.NAMESPACE_PREFIX);
378
379 Element action = cr.create("action");
380 Element type = cr.create("type");
381 Element artifact = cr.create("artifact");
382
383 cr.addAttr(artifact, "uuid", artId);
384 cr.addAttr(type, "name", "removeartifact");
385
386 action.appendChild(type);
387 type.appendChild(artifact);
356 388
357 doc.appendChild(action); 389 doc.appendChild(action);
358 390
359 return doc; 391 return doc;
360 } 392 }

http://dive4elements.wald.intevation.org