comparison flys-client/src/main/java/de/intevation/flys/client/server/DoCollectionAction.java @ 599:1dbffe4c6d12

Implemented the RPC stubs to set the TTL and name of a collection and to delete an existing collection. flys-client/trunk@2203 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 22 Jun 2011 12:50:20 +0000
parents
children ab8eb2f544f2
comparison
equal deleted inserted replaced
598:031357c3e23e 599:1dbffe4c6d12
1 package de.intevation.flys.client.server;
2
3 import org.w3c.dom.Document;
4
5 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
6
7 import de.intevation.artifacts.common.ArtifactNamespaceContext;
8 import de.intevation.artifacts.common.utils.XMLUtils;
9
10 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
11 import de.intevation.artifacts.httpclient.http.HttpClient;
12 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
13 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
14
15 import de.intevation.flys.client.shared.exceptions.ServerException;
16 import de.intevation.flys.client.shared.model.Collection;
17
18
19 /**
20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
21 */
22 public class DoCollectionAction extends RemoteServiceServlet {
23
24 public static final String XPATH_RESULT = "/art:result/text()";
25 public static final String OPERATION_FAILURE = "FAILED";
26 public static final String FAILURE_EXCEPTION = "collection_action_failed";
27
28
29 protected void doAction(Collection c, Document action, String url)
30 throws ServerException
31 {
32 HttpClient client = new HttpClientImpl(url);
33
34 try {
35 Document res = (Document) client.doCollectionAction(
36 action, c.identifier(),
37 new DocumentResponseHandler());
38
39 String result = XMLUtils.xpathString(
40 res,
41 XPATH_RESULT,
42 ArtifactNamespaceContext.INSTANCE);
43
44 if (result == null || result.equals(OPERATION_FAILURE)) {
45 System.err.println("Operation failed.");
46 throw new ServerException(FAILURE_EXCEPTION);
47 }
48 }
49 catch (ConnectionException ce) {
50 System.err.println(ce.getLocalizedMessage());
51 throw new ServerException(FAILURE_EXCEPTION);
52 }
53 }
54 }

http://dive4elements.wald.intevation.org