annotate gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java @ 1145:dfe1ac687c7f tip

added tags
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:16:15 +0200
parents 28a0628b11b0
children
rev   line source
1022
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
1 /*
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
3 *
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
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: 991
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: 991
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: 991
diff changeset
7 */
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
8
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.action;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
573
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.action.sessionmodel.SessionModel;
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.action.sessionmodel.SessionModelFactory;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
13
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
14 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
15 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
16
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
17 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
18 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
19 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
20 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
21 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
22
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
23 import java.io.OutputStream;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
24
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
25 import java.util.ArrayList;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
26 import java.util.Collection;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
27 import java.util.Iterator;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
28
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
29 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
30 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
31
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
32 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
33
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
34 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
35 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
36 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
37
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
39 * 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
40 * '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
41 *
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
42 * @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
43 */
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
44 public class DoExportAction extends ArtifactDatabaseActionBase {
29
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 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 * 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
48 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 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
50
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 * Constructor
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 public DoExportAction() {
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 super();
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
58
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 @Override
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
60 public ActionForward execute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
61 ActionMapping mapping,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
62 ActionForm form,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
63 HttpServletRequest request,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
64 HttpServletResponse response)
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
65 throws Exception
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
66 {
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
67 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
68 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
69 }
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
70
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
71 try {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
72 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
73 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
74 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
75
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
76 log.debug("Target: " + target);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
77 log.debug("MimeType: " + mimeType);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
78 log.debug("ExportMode: " + mode);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
79
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
80 SessionModel sm = SessionModelFactory.getInstance()
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
81 .getSessionModel(request);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
82 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
83 if (outputMode != null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
84 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
85
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
86 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
87 && exportMode.getMimeType().equals(mimeType)))
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
88 {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
89 Collection<OutputParameter> inputParameter = outputMode
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
90 .getOutputParameters();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
91 Collection<InputParameter> ips = null;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
92 if (inputParameter != null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
93 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
94 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
95 while (it.hasNext()) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
96 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
97 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
98 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
99 values);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
100 ips.add(ip);
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 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
103
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
104 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
105 .getInstance()
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
106 .getArtifactDatabaseClient(getLocale(request));
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
107
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
108 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
109
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 ips);
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
119
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
120 outputStream.flush();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
121 outputStream.close();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
122 }
576
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
123 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
124 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
125 .getOutputParameters();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
126 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
127 if (inputParameter != null) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
128 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
129 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
130 while (it.hasNext()) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
131 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
132 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
133 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
134 values);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
135 ips.add(ip);
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 }
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
138
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
139 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
140 .getInstance()
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
141 .getArtifactDatabaseClient(getLocale(request));
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
142
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
143 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
144
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 ips);
576
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
154
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
155 outputStream.flush();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
156 outputStream.close();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
157 }
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
158 else {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
159 if (outputMode == null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
160 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
161 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
162 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
163 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
164 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
165 // TODO FIXME: Fehlerbehandlung
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
166 }
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 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
169 } catch (Exception e) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
170 log.error(e, e);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
171 request.setAttribute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
172 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
173 .getMessage());
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
174 return super.getExceptionForward(mapping);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
175 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
176 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
177
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 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
179 HttpServletResponse response,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
180 HttpServletRequest request) {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181 log.debug("DoExportAction.setHeaders");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
182 try {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
183 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
184 String fileName = "GNVEXPORT_" + System.currentTimeMillis() + ".";
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
185
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
186 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
187 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
188 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
189 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
190
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
191 if (target.equals("chart")) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
192 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
193 + mimeType.substring(mimeType.indexOf("/") + 1);
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 589
diff changeset
194 }
579
dc548655a66e Removed litte copy-paste mistake while setting file-extension for exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 578
diff changeset
195 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
196 fileName = fileName
fe825061b83e Set file-extension for histogram exports according to mime-type.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 576
diff changeset
197 + 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
198 }
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
199 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
200 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
201 + 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
202 }
398
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("pdf")) {
283
ef10bf497a16 Added link in gui to export charts to pdf.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 38
diff changeset
204 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
205 } 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
206 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
207 } 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
208 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
209 } 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
210 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
211 } 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
212 fileName = fileName + "xml";
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
213 } else {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
214 fileName = fileName + "txt";
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
215 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
216 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
217 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
218 + fileName);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
219 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
220 log.error(e, e);
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 }
700
89ade245ca7a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 699
diff changeset
224 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org