annotate flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java @ 816:dc7b1ba05cd4

Removed superfluous imports. flys-client/trunk@2472 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 08 Aug 2011 17:00:32 +0000
parents 70b728a9f4e8
children bd56dc762e7f
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
811
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
32 public DataCageTree getMetaData(
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
33 String url,
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
34 String locale,
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
35 String artifactId,
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
36 String userId
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
37 ) throws ServerException
262
44a340c9becc Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 {
812
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
39 System.out.println("MetaDataService.getMetaData");
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
40
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
41 Document doc = XMLUtils.newDocument();
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
42
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
43 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
44 doc,
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
45 ArtifactNamespaceContext.NAMESPACE_URI,
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
46 ArtifactNamespaceContext.NAMESPACE_PREFIX);
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
47
812
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
48 Element meta = ec.create("meta");
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
49
811
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
50 if (artifactId != null) {
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
51 Element artifactEl = ec.create("artifact-id");
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
52 artifactEl.setAttribute("value", artifactId);
812
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
53 meta.appendChild(artifactEl);
811
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
54 }
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
55
811
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
56 if (userId != null) {
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
57 Element userEl = ec.create("user-id");
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
58 userEl.setAttribute("value", userId);
812
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
59 meta.appendChild(userEl);
811
8fa303586f14 Pass user id to the meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 615
diff changeset
60 }
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
61
812
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
62 doc.appendChild(meta);
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
63
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
64 HttpClient client = new HttpClientImpl(url, locale);
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
65
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
66 try {
286
0fa8bf8a2295 Datacage: Better converter for incoming XML tree
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 278
diff changeset
67 Converter converter = new Converter();
0fa8bf8a2295 Datacage: Better converter for incoming XML tree
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 278
diff changeset
68 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
69 }
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
70 catch (ConnectionException ce) {
812
70b728a9f4e8 Meta data service: Create correct request document now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 811
diff changeset
71 ce.printStackTrace();
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
72 }
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
73
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 262
diff changeset
74 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
75 }
44a340c9becc Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 }
44a340c9becc Added stub for meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org