예제 #1
0
  @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);
    }
  }
예제 #2
0
  /**
   * 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;
  }
예제 #3
0
 /*
  * Executes an action and returns the next.
  */
 @Override
 public WorkflowActionConfig doState(
     Context c,
     EPerson user,
     HttpServletRequest request,
     int workflowItemId,
     Workflow workflow,
     WorkflowActionConfig currentActionConfig)
     throws SQLException, AuthorizeException, IOException, MessagingException, WorkflowException {
   try {
     XmlWorkflowItem wi = xmlWorkflowItemService.find(c, workflowItemId);
     Step currentStep = currentActionConfig.getStep();
     if (currentActionConfig.getProcessingAction().isAuthorized(c, request, wi)) {
       ActionResult outcome =
           currentActionConfig.getProcessingAction().execute(c, wi, currentStep, request);
       return processOutcome(
           c, user, workflow, currentStep, currentActionConfig, outcome, wi, false);
     } else {
       throw new AuthorizeException("You are not allowed to to perform this task.");
     }
   } catch (WorkflowConfigurationException e) {
     log.error(
         LogManager.getHeader(
             c,
             "error while executing state",
             "workflow:  "
                 + workflow.getID()
                 + " action: "
                 + currentActionConfig.getId()
                 + " workflowItemId: "
                 + workflowItemId),
         e);
     WorkflowUtils.sendAlert(request, e);
     throw new WorkflowException(e);
   }
 }
예제 #4
0
 @Override
 public void deleteCollection(Context context, Collection collection)
     throws SQLException, IOException, AuthorizeException {
   xmlWorkflowItemService.deleteByCollection(context, collection);
   collectionRoleService.deleteByCollection(context, collection);
 }