@Override public int hashCode() { return Objects.hash(path, collection.getID()); } }
@Override public int hashCode() { int hash = 5; hash += 71 * hash + getType(); hash += 71 * hash + getID().hashCode(); return hash; }
@Override public void updateLastModified(Context context, Collection collection) throws SQLException, AuthorizeException { //Also fire a modified event since the collection HAS been modified context.addEvent(new Event(Event.MODIFY, Constants.COLLECTION, collection.getID(), null, getIdentifiers(context, collection))); }
@Override public void createTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException { // Check authorisation AuthorizeUtil.authorizeManageTemplateItem(context, collection); if (collection.getTemplateItem() == null) { Item template = itemService.createTemplateItem(context, collection); collection.setTemplateItem(template); log.info(LogManager.getHeader(context, "create_template_item", "collection_id=" + collection.getID() + ",template_item_id=" + template.getID())); } }
@Override public void addItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, collection, Constants.ADD); log.info(LogManager.getHeader(context, "add_item", "collection_id=" + collection.getID() + ",item_id=" + item.getID())); // Create mapping // We do NOT add the item to the collection template since we would have to load in all our items // Instead we add the collection to an item which works in the same way. if (!item.getCollections().contains(collection)) { item.addCollection(collection); } context.addEvent(new Event(Event.ADD, Constants.COLLECTION, collection.getID(), Constants.ITEM, item.getID(), item.getHandle(), getIdentifiers(context, collection))); }
@Override public void addCollection(Context context, Community community, Collection collection) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, community, Constants.ADD); log.info(LogManager.getHeader(context, "add_collection", "community_id=" + community.getID() + ",collection_id=" + collection.getID())); if (!community.getCollections().contains(collection)) { community.addCollection(collection); collection.addCommunity(community); } context.addEvent( new Event(Event.ADD, Constants.COMMUNITY, community.getID(), Constants.COLLECTION, collection.getID(), community.getHandle(), getIdentifiers(context, community))); }
@Override public void deleteWrapper(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException { // Check authorisation. We check permissions on the enclosed item. Item item = workspaceItem.getItem(); authorizeService.authorizeAction(context, item, Constants.WRITE); log.info(LogManager.getHeader(context, "delete_workspace_item", "workspace_item_id=" + workspaceItem.getID() + "item_id=" + item.getID() + "collection_id=" + workspaceItem.getCollection().getID())); // deleteSubmitPermissions(); // Need to delete the workspaceitem row first since it refers // to item ID workspaceItem.getSupervisorGroups().clear(); workspaceItemDAO.delete(context, workspaceItem); }
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException { super.addPageMeta(pageMeta); int collectionID = submission.getCollection().getID(); pageMeta.addMetadata("choice", "collection").addContent(String.valueOf(collectionID)); String jumpTo = submissionInfo.getJumpToField(); if (jumpTo != null) { pageMeta.addMetadata("page", "jumpTo").addContent(jumpTo); } }
@Override public void update(Context context, Collection collection) throws SQLException, AuthorizeException { // Check authorisation canEdit(context, collection, true); log.info(LogManager.getHeader(context, "update_collection", "collection_id=" + collection.getID())); super.update(context, collection); collectionDAO.save(context, collection); if (collection.isModified()) { context.addEvent(new Event(Event.MODIFY, Constants.COLLECTION, collection.getID(), null, getIdentifiers(context, collection))); collection.clearModified(); } if (collection.isMetadataModified()) { collection.clearDetails(); } }
@Override public Item createTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException { if (collection == null || collection.getTemplateItem() != null) { throw new IllegalArgumentException("Collection is null or already contains template item."); } AuthorizeUtil.authorizeManageTemplateItem(context, collection); if (collection.getTemplateItem() == null) { Item template = createItem(context); collection.setTemplateItem(template); template.setTemplateItemOf(collection); log.info(LogManager.getHeader(context, "create_template_item", "collection_id=" + collection.getID() + ",template_item_id=" + template.getID())); return template; } else { return collection.getTemplateItem(); } }
private static Group getXMLWorkflowRole(Context context, int collectionID, String roleName, Collection collection, Group roleGroup) throws IOException, WorkflowConfigurationException, SQLException, AuthorizeException { Role role = WorkflowUtils.getCollectionRoles(collection).get(roleName); if(role.getScope() == Role.Scope.COLLECTION){ roleGroup = WorkflowUtils.getRoleGroup(context, collectionID, role); if(roleGroup == null){ AuthorizeManager.authorizeAction(context, collection, Constants.WRITE); roleGroup = Group.create(context); roleGroup.setName("COLLECTION_" + collection.getID() + "_WORKFLOW_ROLE_" + roleName); roleGroup.update(); AuthorizeManager.addPolicy(context, collection, Constants.ADD, roleGroup); WorkflowUtils.createCollectionWorkflowRole(context, collectionID, roleName, roleGroup); } } return roleGroup; }
@Override public void removeItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException, IOException { // Check authorisation authorizeService.authorizeAction(context, collection, Constants.REMOVE); //Check if we orphaned our poor item if (item.getCollections().size() == 1) { // Orphan; delete it itemService.delete(context, item); } else { //Remove the item from the collection if we have multiple collections item.removeCollection(collection); } context.addEvent(new Event(Event.REMOVE, Constants.COLLECTION, collection.getID(), Constants.ITEM, item.getID(), item.getHandle(), getIdentifiers(context, collection))); }
public void addPageMeta(PageMeta pageMeta) throws WingException, SQLException { Item item = Item.find(context, parameters.getParameterAsInteger("itemID",-1)); Collection owner = item.getOwningCollection(); int collectionID = (owner == null) ? -1 : owner.getID(); pageMeta.addMetadata("choice", "collection").addContent(String.valueOf(collectionID)); pageMeta.addMetadata("title").addContent(T_title); pageMeta.addTrailLink(contextPath + "/", T_dspace_home); pageMeta.addTrailLink(contextPath + "/admin/item", T_item_trail); pageMeta.addTrail().addContent(T_trail); }
@Override public WorkspaceItem abort(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, AuthorizeException, IOException { // authorize a DSpaceActions.ABORT if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "You must be an admin to abort a workflow"); } // stop workflow regardless of its state taskListItemService.deleteByWorkflowItem(context, workflowItem); log.info(LogManager.getHeader(context, "abort_workflow", "workflow_item_id=" + workflowItem.getID() + "item_id=" + workflowItem.getItem().getID() + "collection_id=" + workflowItem.getCollection().getID() + "eperson_id=" + e.getID())); // convert into personal workspace return returnToWorkspace(context, workflowItem); }
@Override public WorkspaceItem abort(Context c, XmlWorkflowItem wi, EPerson e) throws AuthorizeException, SQLException, IOException { if (!authorizeService.isAdmin(c)) { throw new AuthorizeException( "You must be an admin to abort a workflow"); } c.turnOffAuthorisationSystem(); //Restore permissions for the submitter // convert into personal workspace WorkspaceItem wsi = returnToWorkspace(c, wi); log.info(LogManager.getHeader(c, "abort_workflow", "workflow_item_id=" + wi.getID() + "item_id=" + wsi.getItem().getID() + "collection_id=" + wi.getCollection().getID() + "eperson_id=" + e.getID())); c.restoreAuthSystemState(); return wsi; }
@Override public Group createWorkflowGroup(Context context, Collection collection, int step) throws SQLException, AuthorizeException { // Check authorisation - Must be an Admin to create Workflow Group AuthorizeUtil.authorizeManageWorkflowsGroup(context, collection); if (getWorkflowGroup(collection, step) == null) { //turn off authorization so that Collection Admins can create Collection Workflow Groups context.turnOffAuthorisationSystem(); Group g = groupService.create(context); context.restoreAuthSystemState(); groupService.setName(g, "COLLECTION_" + collection.getID() + "_WORKFLOW_STEP_" + step); groupService.update(context, g); setWorkflowGroup(context, collection, step, g); } return getWorkflowGroup(collection, step); }
@Override public Group createAdministrators(Context context, Collection collection) throws SQLException, AuthorizeException { // Check authorisation - Must be an Admin to create more Admins AuthorizeUtil.authorizeManageAdminGroup(context, collection); Group admins = collection.getAdministrators(); if (admins == null) { //turn off authorization so that Community Admins can create Collection Admins context.turnOffAuthorisationSystem(); admins = groupService.create(context); context.restoreAuthSystemState(); groupService.setName(admins, "COLLECTION_" + collection.getID() + "_ADMIN"); groupService.update(context, admins); } authorizeService.addPolicy(context, collection, Constants.ADMIN, admins); // register this as the admin group collection.setAdmins(admins); return admins; }
protected void activateFirstStep(Context context, Workflow wf, Step firstStep, XmlWorkflowItem wfi) throws AuthorizeException, IOException, SQLException, WorkflowException, WorkflowConfigurationException { WorkflowActionConfig firstActionConfig = firstStep.getUserSelectionMethod(); firstActionConfig.getProcessingAction().activate(context, wfi); log.info(LogManager.getHeader(context, "start_workflow", firstActionConfig.getProcessingAction() + " workflow_item_id=" + wfi.getID() + "item_id=" + wfi.getItem().getID() + "collection_id=" + wfi.getCollection().getID())); // record the start of the workflow w/provenance message recordStart(context, wfi.getItem(), firstActionConfig.getProcessingAction()); //Fire an event ! logWorkflowEvent(context, firstStep.getWorkflow().getID(), null, null, wfi, null, firstStep, firstActionConfig); //If we don't have a UI activate it if (!firstActionConfig.requiresUI()) { ActionResult outcome = firstActionConfig.getProcessingAction().execute(context, wfi, firstStep, null); processOutcome(context, null, wf, firstStep, firstActionConfig, outcome, wfi, true); } }