Mercurial > dive4elements > gnv-client
view 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 |
line wrap: on
line source
package de.intevation.gnv.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; /** * Basicimplemantation for all Actions which should serv request for * the GNV. * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> * */ public class ArtifactDatabaseActionBase extends Action { /** * The id of the action which should used if the execution * of the action was successful. */ protected final static String SUCCSESS_FORWARD_ID = "success"; /** * The id of the action which should be used if an exception has occurred * during the execution. */ protected final static String EXCEPTION_FORWARD_ID = "success"; /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger .getLogger(ArtifactDatabaseActionBase.class); /** * Constructor */ public ArtifactDatabaseActionBase() { super(); } @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("ArtifactDatabaseActionBase.execute"); ActionForward forward = mapping.findForward(SUCCSESS_FORWARD_ID); return forward; } /** * Returns the Action that should be used if an exception has occurred. * @param mapping the mapping which holds all available Actions * @return the Action that should be used. */ protected ActionForward getExceptionForward(ActionMapping mapping) { log.debug("ArtifactDatabaseActionBase.getExceptionForward"); ActionForward lForward = mapping.findForward(EXCEPTION_FORWARD_ID); return lForward; } /** * Encodes the <code>String</code> to prevent cross-site-scripting * @param s the string that should be encoded * @return the encoded string */ protected String encode(String s) { log.debug("String to encode: " + s); s = s.replaceAll("<", "<"); s = s.replaceAll(">", ">"); s = s.replaceAll("\"", """); s = s.replaceAll("&", "&"); log.debug("Encoded string: " + s); return s; } /** * Encodes the <code>StringArray</code> to prevent cross-site-scripting * @param s the stringarray that should be encoded * @return the encoded stringarray */ protected String[] encode(String[] s) { if (s == null) return null; String[] good = new String[s.length]; for (int i = 0; i < good.length; i++) { good[i] = encode(s[i]); } return good; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :