annotate gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java @ 991:33198e55371c

Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection. gnv/trunk@1192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Jun 2010 15:13:08 +0000
parents 89ade245ca7a
children 28a0628b11b0
rev   line source
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.action;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
3 import de.intevation.gnv.action.sessionmodel.SessionModel;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
4 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
5
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
6 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
7 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
8
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
9 import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
10 import de.intevation.gnv.artifactdatabase.objects.ExportMode;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
11 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
12 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
13 import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
14
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
15 import java.io.OutputStream;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
16
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
17 import java.util.ArrayList;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
18 import java.util.Collection;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
19 import java.util.Iterator;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
20
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
21 import javax.servlet.http.HttpServletRequest;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
22 import javax.servlet.http.HttpServletResponse;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
23
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
24 import org.apache.log4j.Logger;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
25
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
26 import org.apache.struts.action.ActionForm;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
27 import org.apache.struts.action.ActionForward;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
28 import org.apache.struts.action.ActionMapping;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
29
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
31 * This controller is called to trigger an export (e.g. pdf, svg, image). A
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
32 * 'save-file' dialog is opened to save the export.
699
af22fa5567a6 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 690
diff changeset
33 *
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
34 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 */
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
36 public class DoExportAction extends ArtifactDatabaseActionBase {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * the logger, used to log exceptions and additonaly information
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 private static Logger log = Logger.getLogger(DoExportAction.class);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
42
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 * Constructor
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 public DoExportAction() {
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 super();
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
50
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 @Override
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
52 public ActionForward execute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
53 ActionMapping mapping,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
54 ActionForm form,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
55 HttpServletRequest request,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
56 HttpServletResponse response)
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
57 throws Exception
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
58 {
991
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 700
diff changeset
59 if (isSessionExhausted(request)) {
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 700
diff changeset
60 return sessionExhaustedForward(mapping, form, request, response);
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 700
diff changeset
61 }
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 700
diff changeset
62
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
63 try {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
64 String target = request.getParameter("target");
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
65 String mimeType = request.getParameter("mimetype");
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
66 String mode = request.getParameter("mode");
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
67
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
68 log.debug("Target: " + target);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
69 log.debug("MimeType: " + mimeType);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
70 log.debug("ExportMode: " + mode);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
71
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
72 SessionModel sm = SessionModelFactory.getInstance()
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
73 .getSessionModel(request);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
74 OutputMode outputMode = sm.getOutputMode(target);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
75 if (outputMode != null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
76 ExportMode exportMode = outputMode.getExportMode(mode);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
77
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
78 if (target.equals(mode) || (exportMode != null
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
79 && exportMode.getMimeType().equals(mimeType)))
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
80 {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
81 Collection<OutputParameter> inputParameter = outputMode
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
82 .getOutputParameters();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
83 Collection<InputParameter> ips = null;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
84 if (inputParameter != null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
85 ips = new ArrayList<InputParameter>(inputParameter.size());
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
86 Iterator<OutputParameter> it = inputParameter.iterator();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
87 while (it.hasNext()) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
88 String name = it.next().getName();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
89 String[] values = request.getParameterValues(name);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
90 InputParameter ip = new DefaultInputParameter(name,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
91 values);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
92 ips.add(ip);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
93 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
94 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
95
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
96 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
97 .getInstance()
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
98 .getArtifactDatabaseClient(getLocale(request));
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
99
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
100 this.setHeaders(mode, mimeType, response, request);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
101
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
102 OutputStream outputStream = response.getOutputStream();
583
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
103 adc.doOutput(
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
104 sm.getSelectedArtifactFactory(),
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
105 sm.getCurrentArtifact(),
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
106 outputStream,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
107 target,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
108 mode,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
109 mimeType,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
110 ips);
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
111
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
112 outputStream.flush();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
113 outputStream.close();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
114 }
576
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
115 else if (exportMode == null) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
116 Collection<OutputParameter> inputParameter = outputMode
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
117 .getOutputParameters();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
118 Collection<InputParameter> ips = null;
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
119 if (inputParameter != null) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
120 ips = new ArrayList<InputParameter>(inputParameter.size());
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
121 Iterator<OutputParameter> it = inputParameter.iterator();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
122 while (it.hasNext()) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
123 String name = it.next().getName();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
124 String[] values = request.getParameterValues(name);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
125 InputParameter ip = new DefaultInputParameter(name,
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
126 values);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
127 ips.add(ip);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
128 }
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
129 }
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
130
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
131 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
132 .getInstance()
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
133 .getArtifactDatabaseClient(getLocale(request));
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
134
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
135 this.setHeaders(target, mimeType, response, request);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
136
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
137 OutputStream outputStream = response.getOutputStream();
583
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
138 adc.doOutput(
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
139 sm.getSelectedArtifactFactory(),
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
140 sm.getCurrentArtifact(),
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
141 outputStream,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
142 target,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
143 mode,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
144 mimeType,
2f3d885fed09 Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 579
diff changeset
145 ips);
576
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
146
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
147 outputStream.flush();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
148 outputStream.close();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
149 }
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
150 else {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
151 if (outputMode == null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
152 log.error("Outputmode is not supported.");
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
153 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
154 else if (!exportMode.getMimeType().equals(mimeType)) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
155 log.error("MimeType "+mimeType+" wis not supported.");
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
156 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
157 // TODO FIXME: Fehlerbehandlung
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
158 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
159 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
160 return super.execute(mapping, form, request, response);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
161 } catch (Exception e) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
162 log.error(e, e);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
163 request.setAttribute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
164 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
165 .getMessage());
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
166 return super.getExceptionForward(mapping);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
167 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
168 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
169
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 protected void setHeaders(String target, String mimeType,
38
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
171 HttpServletResponse response,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
172 HttpServletRequest request) {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 log.debug("DoExportAction.setHeaders");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
174 try {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
175 response.setHeader("Content-Type", mimeType);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
176 String fileName = "GNVEXPORT_" + System.currentTimeMillis() + ".";
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
177
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
178 target = target.toLowerCase();
589
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
179 log.debug("******************************************************");
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
180 log.debug("TARGET: " + target);
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
181 log.debug("MIMETYPE: " + mimeType);
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
182
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
183 if (target.equals("chart")) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
184 fileName = fileName
38
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
185 + mimeType.substring(mimeType.indexOf("/") + 1);
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 589
diff changeset
186 }
579
dc548655a66e Removed litte copy-paste mistake while setting file-extension for exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 578
diff changeset
187 else if (target.equals("histogram")) {
578
fe825061b83e Set file-extension for histogram exports according to mime-type.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 576
diff changeset
188 fileName = fileName
fe825061b83e Set file-extension for histogram exports according to mime-type.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 576
diff changeset
189 + mimeType.substring(mimeType.indexOf("/") + 1);
fe825061b83e Set file-extension for histogram exports according to mime-type.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 576
diff changeset
190 }
589
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
191 else if (target.equals("img")) {
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
192 fileName = fileName
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
193 + mimeType.substring(mimeType.indexOf("/") + 1);
960ae818296e img-Exports will get a file extension that corresponds to their mime-type (issue187).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 588
diff changeset
194 }
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
195 else if (target.equals("pdf")) {
283
ef10bf497a16 Added link in gui to export charts to pdf.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 38
diff changeset
196 fileName = fileName + "pdf";
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
197 } else if (target.equals("svg")) {
284
47e3647af88f Added link in gui to export charts to svg.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
198 fileName = fileName + "svg";
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
199 } else if (target.equals("csv")) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
200 fileName = fileName + "csv";
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
201 } else if (target.equals("zip")) {
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
202 fileName = fileName + "zip";
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
203 } else if (target.equals("wms")) {
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
204 fileName = fileName + "xml";
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
205 } else {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
206 fileName = fileName + "txt";
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
207 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
208 log.debug("FileName for Export: " + fileName);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
209 response.setHeader("Content-Disposition", "attachment;filename="
38
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
210 + fileName);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
211 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
212 log.error(e, e);
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215 }
700
89ade245ca7a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 699
diff changeset
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org