mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Alternate way to restart workflow in case of decline
This commit is contained in:
@@ -18,6 +18,7 @@ import org.dspace.core.Context;
|
|||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service interface class for the WorkflowService framework.
|
* Service interface class for the WorkflowService framework.
|
||||||
@@ -100,6 +101,9 @@ public interface WorkflowService<T extends WorkflowItem> {
|
|||||||
String rejection_message)
|
String rejection_message)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
public void restartWorkflow(Context context, XmlWorkflowItem wi, EPerson decliner, String provenance)
|
||||||
|
throws SQLException, AuthorizeException, IOException, WorkflowException;
|
||||||
|
|
||||||
public String getMyDSpaceLink();
|
public String getMyDSpaceLink();
|
||||||
|
|
||||||
public void deleteCollection(Context context, Collection collection)
|
public void deleteCollection(Context context, Collection collection)
|
||||||
|
@@ -1076,6 +1076,49 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
return wsi;
|
return wsi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restartWorkflow(Context context, XmlWorkflowItem wi, EPerson decliner, String provenance)
|
||||||
|
throws SQLException, AuthorizeException, IOException, WorkflowException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException("You must be an admin to restart a workflow");
|
||||||
|
}
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
// rejection provenance
|
||||||
|
Item myitem = wi.getItem();
|
||||||
|
|
||||||
|
// Here's what happened
|
||||||
|
String provDescription =
|
||||||
|
provenance + " Declined by " + getEPersonName(decliner) + " on " + DCDate.getCurrent().toString() +
|
||||||
|
" (GMT) ";
|
||||||
|
|
||||||
|
// Add to item as a DC field
|
||||||
|
itemService
|
||||||
|
.addMetadata(context, myitem, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en", provDescription);
|
||||||
|
|
||||||
|
//Clear any workflow schema related metadata
|
||||||
|
itemService
|
||||||
|
.clearMetadata(context, myitem, WorkflowRequirementsService.WORKFLOW_SCHEMA, Item.ANY, Item.ANY, Item.ANY);
|
||||||
|
|
||||||
|
itemService.update(context, myitem);
|
||||||
|
|
||||||
|
// remove policy for controller
|
||||||
|
removeUserItemPolicies(context, myitem, decliner);
|
||||||
|
revokeReviewerPolicies(context, myitem);
|
||||||
|
|
||||||
|
// convert into personal workspace
|
||||||
|
WorkspaceItem wsi = returnToWorkspace(context, wi);
|
||||||
|
|
||||||
|
log.info(LogHelper.getHeader(context, "decline_workflow", "workflow_item_id="
|
||||||
|
+ wi.getID() + "item_id=" + wi.getItem().getID() + "collection_id=" + wi.getCollection().getID() +
|
||||||
|
"eperson_id=" + decliner.getID()));
|
||||||
|
|
||||||
|
// Restart workflow
|
||||||
|
this.startWithoutNotify(context, wsi);
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the workflow item to the workspace of the submitter. The workflow
|
* Return the workflow item to the workspace of the submitter. The workflow
|
||||||
* item is removed, and a workspace item created.
|
* item is removed, and a workspace item created.
|
||||||
|
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.service.XmlWorkflowService;
|
||||||
import org.dspace.xmlworkflow.state.actions.Action;
|
import org.dspace.xmlworkflow.state.actions.Action;
|
||||||
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
@@ -36,6 +36,8 @@ public abstract class ProcessingAction extends Action {
|
|||||||
protected ClaimedTaskService claimedTaskService;
|
protected ClaimedTaskService claimedTaskService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected ItemService itemService;
|
protected ItemService itemService;
|
||||||
|
@Autowired
|
||||||
|
protected XmlWorkflowService xmlWorkflowService;
|
||||||
|
|
||||||
public static final String SUBMIT_EDIT_METADATA = "submit_edit_metadata";
|
public static final String SUBMIT_EDIT_METADATA = "submit_edit_metadata";
|
||||||
public static final String SUBMIT_CANCEL = "submit_cancel";
|
public static final String SUBMIT_CANCEL = "submit_cancel";
|
||||||
@@ -73,8 +75,8 @@ public abstract class ProcessingAction extends Action {
|
|||||||
|
|
||||||
// We have pressed reject, so remove the task the user has & put it back
|
// We have pressed reject, so remove the task the user has & put it back
|
||||||
// to a workspace item
|
// to a workspace item
|
||||||
XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService().sendWorkflowItemBackSubmission(c, wfi,
|
xmlWorkflowService.sendWorkflowItemBackSubmission(c, wfi, c.getCurrentUser(), this.getProvenanceStartId(),
|
||||||
c.getCurrentUser(), this.getProvenanceStartId(), reason);
|
reason);
|
||||||
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@ import org.dspace.core.Context;
|
|||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowException;
|
import org.dspace.workflow.WorkflowException;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
import org.dspace.xmlworkflow.service.XmlWorkflowService;
|
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
@@ -120,11 +119,8 @@ public class SingleUserReviewAction extends ProcessingAction {
|
|||||||
*/
|
*/
|
||||||
private ActionResult processDecline(Context c, XmlWorkflowItem wfi)
|
private ActionResult processDecline(Context c, XmlWorkflowItem wfi)
|
||||||
throws SQLException, IOException, AuthorizeException, WorkflowException {
|
throws SQLException, IOException, AuthorizeException, WorkflowException {
|
||||||
EPerson user = c.getCurrentUser();
|
|
||||||
c.turnOffAuthorisationSystem();
|
c.turnOffAuthorisationSystem();
|
||||||
XmlWorkflowService xmlWorkflowService = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService();
|
xmlWorkflowService.restartWorkflow(c, wfi, c.getCurrentUser(), this.getProvenanceStartId());
|
||||||
WorkspaceItem workspaceItem = xmlWorkflowService.abort(c, wfi, user);
|
|
||||||
xmlWorkflowService.start(c, workspaceItem);
|
|
||||||
c.restoreAuthSystemState();
|
c.restoreAuthSystemState();
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user