annotate gnv/src/main/java/de/intevation/gnv/action/mapviewer/MapViewerCallAction.java @ 952:902d4de27c37

Add more Javadocs gnv/trunk@1096 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 17 May 2010 14:21:19 +0000
parents 57fa8019fbdc
children 28a0628b11b0
rev   line source
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
1 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
2
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
3 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
4 import java.io.InputStream;
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
5 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
6 import java.util.Collection;
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
7 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
8
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 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
10 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
11
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 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
13 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
14 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
15 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
16
952
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
17 import de.intevation.gnv.action.ArtifactDatabaseActionBase;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
18 import de.intevation.gnv.action.mapviewer.parser.ExternalCallParser;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
19 import de.intevation.gnv.action.mapviewer.parser.XMLExternalCallParser;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
20 import de.intevation.gnv.action.sessionmodel.SessionModel;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
21 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
22 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
23 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
24 import de.intevation.gnv.artifactdatabase.objects.map.MapService;
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
25
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
26 /**
952
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
27 * This class provides the businesslogic for handling an
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
28 * MV-GNV-Interface-call.
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
29 * This call can be done in two ways.
902d4de27c37 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
30 * 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
31 * 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
32 * 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
33 * @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
34 */
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
35 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
36
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
37 /**
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
38 * 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
39 */
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
40 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
41
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 * 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
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 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
46 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
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
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 * @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
51 */
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 @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
53 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
54 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
55 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
56 log.debug("MapViewerCallAction.execute");
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
57 InputStream inputStream = null;
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
58 String documentvalue = request.getParameter("document");
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
59 if (documentvalue != null){
562
4df3347d6d1d Removed trailing and leading Whitespaces from the Parametervalue which
Tim Englich <tim.englich@intevation.de>
parents: 558
diff changeset
60 documentvalue = documentvalue.trim();
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
61 inputStream = new ByteArrayInputStream(documentvalue.getBytes());
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
62 }else{
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
63 inputStream = request.getInputStream();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
64 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
65
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
66 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
67 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
68 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
69 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
70 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
71 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
72 Collection<MapService> mapServices = ecp.getMapServices();
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
73
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
74 Collection<ArtifactObject> availableFactories =
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
75 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
76 .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
77 .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
78 .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
79 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
80 srs);
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> providedFactories =
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
83 ArtifactDatabaseClientFactory
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
84 .getInstance()
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
85 .getArtifactDatabaseClient(getLocale(request))
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
86 .getArtifactFactories();
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
87
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
88 // Sort out which ArtifactFactories should not be used.
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
89 Collection<ArtifactObject> usedFactories =
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
90 new ArrayList<ArtifactObject>(availableFactories.size());
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 562
diff changeset
91
558
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
92 Iterator<ArtifactObject> it = availableFactories.iterator();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
93 while (it.hasNext()){
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
94 ArtifactObject ao = it.next();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
95 if (providedFactories.contains(ao)){
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
96 usedFactories.add(ao);
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
97 }
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
98 }
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 SessionModel sm = SessionModelFactory
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
101 .getInstance()
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
102 .getSessionModel(request);
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
103 sm.resetModel();
8032da9e8b70 Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents: 402
diff changeset
104 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
105 } 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
106 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
107 }
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
108 }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
109 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
110 }
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
111 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
112 }
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
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 }

http://dive4elements.wald.intevation.org