Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/AdvanceServiceImpl.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/server/AdvanceServiceImpl.java@821a02bbfb4e |
children | 172338b1407f |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.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 org.dive4elements.artifacts.common.ArtifactNamespaceContext; | |
10 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; | |
11 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
12 | |
13 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; | |
14 import org.dive4elements.artifacts.httpclient.http.HttpClient; | |
15 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; | |
16 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler; | |
17 | |
18 import org.dive4elements.river.client.shared.exceptions.ServerException; | |
19 import org.dive4elements.river.client.shared.model.Artifact; | |
20 import org.dive4elements.river.client.client.services.AdvanceService; | |
21 | |
22 | |
23 /** | |
24 * This interface provides artifact specific operation ADVANCE. | |
25 * | |
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
27 */ | |
28 public class AdvanceServiceImpl | |
29 extends RemoteServiceServlet | |
30 implements AdvanceService | |
31 { | |
32 private static final Logger logger = Logger.getLogger(AdvanceService.class); | |
33 | |
34 public static final String XPATH_RESULT = "/art:result/text()"; | |
35 | |
36 public static final String OPERATION_FAILURE = "FAILED"; | |
37 | |
38 public static final String ERROR_ADVANCE_ARTIFACT = "error_advance_artifact"; | |
39 | |
40 | |
41 public Artifact advance( | |
42 String locale, | |
43 Artifact artifact, | |
44 String target) | |
45 throws ServerException | |
46 { | |
47 logger.info("AdvanceServiceImpl.advance"); | |
48 | |
49 String url = getServletContext().getInitParameter("server-url"); | |
50 | |
51 Document advance = ClientProtocolUtils.newAdvanceDocument( | |
52 artifact.getUuid(), | |
53 artifact.getHash(), | |
54 target); | |
55 | |
56 HttpClient client = new HttpClientImpl(url, locale); | |
57 | |
58 try { | |
59 Document description = (Document) client.advance( | |
60 new org.dive4elements.artifacts.httpclient.objects.Artifact( | |
61 artifact.getUuid(), | |
62 artifact.getHash()), | |
63 advance, | |
64 new DocumentResponseHandler()); | |
65 | |
66 if (description == null) { | |
67 throw new ServerException(ERROR_ADVANCE_ARTIFACT); | |
68 } | |
69 | |
70 String result = XMLUtils.xpathString( | |
71 description, | |
72 XPATH_RESULT, | |
73 ArtifactNamespaceContext.INSTANCE); | |
74 | |
75 if (result == null || !result.equals(OPERATION_FAILURE)) { | |
76 return (Artifact) new FLYSArtifactCreator().create(description); | |
77 } | |
78 } | |
79 catch (ConnectionException ce) { | |
80 logger.error(ce, ce); | |
81 } | |
82 | |
83 throw new ServerException(ERROR_ADVANCE_ARTIFACT); | |
84 } | |
85 } | |
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |