annotate gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java @ 579:dc548655a66e

Removed litte copy-paste mistake while setting file-extension for exports. gnv/trunk@716 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 01 Mar 2010 11:08:07 +0000
parents fe825061b83e
children 2f3d885fed09
rev   line source
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.action;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import javax.servlet.http.HttpServletRequest;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import javax.servlet.http.HttpServletResponse;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import org.apache.log4j.Logger;
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 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * @author Tim Englich <tim.englich@intevation.de>
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
40 *
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 */
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
42 public class DoExportAction extends ArtifactDatabaseActionBase {
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 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 * 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
46 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 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
48
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 * Constructor
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 public DoExportAction() {
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 super();
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
56 /**
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
57 * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(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
58 * 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
59 * javax.servlet.http.HttpServletRequest,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
60 * javax.servlet.http.HttpServletResponse)
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
61 */
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 @Override
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
63 public ActionForward execute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
64 ActionMapping mapping,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
65 ActionForm form,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
66 HttpServletRequest request,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
67 HttpServletResponse response)
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
68 throws Exception
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
69 {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
70 try {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
71 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
72 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
73 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
74
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
75 log.debug("Target: " + target);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
76 log.debug("MimeType: " + mimeType);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
77 log.debug("ExportMode: " + mode);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
78
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
79 SessionModel sm = SessionModelFactory.getInstance()
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
80 .getSessionModel(request);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
81 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
82 if (outputMode != null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
83 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
84
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
85 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
86 && exportMode.getMimeType().equals(mimeType)))
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
87 {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
88 Collection<OutputParameter> inputParameter = outputMode
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
89 .getOutputParameters();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
90 Collection<InputParameter> ips = null;
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
91 if (inputParameter != null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
92 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
93 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
94 while (it.hasNext()) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
95 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
96 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
97 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
98 values);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
99 ips.add(ip);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
100 }
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 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
104 .getInstance()
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
105 .getArtifactDatabaseClient(getLocale(request));
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
106
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
107 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
108
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
109 OutputStream outputStream = response.getOutputStream();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
110 adc.doOutput(sm.getSelectedArtifactFactory(), sm
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
111 .getCurrentArtifact(), outputStream, mode, mimeType,
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
112 ips);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
113
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
114 outputStream.flush();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
115 outputStream.close();
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
116 }
576
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
117 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
118 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
119 .getOutputParameters();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
120 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
121 if (inputParameter != null) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
122 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
123 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
124 while (it.hasNext()) {
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
125 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
126 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
127 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
128 values);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
129 ips.add(ip);
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 }
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
132
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
133 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
134 .getInstance()
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
135 .getArtifactDatabaseClient(getLocale(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 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
138
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
139 OutputStream outputStream = response.getOutputStream();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
140 adc.doOutput(sm.getSelectedArtifactFactory(), sm
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
141 .getCurrentArtifact(), outputStream, target, mimeType,
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
142 ips);
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
143
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
144 outputStream.flush();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
145 outputStream.close();
b21fc7502750 Fixed issue 178. Export modes CSV and ODV work again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 573
diff changeset
146 }
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
147 else {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
148 if (outputMode == null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
149 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
150 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
151 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
152 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
153 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
154 // TODO FIXME: Fehlerbehandlung
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
155 }
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 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
158 } catch (Exception e) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
159 log.error(e, e);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
160 request.setAttribute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
161 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
162 .getMessage());
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
163 return super.getExceptionForward(mapping);
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 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
166
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 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
168 HttpServletResponse response,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
169 HttpServletRequest request) {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 log.debug("DoExportAction.setHeaders");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
171 try {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
172 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
173 String fileName = "GNVEXPORT_" + System.currentTimeMillis() + ".";
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
174
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
175 target = target.toLowerCase();
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
176
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
177 if (target.equals("chart")) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
178 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
179 + mimeType.substring(mimeType.indexOf("/") + 1);
283
ef10bf497a16 Added link in gui to export charts to pdf.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 38
diff changeset
180 }
579
dc548655a66e Removed litte copy-paste mistake while setting file-extension for exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 578
diff changeset
181 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
182 fileName = fileName
fe825061b83e Set file-extension for histogram exports according to mime-type.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 576
diff changeset
183 + 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
184 }
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
185 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
186 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
187 } 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
188 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
189 } 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
190 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
191 } 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
192 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
193 } 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
194 fileName = fileName + "xml";
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
195 } else {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
196 fileName = fileName + "txt";
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
197 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
198 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
199 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
200 + fileName);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
201 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
202 log.error(e, e);
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205 }

http://dive4elements.wald.intevation.org