comparison gwt-client/src/main/java/org/dive4elements/river/client/server/DescribeArtifactServiceImpl.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/DescribeArtifactServiceImpl.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.Artifact;
18 import org.dive4elements.river.client.client.services.DescribeArtifactService;
19
20
21 /**
22 * This interface provides artifact specific operation DESCRIBE.
23 *
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
25 */
26 public class DescribeArtifactServiceImpl
27 extends RemoteServiceServlet
28 implements DescribeArtifactService
29 {
30 private static final Logger logger =
31 Logger.getLogger(DescribeArtifactServiceImpl.class);
32
33
34 public static final String ERROR_DESCRIBE_ARTIFACT =
35 "error_describe_artifact";
36
37
38 public Artifact describe(String locale, Artifact artifact)
39 throws ServerException
40 {
41 logger.info("DescribeArtifactServiceImpl.describe");
42
43 String url = getServletContext().getInitParameter("server-url");
44
45 Document describe = ClientProtocolUtils.newDescribeDocument(
46 artifact.getUuid(),
47 artifact.getHash(),
48 true);
49
50 HttpClient client = new HttpClientImpl(url, locale);
51
52 try {
53 logger.debug("Start Http request now.");
54
55 Document description = (Document) client.describe(
56 new org.dive4elements.artifacts.httpclient.objects.Artifact(
57 artifact.getUuid(),
58 artifact.getHash()),
59 describe,
60 new DocumentResponseHandler());
61
62 if (description != null) {
63 logger.debug("Finished Http request sucessfully!");
64
65 return (Artifact) new FLYSArtifactCreator().create(description);
66 }
67 }
68 catch (ConnectionException ce) {
69 ce.printStackTrace();
70 }
71
72 throw new ServerException(ERROR_DESCRIBE_ARTIFACT);
73 }
74 }
75 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org