protected void notifyOfReject( Context context, BasicWorkflowItem workflowItem, EPerson e, String reason) { try { // Get the item title String title = getItemTitle(workflowItem); // Get the collection Collection coll = workflowItem.getCollection(); // Get rejector's name String rejector = getEPersonName(e); Locale supportedLocale = I18nUtil.getEPersonLocale(e); Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "submit_reject")); email.addRecipient(workflowItem.getSubmitter().getEmail()); email.addArgument(title); email.addArgument(coll.getName()); email.addArgument(rejector); email.addArgument(reason); email.addArgument(getMyDSpaceLink()); email.send(); } catch (RuntimeException re) { // log this email error log.warn( LogManager.getHeader( context, "notify_of_reject", "cannot email user eperson_id=" + e.getID() + " eperson_email=" + e.getEmail() + " workflow_item_id=" + workflowItem.getID() + ": " + re.getMessage())); throw re; } catch (Exception ex) { // log this email error log.warn( LogManager.getHeader( context, "notify_of_reject", "cannot email user eperson_id=" + e.getID() + " eperson_email=" + e.getEmail() + " workflow_item_id=" + workflowItem.getID() + ": " + ex.getMessage())); } }
@Override public WorkflowActionConfig processOutcome( Context c, EPerson user, Workflow workflow, Step currentStep, WorkflowActionConfig currentActionConfig, ActionResult currentOutcome, XmlWorkflowItem wfi, boolean enteredNewStep) throws IOException, AuthorizeException, SQLException, WorkflowException { if (currentOutcome.getType() == ActionResult.TYPE.TYPE_PAGE || currentOutcome.getType() == ActionResult.TYPE.TYPE_ERROR) { // Our outcome is a page or an error, so return our current action c.restoreAuthSystemState(); return currentActionConfig; } else if (currentOutcome.getType() == ActionResult.TYPE.TYPE_CANCEL || currentOutcome.getType() == ActionResult.TYPE.TYPE_SUBMISSION_PAGE) { // We either pressed the cancel button or got an order to return to the submission page, so // don't return an action // By not returning an action we ensure ourselfs that we go back to the submission page c.restoreAuthSystemState(); return null; } else if (currentOutcome.getType() == ActionResult.TYPE.TYPE_OUTCOME) { Step nextStep = null; WorkflowActionConfig nextActionConfig = null; try { // We have completed our action search & retrieve the next action if (currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) { nextActionConfig = currentStep.getNextAction(currentActionConfig); } if (nextActionConfig != null) { // We remain in the current step since an action is found nextStep = currentStep; nextActionConfig.getProcessingAction().activate(c, wfi); if (nextActionConfig.requiresUI() && !enteredNewStep) { createOwnedTask(c, wfi, currentStep, nextActionConfig, user); return nextActionConfig; } else if (nextActionConfig.requiresUI() && enteredNewStep) { // We have entered a new step and have encountered a UI, return null since the current // user doesn't have anything to do with this c.restoreAuthSystemState(); return null; } else { ActionResult newOutcome = nextActionConfig.getProcessingAction().execute(c, wfi, currentStep, null); return processOutcome( c, user, workflow, currentStep, nextActionConfig, newOutcome, wfi, enteredNewStep); } } else if (enteredNewStep) { // If the user finished his/her step, we keep processing until there is a UI step action // or no step at all nextStep = workflow.getNextStep(c, wfi, currentStep, currentOutcome.getResult()); c.turnOffAuthorisationSystem(); nextActionConfig = processNextStep(c, user, workflow, currentOutcome, wfi, nextStep); // If we require a user interface return null so that the user is redirected to the // "submissions page" if (nextActionConfig == null || nextActionConfig.requiresUI()) { return null; } else { return nextActionConfig; } } else { ClaimedTask task = claimedTaskService.findByWorkflowIdAndEPerson(c, wfi, user); // Check if we have a task for this action (might not be the case with automatic steps) // First add it to our list of finished users, since no more actions remain workflowRequirementsService.addFinishedUser(c, wfi, user); c.turnOffAuthorisationSystem(); // Check if our requirements have been met if ((currentStep.isFinished(c, wfi) && currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) || currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE) { // Delete all the table rows containing the users who performed this task workflowRequirementsService.clearInProgressUsers(c, wfi); // Remove all the tasks deleteAllTasks(c, wfi); nextStep = workflow.getNextStep(c, wfi, currentStep, currentOutcome.getResult()); nextActionConfig = processNextStep(c, user, workflow, currentOutcome, wfi, nextStep); // If we require a user interface return null so that the user is redirected to the // "submissions page" if (nextActionConfig == null || nextActionConfig.requiresUI()) { return null; } else { return nextActionConfig; } } else { // We are done with our actions so go to the submissions page but remove action // ClaimedAction first deleteClaimedTask(c, wfi, task); c.restoreAuthSystemState(); nextStep = currentStep; nextActionConfig = currentActionConfig; return null; } } } catch (Exception e) { log.error("error while processing workflow outcome", e); e.printStackTrace(); } finally { if ((nextStep != null && currentStep != null && nextActionConfig != null) || (wfi.getItem().isArchived() && currentStep != null)) { logWorkflowEvent( c, currentStep.getWorkflow().getID(), currentStep.getId(), currentActionConfig.getId(), wfi, user, nextStep, nextActionConfig); } } } log.error(LogManager.getHeader(c, "Invalid step outcome", "Workflow item id: " + wfi.getID())); throw new WorkflowException("Invalid step outcome"); }