annotate gnv/src/main/java/de/intevation/gnv/action/mapviewer/MapViewerCallAction.java @ 1022:28a0628b11b0

Added license file and license header. gnv/trunk@1258 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:15:08 +0000
parents 902d4de27c37
children e887763a37e2
rev   line source
1022
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
1 /*
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
3 *
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
5 * Read the file LGPL.txt coming with the software for details
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
7 */
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 952
diff changeset
8
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.action.mapviewer;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
11 import java.io.ByteArrayInputStream;
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import java.io.InputStream;
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
13 import java.util.ArrayList;
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import java.util.Collection;
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
15 import java.util.Iterator;
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import javax.servlet.http.HttpServletRequest;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import javax.servlet.http.HttpServletResponse;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.Logger;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import org.apache.struts.action.ActionForm;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import org.apache.struts.action.ActionForward;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import org.apache.struts.action.ActionMapping;
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24
952
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
25 import de.intevation.gnv.action.ArtifactDatabaseActionBase;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
26 import de.intevation.gnv.action.mapviewer.parser.ExternalCallParser;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
27 import de.intevation.gnv.action.mapviewer.parser.XMLExternalCallParser;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
28 import de.intevation.gnv.action.sessionmodel.SessionModel;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
29 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
30 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
31 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
32 import de.intevation.gnv.artifactdatabase.objects.map.MapService;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
33
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 /**
952
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
35 * This class provides the businesslogic for handling an
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
36 * MV-GNV-Interface-call.
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
37 * This call can be done in two ways.
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
38 * First is to put the requestbody into the body of the http-post-request.
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
39 * Second to put the requestbody to the parameter "document" of the
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
40 * http-post-request.
684
57fa8019fbdc Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 683
diff changeset
41 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 */
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 public class MapViewerCallAction extends ArtifactDatabaseActionBase {
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 /**
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 * the logger, used to log exceptions and additonaly information
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 */
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 private static Logger log = Logger.getLogger(MapViewerCallAction.class);
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 /**
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 * Constructor
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 */
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 public MapViewerCallAction() {
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 super();
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 }
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 /**
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 */
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 @Override
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 public ActionForward execute(ActionMapping mapping, ActionForm form,
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 HttpServletRequest request,
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 HttpServletResponse response) throws Exception {
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 log.debug("MapViewerCallAction.execute");
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
65 InputStream inputStream = null;
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
66 String documentvalue = request.getParameter("document");
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
67 if (documentvalue != null){
562
4df3347d6d1d Removed trailing and leading Whitespaces from the Parametervalue which
Tim Englich <tim.englich@intevation.de>
parents: 558
diff changeset
68 documentvalue = documentvalue.trim();
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
69 inputStream = new ByteArrayInputStream(documentvalue.getBytes());
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
70 }else{
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
71 inputStream = request.getInputStream();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
72 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
73
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 if (inputStream != null){
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 try {
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 ExternalCallParser ecp = new XMLExternalCallParser(inputStream);
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 ecp.parse();
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 String geometry = ecp.getGeometry();
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 String srs = ecp.getSRS();
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 Collection<MapService> mapServices = ecp.getMapServices();
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
81
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
82 Collection<ArtifactObject> availableFactories =
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
83 ArtifactDatabaseClientFactory
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 .getInstance()
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 .getArtifactDatabaseClient(getLocale(request))
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 .getArtifactFactoryMetaInformation(mapServices,
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 geometry,
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 srs);
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
89
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
90 Collection<ArtifactObject> providedFactories =
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
91 ArtifactDatabaseClientFactory
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
92 .getInstance()
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
93 .getArtifactDatabaseClient(getLocale(request))
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
94 .getArtifactFactories();
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
95
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
96 // Sort out which ArtifactFactories should not be used.
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
97 Collection<ArtifactObject> usedFactories =
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
98 new ArrayList<ArtifactObject>(availableFactories.size());
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
99
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
100 Iterator<ArtifactObject> it = availableFactories.iterator();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
101 while (it.hasNext()){
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
102 ArtifactObject ao = it.next();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
103 if (providedFactories.contains(ao)){
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
104 usedFactories.add(ao);
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
105 }
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
106 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
107
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
108 SessionModel sm = SessionModelFactory
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
109 .getInstance()
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
110 .getSessionModel(request);
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
111 sm.resetModel();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
112 sm.setArtifacteFactories(usedFactories);
402
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 } catch (Exception e) {
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 log.error(e,e);
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 }
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 }else{
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 log.error("Kein Anfragedokument übergeben.");
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 }
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 return super.execute(mapping, form, request, response);
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 }
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121
b88e881e8e94 Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 }

http://dive4elements.wald.intevation.org