annotate gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java @ 1022:28a0628b11b0

Added license file and license header. gnv/trunk@1258 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:15:08 +0000
parents 33198e55371c
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
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.action;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import javax.servlet.http.HttpServletRequest;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import javax.servlet.http.HttpServletResponse;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.apache.log4j.Logger;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.apache.struts.action.ActionForm;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.apache.struts.action.ActionForward;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.apache.struts.action.ActionMapping;
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
19 import de.intevation.gnv.action.sessionmodel.SessionModel;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
20 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
21 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
22 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
23 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
24 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
25
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
27 * This controller is used to step back to a previous state of the current
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
28 * artifact. After calling the advance operation of the artifact server have
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
29 * been called successfully, the describe document of the current artifact is
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
30 * fetched and a new gui is rendered.
699
af22fa5567a6 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 690
diff changeset
31 *
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
32 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 */
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
34 public class PreviousArtifactStepAction extends DescribeUIAction {
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public static final String URL_STATE_KEY = "target";
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
39 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
40 * the logger, used to log exceptions and additonaly information
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
41 */
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 private static Logger logger =
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 Logger.getLogger(PreviousArtifactStepAction.class);
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
46 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
47 * Constructor
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
48 */
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public PreviousArtifactStepAction() {
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 super();
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 }
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 @Override
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 public ActionForward execute(
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 ActionMapping mapping,
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 ActionForm form,
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 HttpServletRequest request,
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 HttpServletResponse response
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 ) throws Exception {
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
62 SessionModel session = SessionModelFactory.getInstance().getSessionModel(
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
63 request);
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
580
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
65 ArtifactDescription ad = session.getArtifactDescription();
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
66 if (ad == null) {
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
67 logger.warn("Session timed out.");
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
68 request.setAttribute(
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: 963
diff changeset
69 CommunicationKeys.REQUEST_EXCEPTION_SESSION_ID,
580
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
70 "SessionTimeout has occured");
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: 963
diff changeset
71 return new FetchArtifactFactoriesAction().execute(
580
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
72 mapping, form, request, response);
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
73 }
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
74
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
75 // TODO check if target is reachable
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
77 ArtifactDatabaseClientFactory f =
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
78 ArtifactDatabaseClientFactory.getInstance();
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
79 ArtifactDatabaseClient client =
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
80 f.getArtifactDatabaseClient(getLocale(request));
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
82 ArtifactObject artifactFactory = session.getSelectedArtifactFactory();
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
83 ArtifactObject currentArtifact = session.getCurrentArtifact();
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
85 String target = (String) request.getParameter(URL_STATE_KEY);
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
86 logger.debug("Step back to previous state: " + target);
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
87
580
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
88 try {
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
89 client.doAdvance(
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
90 artifactFactory,
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
91 currentArtifact,
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
92 target
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
93 );
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
94 }
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
95 catch (Exception e) {
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
96 logger.error(e, e);
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
97 request.setAttribute(
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
98 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID,
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
99 e.getMessage());
377da78ed36b Display an exception if an error occured while stepping back to a former state (issue183).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 409
diff changeset
100 }
394
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 return super.execute(mapping, form, request, response);
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 }
14eecfde4607 Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 }
409
df78178e1180 Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 396
diff changeset
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org