comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/ServerInfoService.java @ 6457:41152c3a532d 3.0.9

Add ServerInfoService (currently inactive).
author Christian Lins <christian.lins@intevation.de>
date Wed, 26 Jun 2013 23:07:24 +0200
parents
children d30ae7275e5a
comparison
equal deleted inserted replaced
6456:0624d3a0a63e 6457:41152c3a532d
1 package org.dive4elements.river.artifacts.services;
2
3 import javax.xml.xpath.XPathConstants;
4
5 import org.apache.log4j.Logger;
6 import org.dive4elements.artifacts.CallMeta;
7 import org.dive4elements.artifacts.GlobalContext;
8 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
9 import org.dive4elements.artifacts.common.utils.Config;
10 import org.dive4elements.artifacts.common.utils.XMLUtils;
11 import org.w3c.dom.Document;
12 import org.w3c.dom.Element;
13
14 /**
15 * Through this service the client can retrieve basic information about or
16 * configuration of the artifact server.
17 * Currently it only returns the help-url (wiki) to the client.
18 *
19 * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a>
20 */
21 public class ServerInfoService extends D4EService {
22
23 /** The logger used in this service.*/
24 private static Logger logger = Logger.getLogger(ServerInfoService.class);
25
26 private static final String XPATH_HELP_URL = "/artifact-database/help-url/text()";
27
28 @Override
29 protected Document doProcess(Document data, GlobalContext globalContext,
30 CallMeta callMeta) {
31 logger.debug("ServerInfoService.process");
32
33 Document result = XMLUtils.newDocument();
34
35 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
36 result,
37 ArtifactNamespaceContext.NAMESPACE_URI,
38 ArtifactNamespaceContext.NAMESPACE_PREFIX);
39
40 Element serverInfo = ec.create("server");
41
42 String helpUrl = (String) XMLUtils.xpath(
43 Config.getConfig(),
44 XPATH_HELP_URL,
45 XPathConstants.STRING);
46
47 Element info = ec.create("info");
48 ec.addAttr(info, "key", "help-url", true);
49 ec.addAttr(info, "value", helpUrl, true);
50
51 result.appendChild(serverInfo);
52
53 return result;
54 }
55
56 }

http://dive4elements.wald.intevation.org