コード例 #1
0
ファイル: FlowUtils.java プロジェクト: UWLibrary/DSpace
  /**
   * Obtains the submission info for the current submission process. If a submissionInfo object has
   * already been created for this HTTP request, it is re-used, otherwise it is created.
   *
   * @param objectModel the cocoon Objectmodel
   * @param workspaceID the workspaceID of the submission info to obtain
   * @return a SubmissionInfo object
   */
  public static SubmissionInfo obtainSubmissionInfo(Map objectModel, String workspaceID)
      throws SQLException, IOException, AuthorizeException {
    Request request = ObjectModelHelper.getRequest(objectModel);
    Context context = ContextUtil.obtainContext(objectModel);

    // try loading subInfo from HTTP request
    SubmissionInfo subInfo = (SubmissionInfo) request.getAttribute(DSPACE_SUBMISSION_INFO);

    // get the submission represented by the WorkspaceID
    InProgressSubmission submission = findSubmission(context, workspaceID);

    // if no submission info, or wrong submission info, reload it!
    if ((subInfo == null && submission != null)
        || (subInfo != null
            && submission != null
            && subInfo.getSubmissionItem().getID() != submission.getID())) {
      try {
        final HttpServletRequest httpRequest =
            (HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);

        // load submission info
        subInfo = SubmissionInfo.load(httpRequest, submission);

        // Set the session ID
        context.setExtraLogInfo("session_id=" + request.getSession().getId());

        // Store the submissionInfo in the request
        request.setAttribute(DSPACE_SUBMISSION_INFO, subInfo);
      } catch (Exception e) {
        throw new SQLException("Error loading Submission Info: " + e.getMessage(), e);
      }
    } else if (subInfo == null && submission == null) {
      throw new SQLException(
          "Unable to load Submission Information, since WorkspaceID (ID:"
              + workspaceID
              + ") is not a valid in-process submission.");
    }

    return subInfo;
  }