annotate gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java @ 573:bd67164cf28b

Devided actions and exports. Adjusted output and export actions. gnv/trunk@704 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 17:43:16 +0000
parents 9005b39c52ac
children b21fc7502750
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 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
117 else {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
118 if (outputMode == null) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
119 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
120 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
121 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
122 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
123 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
124 // TODO FIXME: Fehlerbehandlung
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
125 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
126 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
127 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
128 } catch (Exception e) {
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
129 log.error(e, e);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
130 request.setAttribute(
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
131 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
132 .getMessage());
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
133 return super.getExceptionForward(mapping);
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
134 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
135 }
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
136
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 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
138 HttpServletResponse response,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
139 HttpServletRequest request) {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 log.debug("DoExportAction.setHeaders");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
141 try {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 398
diff changeset
142 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
143 String fileName = "GNVEXPORT_" + System.currentTimeMillis() + ".";
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
144
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
145 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
146
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
147 if (target.equals("chart")) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
148 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
149 + 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
150 }
398
9005b39c52ac Only display chart addons if we really display a chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 284
diff changeset
151 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
152 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
153 } 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
154 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
155 } 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
156 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
157 } 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
158 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
159 } 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
160 fileName = fileName + "xml";
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
161 } else {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
162 fileName = fileName + "txt";
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
163 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
164 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
165 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
166 + fileName);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
167 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
168 log.error(e, e);
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 }

http://dive4elements.wald.intevation.org