001: /*
002: * WorkflowAbortServlet.java
003: *
004: * Version: $Revision: 1189 $
005: *
006: * Date: $Date: 2005-04-20 09:23:44 -0500 (Wed, 20 Apr 2005) $
007: *
008: * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040: package org.dspace.app.webui.servlet.admin;
041:
042: import java.io.IOException;
043: import java.sql.SQLException;
044:
045: import javax.servlet.ServletException;
046: import javax.servlet.http.HttpServletRequest;
047: import javax.servlet.http.HttpServletResponse;
048:
049: import org.dspace.app.webui.servlet.DSpaceServlet;
050: import org.dspace.app.webui.util.JSPManager;
051: import org.dspace.app.webui.util.UIUtil;
052: import org.dspace.authorize.AuthorizeException;
053: import org.dspace.core.Context;
054: import org.dspace.workflow.WorkflowItem;
055: import org.dspace.workflow.WorkflowManager;
056:
057: /**
058: * Servlet for aborting workflows
059: *
060: * @author dstuve
061: * @version $Revision: 1189 $
062: */
063: public class WorkflowAbortServlet extends DSpaceServlet {
064: protected void doDSGet(Context c, HttpServletRequest request,
065: HttpServletResponse response) throws ServletException,
066: IOException, SQLException, AuthorizeException {
067: // Get displays list of workflows
068: showWorkflows(c, request, response);
069: }
070:
071: protected void doDSPost(Context c, HttpServletRequest request,
072: HttpServletResponse response) throws ServletException,
073: IOException, SQLException, AuthorizeException {
074: String button = UIUtil.getSubmitButton(request, "submit");
075:
076: if (button.equals("submit_abort")) {
077: // bring up the confirm page
078: WorkflowItem wi = WorkflowItem.find(c, UIUtil
079: .getIntParameter(request, "workflow_id"));
080:
081: request.setAttribute("workflow", wi);
082: JSPManager.showJSP(request, response,
083: "/dspace-admin/workflow-abort-confirm.jsp");
084: } else if (button.equals("submit_abort_confirm")) {
085: // do the actual abort
086: WorkflowItem wi = WorkflowItem.find(c, UIUtil
087: .getIntParameter(request, "workflow_id"));
088:
089: WorkflowManager.abort(c, wi, c.getCurrentUser());
090:
091: // now show what's left
092: showWorkflows(c, request, response);
093: } else {
094: // must have been cancel
095: showWorkflows(c, request, response);
096: }
097:
098: // now commit the changes
099: c.complete();
100: }
101:
102: private void showWorkflows(Context c, HttpServletRequest request,
103: HttpServletResponse response) throws ServletException,
104: IOException, SQLException, AuthorizeException {
105: WorkflowItem[] w = WorkflowItem.findAll(c);
106:
107: request.setAttribute("workflows", w);
108: JSPManager.showJSP(request, response,
109: "/dspace-admin/workflow-list.jsp");
110: }
111: }
|