/** * Utility method to store parameters in a map as request attribute until either {@link * #rollback(Map, String)} or {@link #prepareCommit(Map, String)} is called. * * @param objectModel - the objectModel * @param trans_place - request attribute name used for the transient data * @param name - name of the attribute to set * @param value - attribute value */ protected void transientSetAttribute( Map objectModel, String trans_place, String name, Object value) { final Request request = ObjectModelHelper.getRequest(objectModel); Map map = (Map) request.getAttribute(trans_place); if (map == null) { // Need java.util.HashMap here since JXPath does not like the extended version... map = new java.util.HashMap(); } map.put(name, value); request.setAttribute(trans_place, map); }
/** * 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; }