/** * @see Action#execute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse) * @param actionMapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The request we are processing * @param response The response we are creating * @pre actionForm instanceof CrudDynaActionForm; * @pre ; actionMapping contains forward with name "success" * @throws TechnicalException A fatal error from which recovery is not possible. */ public final ActionForward execute( final ActionMapping actionMapping, final ActionForm actionForm, final HttpServletRequest request, final HttpServletResponse response) throws TechnicalException { if (LOG.isDebugEnabled()) { LOG.debug("start action request processing ..."); // $NON-NLS-1$ } assert actionForm instanceof CrudDynaActionForm; CrudDynaActionForm form = ((CrudDynaActionForm) actionForm); ActionForward forward = actionMapping.findForward(ILLEGAL_ACCESS); if (requestParamExistsAndIsNotEmpty(REQUEST_MODE_CANCEL_NEW, request)) { String referer = request.getParameter("referer"); // $NON-NLS-1$ referer = referer.replaceAll("https?://.*/.*/", "/"); // $NON-NLS-1$ //$NON-NLS-2$ forward = new ActionForward(referer, true); } else { // handle each mode, after checking that this user has the rights try { if (requestParamExistsAndIsNotEmpty(REQUEST_MODE_EDIT, request)) { if ((getSecurityStrategy() != null) && getSecurityStrategy().hasEditRights(request, actionMapping, actionForm)) { forward = actionMapping.getInputForward(); templateRetrieve(form, true, request); } } else if (requestParamExistsAndIsNotEmpty(REQUEST_MODE_NEW, request)) { if ((getSecurityStrategy() != null) && getSecurityStrategy().hasNewRights(request, actionMapping, actionForm)) { forward = actionMapping.getInputForward(); templateNew(form, request); } } else if (requestParamExistsAndIsNotEmpty(REQUEST_MODE_UPDATE, request)) { if ((getSecurityStrategy() != null) && getSecurityStrategy().hasUpdateRights(request, actionMapping, actionForm)) { forward = actionMapping.getInputForward(); templateUpdate(form, request); // return to edit mode on errors } } else if (requestParamExistsAndIsNotEmpty(REQUEST_MODE_CREATE, request)) { if ((getSecurityStrategy() != null) && getSecurityStrategy().hasCreateRights(request, actionMapping, actionForm)) { forward = actionMapping.getInputForward(); templateCreate(form, request); } } else if (requestParamExistsAndIsNotEmpty(REQUEST_MODE_DELETE, request)) { if ((getSecurityStrategy() != null) && getSecurityStrategy().hasDeleteRights(request, actionMapping, actionForm)) { forward = actionMapping.getInputForward(); templateDelete(form, request); } } else { // display mode if (LOG.isDebugEnabled() && !requestParamExistsAndIsNotEmpty(REQUEST_MODE_DISPLAY, request)) { LOG.debug( "no dispatch parameter match found; " //$NON-NLS-1$ + "doing default display retrieve"); //$NON-NLS-1$ } if ((getSecurityStrategy() != null) && getSecurityStrategy().hasDisplayRigths(request, actionMapping, actionForm)) { forward = actionMapping.getInputForward(); templateRetrieve(form, false, request); } } form.releaseBean(); if (getSecurityStrategy() != null) { // which buttons do we want to show on the next page? form.setCreateable( getSecurityStrategy().hasCreateRights(request, actionMapping, actionForm)); form.setEditable(getSecurityStrategy().hasEditRights(request, actionMapping, actionForm)); form.setDeleteable( getSecurityStrategy().hasDeleteRights(request, actionMapping, actionForm)); } else { // no security strategy: all is allowed form.setCreateable(true); form.setEditable(true); form.setDeleteable(true); } } catch (IdException idExc) { if (LOG.isDebugEnabled()) { LOG.debug("id exception", idExc); // $NON-NLS-1$ } request.setAttribute(REQUEST_ATTRIBUTE_KEY_NOTFOUND, idExc); forward = actionMapping.findForward(FORWARD_NOTFOUND); } catch (CompoundPropertyException cpExc) { if (LOG.isDebugEnabled()) { LOG.debug("property exception", cpExc); // $NON-NLS-1$ } assert cpExc.isClosed(); form.setCompoundPropertyException(cpExc); forward = actionMapping.getInputForward(); form.releaseBean(); } } if (LOG.isDebugEnabled()) { LOG.debug( "action request processing completed; forward = " //$NON-NLS-1$ + forward.toString()); } return forward; }