Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java @ 1510:f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
flys-client/trunk@3652 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 11 Jan 2012 14:28:46 +0000 |
parents | 28eb4dfe2cbf |
children |
comparison
equal
deleted
inserted
replaced
1509:8c911c935b58 | 1510:f7b3d5833f3b |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import java.io.InputStream; | 3 import java.io.InputStream; |
4 import java.io.IOException; | 4 import java.io.IOException; |
5 | |
6 import java.util.Map; | |
5 | 7 |
6 import org.w3c.dom.Document; | 8 import org.w3c.dom.Document; |
7 | 9 |
8 import org.apache.log4j.Logger; | 10 import org.apache.log4j.Logger; |
9 | 11 |
17 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | 19 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
18 | 20 |
19 import de.intevation.flys.client.shared.exceptions.ServerException; | 21 import de.intevation.flys.client.shared.exceptions.ServerException; |
20 import de.intevation.flys.client.shared.model.Collection; | 22 import de.intevation.flys.client.shared.model.Collection; |
21 import de.intevation.flys.client.shared.model.MapConfig; | 23 import de.intevation.flys.client.shared.model.MapConfig; |
22 | 24 import de.intevation.flys.client.shared.model.OutputMode; |
23 import de.intevation.flys.client.client.services.MapOutputService; | 25 import de.intevation.flys.client.client.services.MapOutputService; |
24 | 26 |
25 | 27 |
26 public class MapOutputServiceImpl | 28 public class MapOutputServiceImpl |
27 extends RemoteServiceServlet | 29 extends RemoteServiceServlet |
32 Logger.getLogger(MapOutputServiceImpl.class); | 34 Logger.getLogger(MapOutputServiceImpl.class); |
33 | 35 |
34 | 36 |
35 public static final String ERROR_NO_MAP_CONFIG = "error_no_map_config"; | 37 public static final String ERROR_NO_MAP_CONFIG = "error_no_map_config"; |
36 | 38 |
39 public static final String ERROR_NO_MAP_OUTPUT_TYPE = "error_no_map_output_type"; | |
37 | 40 |
38 public MapConfig doOut(Collection collection) | 41 public MapConfig doOut(Collection collection) |
39 throws ServerException | 42 throws ServerException |
40 { | 43 { |
41 logger.info("MapOutputServiceImpl.doOut"); | 44 logger.info("MapOutputServiceImpl.doOut"); |
42 | 45 |
43 String url = getServletContext().getInitParameter("server-url"); | 46 String url = getServletContext().getInitParameter("server-url"); |
44 String uuid = collection.identifier(); | 47 String uuid = collection.identifier(); |
45 | 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 | |
46 try { | 61 try { |
47 Document request = ClientProtocolUtils.newOutCollectionDocument( | 62 Document request = ClientProtocolUtils.newOutCollectionDocument( |
48 uuid, "floodmap", "floodmap"); | 63 uuid, requestMode, requestMode); |
49 | 64 |
50 HttpClient client = new HttpClientImpl(url); | 65 HttpClient client = new HttpClientImpl(url); |
51 InputStream is = client.collectionOut(request, uuid, "floodmap"); | 66 InputStream is = client.collectionOut(request, uuid, requestMode); |
52 | 67 |
53 Document response = XMLUtils.parseDocument(is); | 68 Document response = XMLUtils.parseDocument(is); |
54 | 69 |
55 return MapHelper.parseConfig(response); | 70 return MapHelper.parseConfig(response); |
56 } | 71 } |