comparison gwt-client/src/main/java/org/dive4elements/river/client/server/MapOutputServiceImpl.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/MapOutputServiceImpl.java@821a02bbfb4e
children 172338b1407f
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.client.server;
2
3 import java.io.InputStream;
4 import java.io.IOException;
5
6 import java.util.Map;
7
8 import org.w3c.dom.Document;
9
10 import org.apache.log4j.Logger;
11
12 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
13
14 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
15 import org.dive4elements.artifacts.common.utils.XMLUtils;
16
17 import org.dive4elements.artifacts.httpclient.http.HttpClient;
18 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
19 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
20
21 import org.dive4elements.river.client.shared.exceptions.ServerException;
22 import org.dive4elements.river.client.shared.model.Collection;
23 import org.dive4elements.river.client.shared.model.MapConfig;
24 import org.dive4elements.river.client.shared.model.OutputMode;
25 import org.dive4elements.river.client.client.services.MapOutputService;
26
27
28 public class MapOutputServiceImpl
29 extends RemoteServiceServlet
30 implements MapOutputService
31 {
32
33 private static final Logger logger =
34 Logger.getLogger(MapOutputServiceImpl.class);
35
36
37 public static final String ERROR_NO_MAP_CONFIG = "error_no_map_config";
38
39 public static final String ERROR_NO_MAP_OUTPUT_TYPE = "error_no_map_output_type";
40
41 public MapConfig doOut(Collection collection)
42 throws ServerException
43 {
44 logger.info("MapOutputServiceImpl.doOut");
45
46 String url = getServletContext().getInitParameter("server-url");
47 String uuid = collection.identifier();
48
49 Map<String, OutputMode> modes = collection.getOutputModes();
50 String requestMode = "";
51 if (modes.containsKey("floodmap")) {
52 requestMode = "floodmap";
53 }
54 else if (modes.containsKey("map")) {
55 requestMode = "map";
56 }
57 else {
58 throw new ServerException(ERROR_NO_MAP_OUTPUT_TYPE);
59 }
60
61 try {
62 Document request = ClientProtocolUtils.newOutCollectionDocument(
63 uuid, requestMode, requestMode);
64
65 HttpClient client = new HttpClientImpl(url);
66 InputStream is = client.collectionOut(request, uuid, requestMode);
67
68 Document response = XMLUtils.parseDocument(is);
69
70 return MapHelper.parseConfig(response);
71 }
72 catch (ConnectionException e) {
73 logger.error(e, e);
74 }
75 catch (IOException ioe) {
76 logger.error(ioe, ioe);
77 }
78
79 throw new ServerException(ERROR_NO_MAP_CONFIG);
80 }
81 }
82 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org