annotate gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java @ 401:002a4d38c16d

Added a link to jump back to the fis selection. gnv/trunk@568 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 18 Jan 2010 16:21:54 +0000
parents a8b1875dcd93
children 15ac78a91d1b
rev   line source
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.action;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
19
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
6 import java.util.Collection;
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
7
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import javax.servlet.http.HttpServletRequest;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import javax.servlet.http.HttpServletResponse;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import org.apache.struts.action.ActionForm;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import org.apache.struts.action.ActionForward;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import org.apache.struts.action.ActionMapping;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15
400
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
16 import org.w3c.dom.Node;
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
17
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import de.intevation.gnv.action.sessionmodel.SessionModel;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
9
a4cb6d175a6e Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents: 8
diff changeset
22 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
400
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
24 import de.intevation.gnv.util.XMLUtils;
11
3cb753564552 Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents: 9
diff changeset
25 import de.intevation.gnv.util.XSLTransformer;
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 /**
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 * @author Tim Englich <tim.englich@intevation.de>
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
29 *
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 */
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 public class SelectArtifactFactoryAction extends ArtifactDatabaseActionBase {
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 /**
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * the logger, used to log exceptions and additonaly information
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 */
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
35 private static Logger log = Logger
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
36 .getLogger(SelectArtifactFactoryAction.class);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
37
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 /**
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
39 * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping,
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
40 * org.apache.struts.action.ActionForm,
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
41 * javax.servlet.http.HttpServletRequest,
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
42 * javax.servlet.http.HttpServletResponse)
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 */
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 @Override
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 public ActionForward execute(ActionMapping mapping, ActionForm form,
38
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
46 HttpServletRequest request,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
47 HttpServletResponse response) throws Exception {
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 log.debug("SelectArtifactFactoryAction.execute");
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
49 String selectedArtifactFactoryID = request
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
50 .getParameter("artifactFactory");
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
51 log.debug("Selected ArtifactFactory ==> " + selectedArtifactFactoryID);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
52
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
53 try {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
54 SessionModel sm = SessionModelFactory.getInstance()
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
55 .getSessionModel(request);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
56 Collection<ArtifactObject> artifactFactories = sm
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
57 .getArtifactFactories();
390
f2e2053ecf23 Removed Encodingerrors from listed Files. All Files are now UTF-8 compliant.
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
58 // Removes the Artifactspecific Attributes from the SessionModel-
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
59 sm.resetModel();
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
60 if (artifactFactories == null || artifactFactories.isEmpty()) {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
61 new FetchArtifactFactoriesAction().execute(mapping, form,
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
62 request, response);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
63
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
64 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
65
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
66 sm.selectArtifactFactory(selectedArtifactFactoryID);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
67 ArtifactObject af = sm.getSelectedArtifactFactory();
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
68 ;
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
69 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
40
23a4f196d7d6 Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 38
diff changeset
70 .getInstance()
23a4f196d7d6 Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 38
diff changeset
71 .getArtifactDatabaseClient(getLocale(request));
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
72 ArtifactObject artifact = adc.createNewArtifact(af);
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
73 sm.setCurrentArtifact(artifact);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
74
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
75 ArtifactDescription artifactdescription = adc
157
013d47662161 Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents: 40
diff changeset
76 .getCurrentStepDescription(af, artifact,true);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
77
401
002a4d38c16d Added a link to jump back to the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 400
diff changeset
78 String fisUrl = response.encodeURL(
002a4d38c16d Added a link to jump back to the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 400
diff changeset
79 mapping.findForward("selectfis").getPath());
002a4d38c16d Added a link to jump back to the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 400
diff changeset
80
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
81 XSLTransformer transformer = new XSLTransformer();
401
002a4d38c16d Added a link to jump back to the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 400
diff changeset
82 transformer.addParameter("selectfis", fisUrl);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
83
400
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
84 Node dynamicUINode = new XMLUtils().getNodeXPath(
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
85 artifactdescription.getCurrentUI(), "art:dynamic"
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
86 );
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
87
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
88 if (dynamicUINode != null){
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
89 String ui = transformer.transform(
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
90 dynamicUINode,
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
91 "UTF-8",
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
92 request.getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
93
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
94 request.setAttribute("ui", ui);
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
95 }
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
96
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
97 Node staticUINode = new XMLUtils().getNodeXPath(
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
98 artifactdescription.getCurrentUI(), "art:static"
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
99 );
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
100
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
101 if (staticUINode != null) {
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
102 String staticUI = transformer.transform(
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
103 staticUINode,
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
104 "UTF-8",
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
105 request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
106 request.setAttribute("staticui", staticUI);
a8b1875dcd93 Just include a select box for choosing the fis if there is no static part in the describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 390
diff changeset
107 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
108
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
109 // return succsess
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
110 return super.execute(mapping, form, request, response);
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
111 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
112 log.error(e, e);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
113 request.setAttribute(
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
114 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 35
diff changeset
115 .getMessage());
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
116 return super.getExceptionForward(mapping);
19
1557bea6cb55 Do some Imporvements for Userfriendly exceptionhandling.
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
117 }
8
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 }
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 /**
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 * Constructor
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 */
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 public SelectArtifactFactoryAction() {
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 }
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125
65ff6fcfee0c Some Basic Stuff for WebProjects
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 }

http://dive4elements.wald.intevation.org