annotate gwt-client/src/main/java/org/dive4elements/river/client/server/MapOutputServiceImpl.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 238fc722f87a
children 0a5239a1e46e
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
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
18 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
19
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 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
21
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 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
24
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 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
28
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
29 import org.dive4elements.river.client.shared.exceptions.ServerException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
30 import org.dive4elements.river.client.shared.model.Collection;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
31 import org.dive4elements.river.client.shared.model.MapConfig;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
32 import org.dive4elements.river.client.shared.model.OutputMode;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
33 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
34
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 public class MapOutputServiceImpl
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 extends RemoteServiceServlet
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 implements MapOutputService
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 {
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
41 private static final Logger log =
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
42 Logger.getLogger(MapOutputServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
43
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
44
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
45 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
46
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
47 public static final String ERROR_NO_MAP_OUTPUT_TYPE =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
48 "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
49
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 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
51 throws ServerException
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
53 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
54
1370
9085cffbb7c4 Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
55 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
56 String uuid = collection.identifier();
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
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
58 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
59 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
60 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
61 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
62 }
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 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
64 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
65 }
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 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
67 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
68 }
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
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 try {
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 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
72 uuid, requestMode, requestMode);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
1370
9085cffbb7c4 Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
74 HttpClient client = new HttpClientImpl(url);
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
75 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
76
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 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
78
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
79 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
80 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 catch (ConnectionException e) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
82 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
83 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 catch (IOException ioe) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
85 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
86 }
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
87
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 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
89 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org