annotate flys-client/src/main/java/de/intevation/flys/client/server/GetArtifactServiceImpl.java @ 1380:2d617c48ca5f

Issue 400. Iterate over a list of all theme settings to display all available settings. flys-client/trunk@3132 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 01 Nov 2011 15:01:37 +0000
parents ab8eb2f544f2
children bc06a671ef60
rev   line source
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.w3c.dom.Document;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
5 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
6
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.common.ArtifactNamespaceContext;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.httpclient.http.HttpClient;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.client.shared.exceptions.ServerException;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.client.shared.model.Artifact;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.client.client.services.GetArtifactService;
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 /**
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 * This service provides a method that returns an artifact based on its
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 * identifier.
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 *
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 */
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public class GetArtifactServiceImpl
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 extends RemoteServiceServlet
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 implements GetArtifactService
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
33 private static final Logger logger =
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
34 Logger.getLogger(GetArtifactServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
35
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
36
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public static final String ERROR_DESCRIBE_ARTIFACT =
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 "error_describe_artifact";
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public static final String XPATH_RESULT = "/art:result/text()";
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 public static final String OPERATION_FAILURE = "FAILED";
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
229
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
45 public Artifact getArtifact(
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
46 String url,
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
47 String locale,
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
48 String uuid,
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
49 String hash)
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 throws ServerException
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
52 logger.info("GetArtifactServiceImpl.getArtifact");
229
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
53
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 Document describe = ClientProtocolUtils.newDescribeDocument(
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 uuid, hash, true);
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
229
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 221
diff changeset
57 HttpClient client = new HttpClientImpl(url, locale);
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 try {
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 Document description = (Document) client.describe(
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 new de.intevation.artifacts.httpclient.objects.Artifact(
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 uuid, hash),
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 describe,
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 new DocumentResponseHandler());
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 if (description == null) {
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 throw new ServerException(ERROR_DESCRIBE_ARTIFACT);
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 }
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 String result = XMLUtils.xpathString(
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 description,
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 XPATH_RESULT,
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 ArtifactNamespaceContext.INSTANCE);
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 if (result == null || !result.equals(OPERATION_FAILURE)) {
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 return (Artifact) new FLYSArtifactCreator().create(description);
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 catch (ConnectionException ce) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
80 logger.error(ce, ce);
221
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 }
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 throw new ServerException(ERROR_DESCRIBE_ARTIFACT);
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 }
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 }
f03c34bec364 Added a new service to query an artifact description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org