Mercurial > dive4elements > framework
comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 285:f5a0f90bcc6f
Improved the ClientProtocolUtils: new methods to create collection action specific documents.
artifacts/trunk@2204 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 22 Jun 2011 12:52:24 +0000 |
parents | 89f6de49803d |
children | a367a0d011af |
comparison
equal
deleted
inserted
replaced
284:084d68974d4a | 285:f5a0f90bcc6f |
---|---|
487 return doc; | 487 return doc; |
488 } | 488 } |
489 | 489 |
490 | 490 |
491 /** | 491 /** |
492 * This function creates a document that is used to set the time-to-live | |
493 * of a collection. | |
494 * | |
495 * @param ttl The ttl for the Collection. | |
496 * | |
497 * @return the document that is used to set the time-to-live. | |
498 */ | |
499 public static Document newSetCollectionTTLDocument(String ttl) { | |
500 Document doc = XMLUtils.newDocument(); | |
501 | |
502 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( | |
503 doc, | |
504 ArtifactNamespaceContext.NAMESPACE_URI, | |
505 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
506 | |
507 Element action = ec.create("action"); | |
508 Element type = ec.create("type"); | |
509 Element ttlEl = ec.create("ttl"); | |
510 | |
511 ec.addAttr(type, "name", "settimetolive"); | |
512 ec.addAttr(ttlEl, "value", ttl); | |
513 | |
514 doc.appendChild(action); | |
515 action.appendChild(type); | |
516 type.appendChild(ttlEl); | |
517 | |
518 return doc; | |
519 } | |
520 | |
521 | |
522 /** | |
523 * This function creates a document that is used to set the name of a | |
524 * collection. | |
525 * | |
526 * @param name The name for the Collection. | |
527 * | |
528 * @return the document that is used to set the name of a collection. | |
529 */ | |
530 public static Document newSetCollectionNameDocument(String name) { | |
531 Document doc = XMLUtils.newDocument(); | |
532 | |
533 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( | |
534 doc, | |
535 ArtifactNamespaceContext.NAMESPACE_URI, | |
536 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
537 | |
538 Element action = ec.create("action"); | |
539 Element type = ec.create("type"); | |
540 Element coll = ec.create("collection"); | |
541 | |
542 ec.addAttr(type, "name", "setname"); | |
543 ec.addAttr(coll, "name", name); | |
544 | |
545 doc.appendChild(action); | |
546 action.appendChild(type); | |
547 type.appendChild(coll); | |
548 | |
549 return doc; | |
550 } | |
551 | |
552 | |
553 /** | |
554 * This function creates a document that is used to delete an existing | |
555 * collection. | |
556 * | |
557 * @return the document that is used to delete an existing collection. | |
558 */ | |
559 public static Document newDeleteCollectionDocument() { | |
560 Document doc = XMLUtils.newDocument(); | |
561 | |
562 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( | |
563 doc, | |
564 ArtifactNamespaceContext.NAMESPACE_URI, | |
565 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
566 | |
567 Element action = ec.create("action"); | |
568 Element type = ec.create("type"); | |
569 | |
570 ec.addAttr(type, "name", "delete"); | |
571 | |
572 doc.appendChild(action); | |
573 action.appendChild(type); | |
574 | |
575 return doc; | |
576 } | |
577 | |
578 | |
579 /** | |
492 * Returns string value found by {@link XPATH_LABEL} relative to | 580 * Returns string value found by {@link XPATH_LABEL} relative to |
493 * <i>node</i>. | 581 * <i>node</i>. |
494 * | 582 * |
495 * @param node A node. | 583 * @param node A node. |
496 * | 584 * |