comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 255:efbad8c5c0e5

Improved the ClientProtocolUtils - new function to create a document that is used to set the attribute of a CollectionItem. artifacts/trunk@1753 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 28 Apr 2011 08:10:03 +0000
parents c0bc172ec7b2
children c41b300b02c3
comparison
equal deleted inserted replaced
254:6cf9560bd249 255:efbad8c5c0e5
368 return doc; 368 return doc;
369 } 369 }
370 370
371 371
372 /** 372 /**
373 * This function creates a document that is used to set the attribute of a
374 * CollectionItem.
375 *
376 * @param uuid The identifier of the CollectionItem.
377 * @param attr The new attribute value for the CollectionItem.
378 *
379 * @return the document that is used to set the attribute.
380 */
381 public static Document newSetItemAttributeDocument(
382 String uuid,
383 Document attr)
384 {
385 Node root = attr.getFirstChild();
386
387 if (root == null) {
388 return null;
389 }
390
391 Document doc = XMLUtils.newDocument();
392
393 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
394 doc,
395 ArtifactNamespaceContext.NAMESPACE_URI,
396 ArtifactNamespaceContext.NAMESPACE_PREFIX);
397
398 Element action = ec.create("action");
399 Element type = ec.create("type");
400 Element artifact = ec.create("artifact");
401
402 ec.addAttr(type, "name", "setitemattribute");
403 ec.addAttr(artifact, "uuid", uuid);
404
405 doc.appendChild(action);
406 action.appendChild(type);
407 type.appendChild(artifact);
408
409 artifact.appendChild(doc.importNode(root, true));
410
411 return doc;
412 }
413
414
415 /**
373 * Returns string value found by {@link XPATH_LABEL} relative to 416 * Returns string value found by {@link XPATH_LABEL} relative to
374 * <i>node</i>. 417 * <i>node</i>.
375 * 418 *
376 * @param node A node. 419 * @param node A node.
377 * 420 *

http://dive4elements.wald.intevation.org