[Dive4elements-commits] [PATCH] Add ServerInfoService (currently inactive)

Wald Commits scm-commit at wald.intevation.org
Wed Jun 26 23:07:30 CEST 2013


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1372280844 -7200
# Node ID 41152c3a532d63a25e9fa348ca4286bdd76069ef
# Parent  0624d3a0a63ec5b88982e7fdc9e51c73d14bb1ab
Add ServerInfoService (currently inactive).

diff -r 0624d3a0a63e -r 41152c3a532d artifacts/src/main/java/org/dive4elements/river/artifacts/services/ServerInfoService.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/ServerInfoService.java	Wed Jun 26 23:07:24 2013 +0200
@@ -0,0 +1,56 @@
+package org.dive4elements.river.artifacts.services;
+
+import javax.xml.xpath.XPathConstants;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.artifacts.GlobalContext;
+import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
+import org.dive4elements.artifacts.common.utils.Config;
+import org.dive4elements.artifacts.common.utils.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Through this service the client can retrieve basic information about or
+ * configuration of the artifact server.
+ * Currently it only returns the help-url (wiki) to the client.
+ *
+ * @author <a href="mailto:christian.lins at intevation.de">Christian Lins</a>
+ */
+public class ServerInfoService extends D4EService {
+
+    /** The logger used in this service.*/
+    private static Logger logger = Logger.getLogger(ServerInfoService.class);
+
+    private static final String XPATH_HELP_URL = "/artifact-database/help-url/text()";
+
+    @Override
+    protected Document doProcess(Document data, GlobalContext globalContext,
+            CallMeta callMeta) {
+        logger.debug("ServerInfoService.process");
+
+        Document result = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            result,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element serverInfo = ec.create("server");
+
+        String helpUrl = (String) XMLUtils.xpath(
+                Config.getConfig(),
+                XPATH_HELP_URL,
+                XPathConstants.STRING);
+
+        Element info = ec.create("info");
+        ec.addAttr(info, "key", "help-url", true);
+        ec.addAttr(info, "value", helpUrl, true);
+
+        result.appendChild(serverInfo);
+
+        return result;
+    }
+
+}


More information about the Dive4elements-commits mailing list