@Override public WorkspaceItem abort(Context c, XmlWorkflowItem wi, EPerson e) throws AuthorizeException, SQLException, IOException { if (!authorizeService.isAdmin(c)) { throw new AuthorizeException("You must be an admin to abort a workflow"); } c.turnOffAuthorisationSystem(); // Restore permissions for the submitter // convert into personal workspace WorkspaceItem wsi = returnToWorkspace(c, wi); log.info( LogManager.getHeader( c, "abort_workflow", "workflow_item_id=" + wi.getID() + "item_id=" + wsi.getItem().getID() + "collection_id=" + wi.getCollection().getID() + "eperson_id=" + e.getID())); c.restoreAuthSystemState(); return wsi; }
/** * startWithoutNotify() starts the workflow normally, but disables notifications (useful for large * imports,) for the first workflow step - subsequent notifications happen normally */ @Override public XmlWorkflowItem startWithoutNotify(Context context, WorkspaceItem wsi) throws SQLException, AuthorizeException, IOException, WorkflowException { // make a hash table entry with item ID for no notify // notify code checks no notify hash for item id noEMail.put(wsi.getItem().getID(), Boolean.TRUE); return start(context, wsi); }
/** * Return the workflow item to the workspace of the submitter. The workflow item is removed, and a * workspace item created. * * @param c Context * @param wfi WorkflowItem to be 'dismantled' * @return the workspace item * @throws java.io.IOException ... * @throws java.sql.SQLException ... * @throws org.dspace.authorize.AuthorizeException ... */ protected WorkspaceItem returnToWorkspace(Context c, XmlWorkflowItem wfi) throws SQLException, IOException, AuthorizeException { // authorize a DSpaceActions.REJECT // stop workflow deleteAllTasks(c, wfi); c.turnOffAuthorisationSystem(); // Also clear all info for this step workflowRequirementsService.clearInProgressUsers(c, wfi); // Remove (if any) the workflowItemroles for this item workflowItemRoleService.deleteForWorkflowItem(c, wfi); Item myitem = wfi.getItem(); // Restore permissions for the submitter grantUserAllItemPolicies(c, myitem, myitem.getSubmitter()); // FIXME: How should this interact with the workflow system? // FIXME: Remove license // FIXME: Provenance statement? // Create the new workspace item row WorkspaceItem workspaceItem = workspaceItemService.create(c, wfi); workspaceItem.setMultipleFiles(wfi.hasMultipleFiles()); workspaceItem.setMultipleTitles(wfi.hasMultipleTitles()); workspaceItem.setPublishedBefore(wfi.isPublishedBefore()); workspaceItemService.update(c, workspaceItem); // myitem.update(); log.info( LogManager.getHeader( c, "return_to_workspace", "workflow_item_id=" + wfi.getID() + "workspace_item_id=" + workspaceItem.getID())); // Now remove the workflow object manually from the database xmlWorkflowItemService.deleteWrapper(c, wfi); return workspaceItem; }
@Override public XmlWorkflowItem start(Context context, WorkspaceItem wsi) throws SQLException, AuthorizeException, IOException, WorkflowException { try { Item myitem = wsi.getItem(); Collection collection = wsi.getCollection(); Workflow wf = xmlWorkflowFactory.getWorkflow(collection); XmlWorkflowItem wfi = xmlWorkflowItemService.create(context, myitem, collection); wfi.setMultipleFiles(wsi.hasMultipleFiles()); wfi.setMultipleTitles(wsi.hasMultipleTitles()); wfi.setPublishedBefore(wsi.isPublishedBefore()); xmlWorkflowItemService.update(context, wfi); removeUserItemPolicies(context, myitem, myitem.getSubmitter()); grantSubmitterReadPolicies(context, myitem); context.turnOffAuthorisationSystem(); Step firstStep = wf.getFirstStep(); if (firstStep.isValidStep(context, wfi)) { activateFirstStep(context, wf, firstStep, wfi); } else { // Get our next step, if none is found, archive our item firstStep = wf.getNextStep(context, wfi, firstStep, ActionResult.OUTCOME_COMPLETE); if (firstStep == null) { archive(context, wfi); } else { activateFirstStep(context, wf, firstStep, wfi); } } // remove the WorkspaceItem workspaceItemService.deleteWrapper(context, wsi); context.restoreAuthSystemState(); return wfi; } catch (WorkflowConfigurationException e) { throw new WorkflowException(e); } }