Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/DoCollectionAction.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/DoCollectionAction.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.XMLUtils; | |
11 | |
12 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; | |
13 import org.dive4elements.artifacts.httpclient.http.HttpClient; | |
14 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; | |
15 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler; | |
16 | |
17 import org.dive4elements.river.client.shared.exceptions.ServerException; | |
18 import org.dive4elements.river.client.shared.model.Collection; | |
19 | |
20 | |
21 /** | |
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
23 */ | |
24 public class DoCollectionAction extends RemoteServiceServlet { | |
25 | |
26 private static final Logger logger = | |
27 Logger.getLogger(DoCollectionAction.class); | |
28 | |
29 | |
30 public static final String XPATH_RESULT = "/art:result/text()"; | |
31 public static final String OPERATION_FAILURE = "FAILED"; | |
32 public static final String FAILURE_EXCEPTION = "collection_action_failed"; | |
33 | |
34 | |
35 protected void doAction(Collection c, Document action, String url) | |
36 throws ServerException | |
37 { | |
38 logger.info("DoCollectionAction.doAction"); | |
39 | |
40 HttpClient client = new HttpClientImpl(url); | |
41 | |
42 try { | |
43 Document res = (Document) client.doCollectionAction( | |
44 action, c.identifier(), | |
45 new DocumentResponseHandler()); | |
46 | |
47 String result = XMLUtils.xpathString( | |
48 res, | |
49 XPATH_RESULT, | |
50 ArtifactNamespaceContext.INSTANCE); | |
51 | |
52 if (result == null || result.equals(OPERATION_FAILURE)) { | |
53 logger.error("Operation failed."); | |
54 throw new ServerException(FAILURE_EXCEPTION); | |
55 } | |
56 } | |
57 catch (ConnectionException ce) { | |
58 logger.error(ce, ce); | |
59 throw new ServerException(FAILURE_EXCEPTION); | |
60 } | |
61 } | |
62 } |