Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java @ 684:57fa8019fbdc
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
gnv/trunk@858 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 09:40:35 +0000 |
parents | d49e8695786c |
children | 254f062e334b |
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 /** |
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
|
22 * @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
|
23 * |
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
|
24 */ |
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
|
25 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
|
26 |
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 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
|
29 |
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 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
|
31 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
|
32 |
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 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
|
35 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
|
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 |
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 @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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 ) 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
|
46 |
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 String id = request.getSession().getId(); |
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 |
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
|
49 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
|
50 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
|
51 |
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
|
52 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
|
53 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
|
54 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
|
55 request.setAttribute( |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
580
diff
changeset
|
56 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
|
57 "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
|
58 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
|
59 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
|
60 |
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 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
|
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 |
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
|
64 // 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
|
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 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
|
67 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
|
68 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
|
69 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
|
70 |
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
|
71 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
|
72 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
|
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 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
|
75 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
|
76 |
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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 ); |
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 } |
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 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 } |
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
|
90 |
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
|
91 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
|
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 } |
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
|
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |