@Override public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) { try { WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(), false); Item itemNew = workspaceItem.getItem(); itemService.update(context, itemNew); return itemNew; } catch (SQLException | AuthorizeException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public void end(Context ctx) throws Exception { if (itemsToProcess != null) { for (Item item : itemsToProcess) { ctx.turnOffAuthorisationSystem(); try { itemService.update(ctx, item); } finally { ctx.restoreAuthSystemState(); } } } itemsToProcess = null; }
@Override public void update(Context context, BasicWorkflowItem workflowItem) throws SQLException, AuthorizeException { // FIXME check auth log.info(LogManager.getHeader(context, "update_workflow_item", "workflow_item_id=" + workflowItem.getID())); // Update the item itemService.update(context, workflowItem.getItem()); // Update ourselves workflowItemDAO.save(context, workflowItem); }
@Override public void update(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException { // Authorisation is checked by the item.update() method below log.info(LogManager.getHeader(context, "update_workspace_item", "workspace_item_id=" + workspaceItem.getID())); // Update the item itemService.update(context, workspaceItem.getItem()); // Update ourselves workspaceItemDAO.save(context, workspaceItem); }
@Override public void update(Context context, XmlWorkflowItem workflowItem) throws SQLException, AuthorizeException { // FIXME check auth log.info(LogManager.getHeader(context, "update_workflow_item", "workflowitem_id=" + workflowItem.getID())); // Update the item itemService.update(context, workflowItem.getItem()); xmlWorkflowItemDAO.save(context, workflowItem); }
@Override public Item updateItemState(Context c, Item itemNew, Item previousItem) { try { copyMetadata(c, itemNew, previousItem); createBundlesAndAddBitstreams(c, itemNew, previousItem); try { identifierService.reserve(c, itemNew); } catch (IdentifierException e) { throw new RuntimeException("Can't create Identifier!", e); } // DSpace knows several types of resource policies (see the class // org.dspace.authorize.ResourcePolicy): Submission, Workflow, Custom // and inherited. Submission, Workflow and Inherited policies will be // set automatically as neccessary. We need to copy the custom policies // only to preserve customly set policies and embargos (which are // realized by custom policies with a start date). List<ResourcePolicy> policies = authorizeService.findPoliciesByDSOAndType(c, previousItem, ResourcePolicy.TYPE_CUSTOM); authorizeService.addPolicies(c, policies, itemNew); itemService.update(c, itemNew); return itemNew; } catch (IOException | SQLException | AuthorizeException e) { throw new RuntimeException(e.getMessage(), e); } } }
@Override public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request) throws SQLException, AuthorizeException, IOException, WorkflowException { if (request.getParameter("submit_score") != null) { int score = Util.getIntParameter(request, "score"); //Add our score to the metadata itemService.addMetadata(c, wfi.getItem(), WorkflowRequirementsService.WORKFLOW_SCHEMA, "score", null, null, String.valueOf(score)); itemService.update(c, wfi.getItem()); return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE); } else { //We have pressed the leave button so return to our submission page return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE); } } }
@Override public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { // Since 3.0 the lift process for all embargoes is performed through the dates // on the authorization process (see DS-2588) // lifter.liftEmbargo(context, item); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); // set the dc.date.available value to right now itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item " + item.getHandle()); itemService.update(context, item); }
/** * Adds a DOI to the metadata of an item. * * @param context The relevant DSpace Context. * @param dso DSpaceObject the DOI should be added to. * @param doi The DOI that should be added as metadata. * @throws SQLException if database error * @throws AuthorizeException if authorization error * @throws IdentifierException if identifier error */ protected void saveDOIToObject(Context context, DSpaceObject dso, String doi) throws SQLException, AuthorizeException, IdentifierException { // FIXME if (!(dso instanceof Item)) { throw new IllegalArgumentException("We currently support DOIs for " + "Items only, not for " + contentServiceFactory .getDSpaceObjectService(dso).getTypeText(dso) + "."); } Item item = (Item) dso; itemService .addMetadata(context, item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, doiService.DOIToExternalForm(doi)); try { itemService.update(context, item); } catch (SQLException ex) { throw ex; } catch (AuthorizeException ex) { throw ex; } }
protected void recordApproval(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, IOException, AuthorizeException { Item item = workflowItem.getItem(); // Get user's name + email address String usersName = getEPersonName(e); // Get current date String now = DCDate.getCurrent().toString(); // Here's what happened String provDescription = "Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // add bitstream descriptions (name, size, checksums) provDescription += installItemService.getBitstreamProvenanceMessage(context, item); // Add to item as a DC field itemService .addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(context, item); }
@Override public void deleteVersionedItem(Context c, Version versionToDelete, VersionHistory history) throws SQLException { try { // if versionToDelete is the current version we have to reinstate the previous version // and reset canonical if (versionHistoryService.isLastVersion(c, history, versionToDelete) && versioningService.getVersionsByHistory(c, history).size() > 1) { // if a new version gets archived, the old one is set to false. // we need to do the oposite now, if the old version was previously // unarchived. If the old version is still archived, the new // version is a WorkspaceItem or WorkflowItem we should skip this, // as unarchiving of previous versions is done only when a newer // version gets archived. Item item = versionHistoryService.getPrevious(c, history, versionToDelete).getItem(); if (!item.isArchived() || workspaceItemService.findByItem(c, versionToDelete.getItem()) != null || workflowItemService.findByItem(c, versionToDelete.getItem()) != null) { item.setArchived(true); itemService.update(c, item); } } // assign tombstone to the Identifier and reset canonical to the previous version only if there is a // previous version Item itemToDelete = versionToDelete.getItem(); identifierService.delete(c, itemToDelete); } catch (SQLException | AuthorizeException | IdentifierException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public void setEmbargo(Context context, Item item) throws SQLException, AuthorizeException { // if lift is null, we might be restoring an item from an AIP DCDate myLift = getEmbargoTermsAsDate(context, item); if (myLift == null) { if ((myLift = recoverEmbargoDate(item)) == null) { return; } } String slift = myLift.toString(); try { context.turnOffAuthorisationSystem(); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); itemService.addMetadata(context, item, lift_schema, lift_element, lift_qualifier, null, slift); log.info("Set embargo on Item " + item.getHandle() + ", expires on: " + slift); setter.setEmbargo(context, item); itemService.update(context, item); } finally { context.restoreAuthSystemState(); } }
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", null, handleref); itemService.update(context, item);
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); } }
protected void recordStart(Context context, Item myitem) throws SQLException, IOException, AuthorizeException { // get date DCDate now = DCDate.getCurrent(); // Create provenance description String provmessage; if (myitem.getSubmitter() != null) { provmessage = "Submitted by " + myitem.getSubmitter().getFullName() + " (" + myitem.getSubmitter().getEmail() + ") on " + now.toString() + "\n"; } else { // else, null submitter provmessage = "Submitted by unknown (probably automated) on" + now.toString() + "\n"; } // add sizes and checksums of bitstreams provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem); // Add message to the DC itemService .addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage); itemService.update(context, myitem); }
protected void recordStart(Context context, Item myitem, Action action) throws SQLException, IOException, AuthorizeException { // get date DCDate now = DCDate.getCurrent(); // Create provenance description String provmessage = ""; if (myitem.getSubmitter() != null) { provmessage = "Submitted by " + myitem.getSubmitter().getFullName() + " (" + myitem.getSubmitter().getEmail() + ") on " + now.toString() + " workflow start=" + action.getProvenanceStartId() + "\n"; } else { // else, null submitter provmessage = "Submitted by unknown (probably automated) on" + now.toString() + " workflow start=" + action.getProvenanceStartId() + "\n"; } // add sizes and checksums of bitstreams provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem); // Add message to the DC itemService .addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage); itemService.update(context, myitem); }
itemService.update(c, item);