comparison gwt-client/src/main/java/org/dive4elements/river/client/server/DescribeCollectionServiceImpl.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/DescribeCollectionServiceImpl.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.utils.ClientProtocolUtils;
10
11 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
12 import org.dive4elements.artifacts.httpclient.http.HttpClient;
13 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
14 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler;
15
16 import org.dive4elements.river.client.shared.exceptions.ServerException;
17 import org.dive4elements.river.client.shared.model.Collection;
18
19 import org.dive4elements.river.client.client.services.DescribeCollectionService;
20
21
22 /**
23 * This service implements a method that queries the DESCRIBE document of a
24 * specific collection and returns a Collection object with the information of
25 * the document.
26 *
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
28 */
29 public class DescribeCollectionServiceImpl
30 extends RemoteServiceServlet
31 implements DescribeCollectionService
32 {
33 private static final Logger logger =
34 Logger.getLogger(DescribeCollectionServiceImpl.class);
35
36
37 /** The error message key that is thrown if an error occured while
38 * describe() a Collection.*/
39 public static final String ERROR_DESCRIBE_COLLECTION =
40 "error_describe_collection";
41
42
43 public Collection describe(String uuid, String locale)
44 throws ServerException
45 {
46 logger.info("DescribeCollectionServiceImpl.describe");
47
48 String url = getServletContext().getInitParameter("server-url");
49
50 Document describe = ClientProtocolUtils.newDescribeCollectionDocument(
51 uuid);
52
53 HttpClient client = new HttpClientImpl(url, locale);
54
55 try {
56 Document response = (Document) client.doCollectionAction(
57 describe, uuid, new DocumentResponseHandler());
58
59 Collection c = CollectionHelper.parseCollection(response);
60
61 if (c == null) {
62 throw new ServerException(ERROR_DESCRIBE_COLLECTION);
63 }
64
65 logger.debug("Collection successfully parsed.");
66
67 return c;
68 }
69 catch (ConnectionException ce) {
70 logger.error(ce, ce);
71 }
72
73 throw new ServerException(ERROR_DESCRIBE_COLLECTION);
74 }
75 }
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org