|
From: Marc B. <mb...@us...> - 2005-11-14 21:57:29
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8285 Added Files: Tag: itrackerhibernate RemoveWorkflowScriptAction.java Log Message: add Action to delete workflow scripts --- NEW FILE: RemoveWorkflowScriptAction.java --- /* * RemoveWorkflowScriptAction.java * * Created on 13. November 2005, 04:51 */ package cowsultants.itracker.web.actions; import cowsultants.itracker.ejb.beans.entity.WorkflowScriptBean; import cowsultants.itracker.ejb.beans.session.WorkflowScriptFactory; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.util.Constants; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; /** * Action to remove a workflow script * * <ol> * <li>get all project and remove the script to be deleted</li> * <li>delete the script</li> * </ol> * * @author mb...@bc... */ public class RemoveWorkflowScriptAction extends ITrackerAction { /** * executes the action which removes a workflow script * * @param form the form with user input * @param request the request triggering the action * @param response response to the client * @param mapping The action mapping * * @throws ServletException thrown if execution fails * @throws IOException thrown if io to client fails * * @return the <code>ActionForward</code> to forward to */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); ActionForward fw = mapping.findForward("error"); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } // check permissions HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } try { // get the id from the form Integer scriptId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); // remove the script this.getITrackerServices().getSystemConfiguration() .removeWorkflowScript(scriptId); // find the mapping for the list of all worksflows fw = mapping.findForward( "listworkflow" ); } catch (InvocationTargetException ex) { Logger.logError( ex.getMessage(), ex ); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } catch (NoSuchMethodException ex) { Logger.logError( ex.getMessage(), ex ); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } catch (IllegalAccessException ex) { Logger.logError( ex.getMessage(), ex ); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } if(! errors.isEmpty()) { this.saveErrors(request, errors); } return fw; } } |