annotate gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java @ 699:af22fa5567a6

Removed trailing whitespace. gnv/trunk@935 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 17 Apr 2010 09:31:48 +0000
parents 254f062e334b
children 0441e78cd900
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
396
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
3 import de.intevation.gnv.action.sessionmodel.SessionModel;
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
4 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
5
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
6 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
7 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
8
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
9 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
396
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
10 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
11
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
12 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
13 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
14
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.log4j.Logger;
396
8330c1dbab34 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 394
diff changeset
16
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
17 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
18 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
19 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
20
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
21 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
22 * 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
23 * artifact. After calling the advance operation of the artifact server have
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
24 * been called successfully, the describe document of the current artifact is
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
25 * fetched and a new gui is rendered.
699
af22fa5567a6 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 690
diff changeset
26 *
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
27 * @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
28 */
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
29 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
30
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
31
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
32 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
33
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
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 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
39 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
40 }
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
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
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 @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
44 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
45 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
46 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
47 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
48 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
49 ) 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
50
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
51 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
52 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
53
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
54 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
55 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
56 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
57 request.setAttribute(
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 580
diff changeset
58 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_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
59 "SessionTimeout has occured");
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 new FetchArtifactFactoriesAction().execute(
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
61 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
62
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
63 return super.execute(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
64 }
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
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
66 // 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
67
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
68 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
69 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
70 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
71 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
72
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
73 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
74 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
75
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
76 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
77 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
78
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
79 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
80 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
81 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
82 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
83 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
84 );
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 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
87 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
88 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
89 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
90 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
91 }
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
92
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 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
94 }
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 }
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
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org