Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/server/MapOutputServiceImpl.java @ 9801:1d7a72a50183 3.2.x tip
Assume Compose V2, consistently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Nov 2023 10:14:13 +0100 |
parents | 0a5239a1e46e |
children |
rev | line source |
---|---|
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
9 package org.dive4elements.river.client.server; |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.io.InputStream; |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import java.io.IOException; |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
1510
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
14 import java.util.Map; |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
15 |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import org.w3c.dom.Document; |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
9726 | 18 import org.apache.logging.log4j.Logger; |
19 import org.apache.logging.log4j.LogManager; | |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1365
diff
changeset
|
20 |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
23 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
24 import org.dive4elements.artifacts.common.utils.XMLUtils; |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
26 import org.dive4elements.artifacts.httpclient.http.HttpClient; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
27 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
28 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
30 import org.dive4elements.river.client.shared.exceptions.ServerException; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
31 import org.dive4elements.river.client.shared.model.Collection; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
32 import org.dive4elements.river.client.shared.model.MapConfig; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
33 import org.dive4elements.river.client.shared.model.OutputMode; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
34 import org.dive4elements.river.client.client.services.MapOutputService; |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 public class MapOutputServiceImpl |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 extends RemoteServiceServlet |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 implements MapOutputService |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 { |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
42 private static final Logger log = |
9726 | 43 LogManager.getLogger(MapOutputServiceImpl.class); |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1365
diff
changeset
|
44 |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1365
diff
changeset
|
45 |
1376
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
46 public static final String ERROR_NO_MAP_CONFIG = "error_no_map_config"; |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
47 |
8856 | 48 public static final String ERROR_NO_MAP_OUTPUT_TYPE = |
49 "error_no_map_output_type"; | |
1376
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
50 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
51 public MapConfig doOut(Collection collection) |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 throws ServerException |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
54 log.info("MapOutputServiceImpl.doOut"); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
1370
9085cffbb7c4
Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1368
diff
changeset
|
56 String url = getServletContext().getInitParameter("server-url"); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 String uuid = collection.identifier(); |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
1510
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
59 Map<String, OutputMode> modes = collection.getOutputModes(); |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
60 String requestMode = ""; |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
61 if (modes.containsKey("floodmap")) { |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
62 requestMode = "floodmap"; |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
63 } |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
64 else if (modes.containsKey("map")) { |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
65 requestMode = "map"; |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
66 } |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
67 else { |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
68 throw new ServerException(ERROR_NO_MAP_OUTPUT_TYPE); |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
69 } |
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
70 |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 try { |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 Document request = ClientProtocolUtils.newOutCollectionDocument( |
1510
f7b3d5833f3b
Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1376
diff
changeset
|
73 uuid, requestMode, requestMode); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
1370
9085cffbb7c4
Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1368
diff
changeset
|
75 HttpClient client = new HttpClientImpl(url); |
8856 | 76 InputStream is = client.collectionOut(request, uuid, requestMode); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 Document response = XMLUtils.parseDocument(is); |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
1376
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
80 return MapHelper.parseConfig(response); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 catch (ConnectionException e) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
83 log.error(e, e); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 catch (IOException ioe) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
86 log.error(ioe, ioe); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 } |
1376
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
88 |
28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1370
diff
changeset
|
89 throw new ServerException(ERROR_NO_MAP_CONFIG); |
1365
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
4c65c5b60a86
First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |