Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java @ 581:210339fd1a34
Removed more expensive XPath.
flys-client/trunk@2169 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 20 Jun 2011 16:25:48 +0000 |
parents | 2e02db03e576 |
children | ba1b27b7d282 |
rev | line source |
---|---|
262
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
3 import org.w3c.dom.Document; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
4 import org.w3c.dom.Element; |
262
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
8 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
9 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
10 import de.intevation.artifacts.common.utils.XMLUtils; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
11 |
262
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.client.shared.exceptions.ServerException; |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.client.client.services.MetaDataService; |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
16 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
17 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
18 import de.intevation.artifacts.httpclient.http.HttpClient; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
19 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
20 |
278
f33af25b7490
Datacage: transport rpc result to ui.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
276
diff
changeset
|
21 import de.intevation.flys.client.shared.model.DataCageTree; |
f33af25b7490
Datacage: transport rpc result to ui.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
276
diff
changeset
|
22 |
286
0fa8bf8a2295
Datacage: Better converter for incoming XML tree
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
278
diff
changeset
|
23 import de.intevation.flys.client.server.meta.Converter; |
0fa8bf8a2295
Datacage: Better converter for incoming XML tree
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
278
diff
changeset
|
24 |
262
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public class MetaDataServiceImpl |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 extends RemoteServiceServlet |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 implements MetaDataService |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 { |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
29 public static final String ERROR_NO_META_DATA_FOUND = |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
30 "error_no_meta_data_found"; |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
31 |
278
f33af25b7490
Datacage: transport rpc result to ui.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
276
diff
changeset
|
32 public DataCageTree getMetaData(String url, String locale, String river) |
262
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 throws ServerException |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 { |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
35 System.out.println("MetaDataService.getDistanceInfo"); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
36 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
37 Document doc = XMLUtils.newDocument(); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
38 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
39 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
40 doc, |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
41 ArtifactNamespaceContext.NAMESPACE_URI, |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
42 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
43 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
44 Element riverEl = ec.create("river"); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
45 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
46 riverEl.setTextContent(river); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
47 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
48 doc.appendChild(riverEl); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
49 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
50 HttpClient client = new HttpClientImpl(url, locale); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
51 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
52 try { |
286
0fa8bf8a2295
Datacage: Better converter for incoming XML tree
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
278
diff
changeset
|
53 Converter converter = new Converter(); |
0fa8bf8a2295
Datacage: Better converter for incoming XML tree
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
278
diff
changeset
|
54 return converter.convert(client.callService(url, "metadata", doc)); |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
55 } |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
56 catch (ConnectionException ce) { |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
57 System.err.println(ce.getLocalizedMessage()); |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
58 } |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
59 |
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
60 throw new ServerException(ERROR_NO_META_DATA_FOUND); |
262
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
44a340c9becc
Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |