Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/server/MetaDataServiceImpl.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java@2dac0e5b927e |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.client.server; | |
2 | |
3 import org.w3c.dom.Document; | |
4 import org.w3c.dom.Element; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | |
9 | |
10 import de.intevation.artifacts.common.ArtifactNamespaceContext; | |
11 | |
12 import de.intevation.artifacts.common.utils.XMLUtils; | |
13 | |
14 import de.intevation.flys.client.shared.exceptions.ServerException; | |
15 | |
16 import de.intevation.flys.client.client.services.MetaDataService; | |
17 | |
18 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | |
19 | |
20 import de.intevation.artifacts.httpclient.http.HttpClient; | |
21 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
22 | |
23 import de.intevation.flys.client.shared.model.DataCageTree; | |
24 | |
25 import de.intevation.flys.client.server.meta.Converter; | |
26 | |
27 /** | |
28 * Service that returns certain meta-data from the backends data, polished to | |
29 * inclusion into current project. | |
30 */ | |
31 public class MetaDataServiceImpl | |
32 extends RemoteServiceServlet | |
33 implements MetaDataService | |
34 { | |
35 /** Our very own logger. */ | |
36 private static final Logger logger = | |
37 Logger.getLogger(MetaDataServiceImpl.class); | |
38 | |
39 public static final String ERROR_NO_META_DATA_FOUND = | |
40 "error_no_meta_data_found"; | |
41 | |
42 | |
43 /** | |
44 * @param locale needed for i18n. | |
45 * @param artifactId ID of masterartifact (can be null) | |
46 * @param userId can be null | |
47 * @param outs can be null | |
48 * @param parameters can be null or parameters like "load-system:true;key:value" | |
49 */ | |
50 @Override | |
51 public DataCageTree getMetaData( | |
52 String locale, | |
53 String artifactId, | |
54 String userId, | |
55 String outs, | |
56 String parameters | |
57 ) throws ServerException | |
58 { | |
59 logger.info("MetaDataService.getMetaData"); | |
60 | |
61 // Create the query document. | |
62 String url = getServletContext().getInitParameter("server-url"); | |
63 | |
64 Document doc = XMLUtils.newDocument(); | |
65 | |
66 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( | |
67 doc, | |
68 ArtifactNamespaceContext.NAMESPACE_URI, | |
69 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
70 | |
71 Element meta = ec.create("meta"); | |
72 | |
73 if (artifactId != null) { | |
74 Element artifactEl = ec.create("artifact-id"); | |
75 artifactEl.setAttribute("value", artifactId); | |
76 meta.appendChild(artifactEl); | |
77 } | |
78 | |
79 if (userId != null) { | |
80 Element userEl = ec.create("user-id"); | |
81 userEl.setAttribute("value", userId); | |
82 meta.appendChild(userEl); | |
83 } | |
84 | |
85 if (outs != null) { | |
86 Element outsEl = ec.create("outs"); | |
87 outsEl.setAttribute("value", outs); | |
88 meta.appendChild(outsEl); | |
89 } | |
90 | |
91 if (parameters != null) { | |
92 Element paramsEl = ec.create("parameters"); | |
93 paramsEl.setAttribute("value", parameters); | |
94 meta.appendChild(paramsEl); | |
95 } | |
96 | |
97 doc.appendChild(meta); | |
98 | |
99 // Fire. | |
100 HttpClient client = new HttpClientImpl(url, locale); | |
101 | |
102 try { | |
103 Converter converter = new Converter(); | |
104 return converter.convert(client.callService(url, "metadata", doc)); | |
105 } | |
106 catch (ConnectionException ce) { | |
107 ce.printStackTrace(); | |
108 } | |
109 | |
110 throw new ServerException(ERROR_NO_META_DATA_FOUND); | |
111 } | |
112 } | |
113 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |