annotate gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java @ 991:33198e55371c

Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection. gnv/trunk@1192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Jun 2010 15:13:08 +0000
parents 0441e78cd900
children 28a0628b11b0
rev   line source
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
1 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
2
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
3 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
4 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
5
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
6 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
7 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
8 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
9 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
10
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
11 import de.intevation.gnv.action.sessionmodel.SessionModel;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
12 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
13 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
14 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
15 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
16 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
17
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
18 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
19 * 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
20 * artifact. After calling the advance operation of the artifact server have
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
21 * been called successfully, the describe document of the current artifact is
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
22 * fetched and a new gui is rendered.
699
af22fa5567a6 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 690
diff changeset
23 *
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
24 * @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
25 */
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
26 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
27
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
28
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
29 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
30
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
31 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
32 * the logger, used to log exceptions and additonaly information
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
33 */
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
34 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
35 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
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
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
38 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
39 * Constructor
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 699
diff changeset
40 */
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
41 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
42 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
43 }
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
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
46 @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
47 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
48 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
49 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
50 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
51 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
52 ) 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
53
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
54 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
55 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
56
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
57 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
58 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
59 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
60 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
61 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
62 "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
63 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
64 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
65 }
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
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
67 // 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
68
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
69 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
70 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
71 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
72 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
73
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
74 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
75 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
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 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
78 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
79
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
80 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
81 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
82 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
83 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
84 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
85 );
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
86 }
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
87 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
88 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
89 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
90 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
91 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
92 }
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
93
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
94 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
95 }
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
96 }
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
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org