Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/server/MapOutputServiceImpl.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java@f7b3d5833f3b |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.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 de.intevation.artifacts.common.utils.ClientProtocolUtils; | |
15 import de.intevation.artifacts.common.utils.XMLUtils; | |
16 | |
17 import de.intevation.artifacts.httpclient.http.HttpClient; | |
18 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
19 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | |
20 | |
21 import de.intevation.flys.client.shared.exceptions.ServerException; | |
22 import de.intevation.flys.client.shared.model.Collection; | |
23 import de.intevation.flys.client.shared.model.MapConfig; | |
24 import de.intevation.flys.client.shared.model.OutputMode; | |
25 import de.intevation.flys.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 : |