private void intermediateCommit() throws SQLException { ourContext.commit(); reloadRequiredEntities(); }
/** * Process the save or remove step. If the user has selected to * remove their submission then remove it. * * @param context The current DSpace content * @param id The unique ID of the current workspace/workflow * @param request The cocoon request object. */ public static void processSaveOrRemove(Context context, String id, Request request) throws SQLException, AuthorizeException, IOException { if (request.getParameter("submit_remove") != null) { // If they selected to remove the item then delete everything. WorkspaceItem workspace = findWorkspace(context,id); workspace.deleteAll(); context.commit(); } }
private void updateFileName(DBConnection dspaceDbConnection, Context c, Item item, String fName) throws Exception { try{ c.turnOffAuthorisationSystem() Bundle[] bundles = item.getBundles("ORIGINAL"); for (int i = 0; i < bundles.length; i++) { Bitstream[] bitstreams = bundles[i].getBitstreams(); for (int j = 0; j < bitstreams.length; j++) { bitstreams[j].setName(fileName); bitstreams[j].update(); log.info("file name change:" + fileName); } } c.commit(); } finally { c.restoreAuthSystemState() }
abort(); } else { commit();
/** * Set a specific step and page as reached. * It will also "set back" where a user has reached. * * @param context The current DSpace content * @param id The unique ID of the current workflow/workspace * @param step the step to set as reached, can be also a previous reached step * @param page the page (within the step) to set as reached, can be also a previous reached page */ public static void setBackPageReached(Context context, String id, int step, int page) throws SQLException, AuthorizeException, IOException { InProgressSubmission submission = findSubmission(context, id); if (submission instanceof WorkspaceItem) { WorkspaceItem workspaceItem = (WorkspaceItem) submission; workspaceItem.setStageReached(step); workspaceItem.setPageReached(page > 0 ? page : 1); workspaceItem.update(); context.commit(); } }
context.commit();
context.commit();
/** * Delete a collection's template item (which is not a member of the collection). * * @param context * @param collectionID * @return * @throws SQLException * @throws AuthorizeException * @throws IOException */ public static FlowResult processDeleteTemplateItem(Context context, int collectionID) throws SQLException, AuthorizeException, IOException { FlowResult result = new FlowResult(); Collection collection = Collection.find(context, collectionID); collection.removeTemplateItem(); context.commit(); result.setContinue(true); result.setOutcome(true); return result; }
/** * Update the provided workflowItem to advance to the next workflow * step. If this was the last thing needed before the item is * committed to the repository then return true, otherwise false. * * @param context The current DSpace content * @param id The unique ID of the current workflow */ public static boolean processApproveTask(Context context, String id) throws SQLException, UIException, ServletException, AuthorizeException, IOException { WorkflowItem workflowItem = findWorkflow(context, id); Item item = workflowItem.getItem(); // Advance the item along the workflow WorkflowManager.advance(context, workflowItem, context.getCurrentUser()); // FIXME: This should be a return value from advance() // See if that gave the item a Handle. If it did, // the item made it into the archive, so we // should display a suitable page. String handle = HandleManager.findHandle(context, item); context.commit(); if (handle != null) { return true; } else { return false; } }
/** * Delete community itself * * @param context The current DSpace context. * @param communityID The community id. * @return A process result's object. */ public static FlowResult processDeleteCommunity(Context context, int communityID) throws SQLException, AuthorizeException, IOException { FlowResult result = new FlowResult(); Community community = Community.find(context, communityID); community.delete(); context.commit(); result.setContinue(true); result.setOutcome(true); result.setMessage(new Message("default","The community was successfully deleted.")); return result; }
context.commit();
/** * Withdraw the specified item, this method assumes that the action has been confirmed. * * @param context The DSpace context * @param itemID The id of the to-be-withdrawn item. * @return A result object */ public static FlowResult processWithdrawItem(Context context, int itemID) throws SQLException, AuthorizeException, IOException { FlowResult result = new FlowResult(); result.setContinue(false); Item item = Item.find(context, itemID); item.withdraw(); context.commit(); result.setContinue(true); result.setOutcome(true); result.setMessage(T_item_withdrawn); return result; }
/** * Reinstate the specified item, this method assumes that the action has been confirmed. * * @param context The DSpace context * @param itemID The id of the to-be-reinstated item. * @return A result object */ public static FlowResult processReinstateItem(Context context, int itemID) throws SQLException, AuthorizeException, IOException { FlowResult result = new FlowResult(); result.setContinue(false); Item item = Item.find(context, itemID); item.reinstate(); context.commit(); result.setContinue(true); result.setOutcome(true); result.setMessage(T_item_reinstated); return result; }
/** * Return the given task back to the pool of unclaimed tasks for another user * to select and preform. * * @param context The current DSpace content * @param id The unique ID of the current workflow */ public static void processUnclaimTask(Context context, String id) throws SQLException, UIException, ServletException, AuthorizeException, IOException { WorkflowItem workflowItem = findWorkflow(context, id); // Return task to pool WorkflowManager.unclaim(context, workflowItem, context.getCurrentUser()); context.commit(); //Log this unclaim action log.info(LogManager.getHeader(context, "unclaim_workflow", "workflow_item_id=" + workflowItem.getID() + ",item_id=" + workflowItem.getItem().getID() + ",collection_id=" + workflowItem.getCollection().getID() + ",new_state=" + workflowItem.getState())); }
/** * Look up the id of the template item for a given collection. * * @param context The current DSpace context. * @param collectionID The collection id. * @return The id of the template item. * @throws IOException */ public static int getTemplateItemID(Context context, int collectionID) throws SQLException, AuthorizeException, IOException { Collection collection = Collection.find(context, collectionID); Item template = collection.getTemplateItem(); if (template == null) { collection.createTemplateItem(); template = collection.getTemplateItem(); collection.update(); template.update(); context.commit(); } return template.getID(); }
/** * Delete collection itself * * @param context The current DSpace context. * @param collectionID The collection id. * @return A process result's object. */ public static FlowResult processDeleteCollection(Context context, int collectionID) throws SQLException, AuthorizeException, IOException { FlowResult result = new FlowResult(); Collection collection = Collection.find(context, collectionID); Community[] parents = collection.getCommunities(); for (Community parent: parents) { parent.removeCollection(collection); parent.update(); } context.commit(); result.setContinue(true); result.setOutcome(true); result.setMessage(new Message("default","The collection was successfully deleted.")); return result; }
/** * Claim this task from the pool of unclaimed task so that this user may * preform the task by either approving or rejecting it. * * @param context The current DSpace content * @param id The unique ID of the current workflow */ public static void processClaimTask(Context context, String id) throws SQLException, UIException, ServletException, AuthorizeException, IOException { WorkflowItem workflowItem = findWorkflow(context, id); if(workflowItem.getState() != WorkflowManager.WFSTATE_STEP1POOL && workflowItem.getState() != WorkflowManager.WFSTATE_STEP2POOL && workflowItem.getState() != WorkflowManager.WFSTATE_STEP3POOL){ //Only allow tasks in the pool to be claimed ! throw new AuthorizeException("Error while claiming task: this task has already been claimed !"); } // Claim the task WorkflowManager.claim(context, workflowItem, context.getCurrentUser()); context.commit(); //log this claim information log.info(LogManager.getHeader(context, "claim_task", "workflow_item_id=" + workflowItem.getID() + "item_id=" + workflowItem.getItem().getID() + "collection_id=" + workflowItem.getCollection().getID() + "newowner_id=" + workflowItem.getOwner().getID() + "new_state=" + workflowItem.getState())); }
context.commit();
context.commit();
@Override public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception { Request request = ObjectModelHelper.getRequest(objectModel); Context context = ContextUtil.obtainContext(objectModel); // Or the user selected a checkbox full of workflow IDs int[] workflowIDs = Util.getIntParameters(request, "workflowID"); if (workflowIDs != null) { for (int workflowID : workflowIDs) { PoolTask poolTask = PoolTask.findByWorkflowIdAndEPerson(context, workflowID, context.getCurrentUser().getID()); XmlWorkflowItem workflowItem = XmlWorkflowItem.find(context, workflowID); Workflow workflow = WorkflowFactory.getWorkflow(workflowItem.getCollection()); WorkflowActionConfig currentAction = workflow.getStep(poolTask.getStepID()).getActionConfig(poolTask.getActionID()); XmlWorkflowManager.doState(context, context.getCurrentUser(), request, workflowID, workflow, currentAction); } context.commit(); } return null; } }