diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java	Wed Feb 16 15:26:38 2011 +0000
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011 by Intevation GmbH
+ *
+ * This program is free software under the LGPL (>=v2.1)
+ * Read the file LGPL.txt coming with the software for details
+ * or visit http://www.gnu.org/licenses/ if it does not exist.
+ */
+package de.intevation.artifacts.common.utils;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import de.intevation.artifacts.common.ArtifactNamespaceContext;
+
+
+/**
+ * This class provides methods that help creating the artifact protocol
+ * documents DESCRIBE, FEED, ADVANCE and OUT.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class ClientProtocolUtils {
+
+    /**
+     * It should not be necessary to create instances of this class.
+     */
+    private ClientProtocolUtils() {
+    }
+
+
+    /**
+     * This method creates a new CREATE document.
+     *
+     * @return the CREATE document.
+     */
+    public static Document newCreateDocument(String factory) {
+        Document doc = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element action = cr.create("action");
+        Element type   = cr.create("type");
+        Element fac    = cr.create("factory");
+
+        type.setAttribute("name", "create");
+        fac.setAttribute("name", factory);
+
+        action.appendChild(type);
+        action.appendChild(fac);
+
+        doc.appendChild(action);
+
+        return doc;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org