Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/server/GetArtifactServiceImpl.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/GetArtifactServiceImpl.java@bc06a671ef60 |
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 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | |
8 | |
9 import de.intevation.artifacts.common.ArtifactNamespaceContext; | |
10 import de.intevation.artifacts.common.utils.ClientProtocolUtils; | |
11 import de.intevation.artifacts.common.utils.XMLUtils; | |
12 | |
13 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | |
14 import de.intevation.artifacts.httpclient.http.HttpClient; | |
15 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
16 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; | |
17 | |
18 import de.intevation.flys.client.shared.exceptions.ServerException; | |
19 import de.intevation.flys.client.shared.model.Artifact; | |
20 import de.intevation.flys.client.client.services.GetArtifactService; | |
21 | |
22 | |
23 /** | |
24 * This service provides a method that returns an artifact based on its | |
25 * identifier. | |
26 * | |
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
28 */ | |
29 public class GetArtifactServiceImpl | |
30 extends RemoteServiceServlet | |
31 implements GetArtifactService | |
32 { | |
33 private static final Logger logger = | |
34 Logger.getLogger(GetArtifactServiceImpl.class); | |
35 | |
36 | |
37 public static final String ERROR_DESCRIBE_ARTIFACT = | |
38 "error_describe_artifact"; | |
39 | |
40 public static final String XPATH_RESULT = "/art:result/text()"; | |
41 | |
42 public static final String OPERATION_FAILURE = "FAILED"; | |
43 | |
44 | |
45 public Artifact getArtifact( | |
46 String locale, | |
47 String uuid, | |
48 String hash) | |
49 throws ServerException | |
50 { | |
51 logger.info("GetArtifactServiceImpl.getArtifact"); | |
52 | |
53 String url = getServletContext().getInitParameter("server-url"); | |
54 | |
55 Document describe = ClientProtocolUtils.newDescribeDocument( | |
56 uuid, hash, true); | |
57 | |
58 HttpClient client = new HttpClientImpl(url, locale); | |
59 | |
60 try { | |
61 Document description = (Document) client.describe( | |
62 new de.intevation.artifacts.httpclient.objects.Artifact( | |
63 uuid, hash), | |
64 describe, | |
65 new DocumentResponseHandler()); | |
66 | |
67 if (description == null) { | |
68 throw new ServerException(ERROR_DESCRIBE_ARTIFACT); | |
69 } | |
70 | |
71 String result = XMLUtils.xpathString( | |
72 description, | |
73 XPATH_RESULT, | |
74 ArtifactNamespaceContext.INSTANCE); | |
75 | |
76 if (result == null || !result.equals(OPERATION_FAILURE)) { | |
77 return (Artifact) new FLYSArtifactCreator().create(description); | |
78 } | |
79 } | |
80 catch (ConnectionException ce) { | |
81 logger.error(ce, ce); | |
82 } | |
83 | |
84 throw new ServerException(ERROR_DESCRIBE_ARTIFACT); | |
85 } | |
86 } | |
87 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |