Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java @ 963:0441e78cd900
Add more Javadocs
gnv/trunk@1107 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 18 May 2010 11:09:33 +0000 |
parents | f550bd27a3f1 |
children | 33198e55371c |
comparison
equal
deleted
inserted
replaced
962:e7fda0ae8b92 | 963:0441e78cd900 |
---|---|
2 | 2 |
3 import javax.servlet.http.HttpServletRequest; | 3 import javax.servlet.http.HttpServletRequest; |
4 import javax.servlet.http.HttpServletResponse; | 4 import javax.servlet.http.HttpServletResponse; |
5 | 5 |
6 import org.apache.log4j.Logger; | 6 import org.apache.log4j.Logger; |
7 | |
8 import org.apache.struts.action.Action; | 7 import org.apache.struts.action.Action; |
9 import org.apache.struts.action.ActionForm; | 8 import org.apache.struts.action.ActionForm; |
10 import org.apache.struts.action.ActionForward; | 9 import org.apache.struts.action.ActionForward; |
11 import org.apache.struts.action.ActionMapping; | 10 import org.apache.struts.action.ActionMapping; |
12 | 11 |
13 /** | 12 /** |
13 * Basicimplemantation for all Actions which should serv request for | |
14 * the GNV. | |
14 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | 15 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
15 * | 16 * |
16 */ | 17 */ |
17 public class ArtifactDatabaseActionBase extends Action { | 18 public class ArtifactDatabaseActionBase extends Action { |
18 | 19 |
20 /** | |
21 * The id of the action which should used if the execution | |
22 * of the action was successful. | |
23 */ | |
19 protected final static String SUCCSESS_FORWARD_ID = "success"; | 24 protected final static String SUCCSESS_FORWARD_ID = "success"; |
25 | |
26 /** | |
27 * The id of the action which should be used if an exception has occurred | |
28 * during the execution. | |
29 */ | |
20 protected final static String EXCEPTION_FORWARD_ID = "success"; | 30 protected final static String EXCEPTION_FORWARD_ID = "success"; |
21 | 31 |
22 /** | 32 /** |
23 * the logger, used to log exceptions and additonaly information | 33 * the logger, used to log exceptions and additonaly information |
24 */ | 34 */ |
30 */ | 40 */ |
31 public ArtifactDatabaseActionBase() { | 41 public ArtifactDatabaseActionBase() { |
32 super(); | 42 super(); |
33 } | 43 } |
34 | 44 |
35 | |
36 @Override | 45 @Override |
37 public ActionForward execute(ActionMapping mapping, ActionForm form, | 46 public ActionForward execute(ActionMapping mapping, ActionForm form, |
38 HttpServletRequest request, | 47 HttpServletRequest request, |
39 HttpServletResponse response) throws Exception { | 48 HttpServletResponse response) throws Exception { |
40 log.debug("ArtifactDatabaseActionBase.execute"); | 49 log.debug("ArtifactDatabaseActionBase.execute"); |
41 | |
42 ActionForward forward = mapping.findForward(SUCCSESS_FORWARD_ID); | 50 ActionForward forward = mapping.findForward(SUCCSESS_FORWARD_ID); |
43 return forward; | 51 return forward; |
44 } | 52 } |
45 | 53 |
46 | 54 /** |
55 * Returns the Action that should be used if an exception has occurred. | |
56 * @param mapping the mapping which holds all available Actions | |
57 * @return the Action that should be used. | |
58 */ | |
47 protected ActionForward getExceptionForward(ActionMapping mapping) { | 59 protected ActionForward getExceptionForward(ActionMapping mapping) { |
48 log.debug("ArtifactDatabaseActionBase.getExceptionForward"); | 60 log.debug("ArtifactDatabaseActionBase.getExceptionForward"); |
49 ActionForward lForward = mapping.findForward(EXCEPTION_FORWARD_ID); | 61 ActionForward lForward = mapping.findForward(EXCEPTION_FORWARD_ID); |
50 return lForward; | 62 return lForward; |
51 } | 63 } |
52 | 64 |
53 | 65 /** |
66 * Encodes the <code>String</code> to prevent cross-site-scripting | |
67 * @param s the string that should be encoded | |
68 * @return the encoded string | |
69 */ | |
54 protected String encode(String s) { | 70 protected String encode(String s) { |
55 log.debug("String to encode: " + s); | 71 log.debug("String to encode: " + s); |
56 s = s.replaceAll("<", "<"); | 72 s = s.replaceAll("<", "<"); |
57 s = s.replaceAll(">", ">"); | 73 s = s.replaceAll(">", ">"); |
58 s = s.replaceAll("\"", """); | 74 s = s.replaceAll("\"", """); |
60 | 76 |
61 log.debug("Encoded string: " + s); | 77 log.debug("Encoded string: " + s); |
62 return s; | 78 return s; |
63 } | 79 } |
64 | 80 |
65 | 81 /** |
82 * Encodes the <code>StringArray</code> to prevent cross-site-scripting | |
83 * @param s the stringarray that should be encoded | |
84 * @return the encoded stringarray | |
85 */ | |
66 protected String[] encode(String[] s) { | 86 protected String[] encode(String[] s) { |
67 if (s == null) | 87 if (s == null) |
68 return null; | 88 return null; |
69 | 89 |
70 String[] good = new String[s.length]; | 90 String[] good = new String[s.length]; |