changeset 118:888e3b1dcdd9

Added a RiverService (/service/rivers) that retrieves a list of provided rivers. flys-artifacts/trunk@1429 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 08 Mar 2011 17:22:37 +0000
parents 1a025ff0f7fd
children 84c0b151203e
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/RiverService.java
diffstat 3 files changed, 80 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Mar 07 14:43:14 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Mar 08 17:22:37 2011 +0000
@@ -1,3 +1,10 @@
+2011-03-08  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/services/RiverService.java:
+	  New. This service will retrieve a list of provided rivers.
+
+	* doc/conf/conf.xml: Added a configuration for the RiverService.
+
 2011-03-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/conf.xml: Added a section user-factory and collection-factory in
--- a/flys-artifacts/doc/conf/conf.xml	Mon Mar 07 14:43:14 2011 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Tue Mar 08 17:22:37 2011 +0000
@@ -18,6 +18,14 @@
         </artifact-factories>
 
         <user-factory name="default" description="Factory to create new users">de.intevation.artifactdatabase.DefaultUserFactory</user-factory>
+
+        <service-factories>
+            <service-factory
+                name="rivers"
+                service="de.intevation.flys.artifacts.services.RiverService"
+                description="This service returns a list of provided rivers by the artifact server.">de.intevation.artifactdatabase.DefaultServiceFactory</service-factory>
+        </service-factories>
+
     </factories>
 
     <artifacts>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/RiverService.java	Tue Mar 08 17:22:37 2011 +0000
@@ -0,0 +1,65 @@
+package de.intevation.flys.artifacts.services;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import de.intevation.artifacts.CallMeta;
+
+import de.intevation.artifacts.common.ArtifactNamespaceContext;
+import de.intevation.artifacts.common.utils.XMLUtils;
+
+import de.intevation.artifactdatabase.DefaultService;
+
+
+/**
+ * This service provides information about the supported rivers by this
+ * application.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class RiverService extends DefaultService {
+
+    /** The logger used in this service.*/
+    private static Logger logger = Logger.getLogger(RiverService.class);
+
+
+    /**
+     * The default constructor.
+     */
+    public RiverService() {
+    }
+
+
+    public Document process(
+        Document data,
+        Object   globalContext,
+        CallMeta callMeta)
+    {
+        logger.debug("RiverService.process");
+
+        Document result = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            result,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        // TODO fetch the rivers from database
+        Element rivers = ec.create("rivers");
+
+        Element saar = ec.create("river");
+        ec.addAttr(saar, "name", "Saar", true);
+
+        Element mosel = ec.create("river");
+        ec.addAttr(mosel, "name", "Mosel", true);
+
+        rivers.appendChild(saar);
+        rivers.appendChild(mosel);
+        result.appendChild(rivers);
+
+        return result;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org