comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 267:72de5c373c9b

Enhanced the ClientProtocolUtils with a method to create a document that sets the attribute of a collection. artifacts/trunk@2014 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 27 May 2011 08:11:34 +0000
parents f3d970a832ff
children 89f6de49803d
comparison
equal deleted inserted replaced
266:c42a07be9aee 267:72de5c373c9b
405 } 405 }
406 406
407 407
408 /** 408 /**
409 * This function creates a document that is used to set the attribute of a 409 * This function creates a document that is used to set the attribute of a
410 * Collection.
411 *
412 * @param uuid The identifier of the Collection.
413 * @param attr The new attribute value for the Collection.
414 *
415 * @return the document that is used to set the attribute.
416 */
417 public static Document newSetAttributeDocument(
418 String uuid,
419 Document attr)
420 {
421 Node root = attr != null ? attr.getFirstChild() : null;
422
423 if (root == null) {
424 return null;
425 }
426
427 Document doc = XMLUtils.newDocument();
428
429 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
430 doc,
431 ArtifactNamespaceContext.NAMESPACE_URI,
432 ArtifactNamespaceContext.NAMESPACE_PREFIX);
433
434 Element action = ec.create("action");
435 Element type = ec.create("type");
436 Element collection = ec.create("collection");
437
438 ec.addAttr(type, "name", "setattribute", false);
439 ec.addAttr(collection, "uuid", uuid, false);
440
441 doc.appendChild(action);
442 action.appendChild(type);
443 type.appendChild(collection);
444
445 collection.appendChild(doc.importNode(root, true));
446
447 return doc;
448 }
449
450 /**
451 * This function creates a document that is used to set the attribute of a
410 * CollectionItem. 452 * CollectionItem.
411 * 453 *
412 * @param uuid The identifier of the CollectionItem. 454 * @param uuid The identifier of the CollectionItem.
413 * @param attr The new attribute value for the CollectionItem. 455 * @param attr The new attribute value for the CollectionItem.
414 * 456 *

http://dive4elements.wald.intevation.org