comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java @ 113:0344a20f8a93

Added the ArtifactNamespaceContext and a ClientProtocolUtils that helps working with the artifact protocol. artifacts/trunk@1318 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 16 Feb 2011 15:26:38 +0000
parents
children 19b86e27d0c3
comparison
equal deleted inserted replaced
112:2f35e8a84004 113:0344a20f8a93
1 /*
2 * Copyright (c) 2011 by Intevation GmbH
3 *
4 * This program is free software under the LGPL (>=v2.1)
5 * Read the file LGPL.txt coming with the software for details
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
7 */
8 package de.intevation.artifacts.common.utils;
9
10 import org.w3c.dom.Document;
11 import org.w3c.dom.Element;
12
13 import de.intevation.artifacts.common.ArtifactNamespaceContext;
14
15
16 /**
17 * This class provides methods that help creating the artifact protocol
18 * documents DESCRIBE, FEED, ADVANCE and OUT.
19 *
20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
21 */
22 public class ClientProtocolUtils {
23
24 /**
25 * It should not be necessary to create instances of this class.
26 */
27 private ClientProtocolUtils() {
28 }
29
30
31 /**
32 * This method creates a new CREATE document.
33 *
34 * @return the CREATE document.
35 */
36 public static Document newCreateDocument(String factory) {
37 Document doc = XMLUtils.newDocument();
38
39 XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator(
40 doc,
41 ArtifactNamespaceContext.NAMESPACE_URI,
42 ArtifactNamespaceContext.NAMESPACE_PREFIX);
43
44 Element action = cr.create("action");
45 Element type = cr.create("type");
46 Element fac = cr.create("factory");
47
48 type.setAttribute("name", "create");
49 fac.setAttribute("name", factory);
50
51 action.appendChild(type);
52 action.appendChild(fac);
53
54 doc.appendChild(action);
55
56 return doc;
57 }
58 }
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org