annotate gwt-client/src/main/java/org/dive4elements/river/client/server/MapOutputServiceImpl.java @ 8203:238fc722f87a

sed 's/logger/log/g' src/**/*.java
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 13:19:22 +0200
parents ea9eef426962
children 5e38e2924c07
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
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
47 public static final String ERROR_NO_MAP_OUTPUT_TYPE = "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
48
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 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
50 throws ServerException
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
52 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
53
1370
9085cffbb7c4 Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
54 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
55 String uuid = collection.identifier();
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
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
57 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
58 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
59 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
60 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
61 }
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 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
63 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
64 }
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 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
66 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
67 }
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
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 try {
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 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
71 uuid, requestMode, requestMode);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
1370
9085cffbb7c4 Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
73 HttpClient client = new HttpClientImpl(url);
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
74 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
75
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 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
77
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
78 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
79 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 catch (ConnectionException e) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
81 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
82 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 catch (IOException ioe) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
84 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
85 }
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
86
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 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
88 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org