@Override public List<String> getEPersonDeleteConstraints(Context context, EPerson ePerson) throws SQLException { List<String> resultList = new ArrayList<>(); List<BasicWorkflowItem> workflowItems = workflowItemService.findByOwner(context, ePerson); if (CollectionUtils.isNotEmpty(workflowItems)) { resultList.add("workflowitem"); } List<TaskListItem> taskListItems = taskListItemService.findByEPerson(context, ePerson); if (CollectionUtils.isNotEmpty(taskListItems)) { resultList.add("tasklistitem"); } return resultList; }
@Override public List<String> getEPersonDeleteConstraints(Context context, EPerson ePerson) throws SQLException { List<String> constraints = new ArrayList<String>(); if (CollectionUtils.isNotEmpty(claimedTaskService.findByEperson(context, ePerson))) { constraints.add("cwf_claimtask"); } if (CollectionUtils.isNotEmpty(poolTaskService.findByEPerson(context, ePerson))) { constraints.add("cwf_pooltask"); } if (CollectionUtils.isNotEmpty(workflowItemRoleService.findByEPerson(context, ePerson))) { constraints.add("cwf_workflowitemrole"); } return constraints; }
protected void grantSubmitterReadPolicies(Context context, Item item) throws SQLException, AuthorizeException { // A list of policies the user has for this item List<Integer> userHasPolicies = new ArrayList<Integer>(); List<ResourcePolicy> itempols = authorizeService.getPolicies(context, item); EPerson submitter = item.getSubmitter(); for (ResourcePolicy resourcePolicy : itempols) { if (submitter.equals(resourcePolicy.getEPerson())) { // The user has already got this policy so add it to the list userHasPolicies.add(resourcePolicy.getAction()); } } // Make sure we don't add duplicate policies if (!userHasPolicies.contains(Constants.READ)) addPolicyToItem(context, item, Constants.READ, submitter); }
protected void grantGroupAllItemPolicies(Context context, Item item, Group group) throws AuthorizeException, SQLException { if (group != null) { // A list of policies the user has for this item List<Integer> groupHasPolicies = new ArrayList<Integer>(); List<ResourcePolicy> itempols = authorizeService.getPolicies(context, item); for (ResourcePolicy resourcePolicy : itempols) { if (group.equals(resourcePolicy.getGroup())) { // The user has already got this policy so it it to the list groupHasPolicies.add(resourcePolicy.getAction()); } } // Make sure we don't add duplicate policies if (!groupHasPolicies.contains(Constants.READ)) addGroupPolicyToItem(context, item, Constants.READ, group); if (!groupHasPolicies.contains(Constants.WRITE)) addGroupPolicyToItem(context, item, Constants.WRITE, group); if (!groupHasPolicies.contains(Constants.DELETE)) addGroupPolicyToItem(context, item, Constants.DELETE, group); if (!groupHasPolicies.contains(Constants.ADD)) addGroupPolicyToItem(context, item, Constants.ADD, group); if (!groupHasPolicies.contains(Constants.REMOVE)) addGroupPolicyToItem(context, item, Constants.REMOVE, group); } }
/** * notify the submitter that the item is archived * * @param context The relevant DSpace Context. * @param item which item was archived * @param coll collection name to display in template * @throws SQLException An exception that provides information on a database access error or other * errors. * @throws IOException A general class of exceptions produced by failed or interrupted I/O * operations. */ protected void notifyOfArchive(Context context, Item item, Collection coll) throws SQLException, IOException { try { // Get submitter EPerson ep = item.getSubmitter(); // Get the Locale Locale supportedLocale = I18nUtil.getEPersonLocale(ep); Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "submit_archive")); // Get the item handle to email to user String handle = handleService.findHandle(context, item); // Get title List<MetadataValue> titles = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY); String title = ""; try { title = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled"); } catch (MissingResourceException e) { title = "Untitled"; } if (titles.size() > 0) { title = titles.iterator().next().getValue(); } email.addRecipient(ep.getEmail()); email.addArgument(title); email.addArgument(coll.getName()); email.addArgument(handleService.getCanonicalForm(handle)); email.send(); } catch (MessagingException e) { log.warn( LogManager.getHeader( context, "notifyOfArchive", "cannot email user" + " item_id=" + item.getID())); } }
protected void logWorkflowEvent( Context c, String workflowId, String previousStepId, String previousActionConfigId, XmlWorkflowItem wfi, EPerson actor, Step newStep, WorkflowActionConfig newActionConfig) throws SQLException { try { // Fire an event so we can log our action ! Item item = wfi.getItem(); Collection myCollection = wfi.getCollection(); String workflowStepString = null; List<EPerson> currentEpersonOwners = new ArrayList<EPerson>(); List<Group> currentGroupOwners = new ArrayList<Group>(); // These are only null if our item is sent back to the submission if (newStep != null && newActionConfig != null) { workflowStepString = workflowId + "." + newStep.getId() + "." + newActionConfig.getId(); // Retrieve the current owners of the task List<ClaimedTask> claimedTasks = claimedTaskService.find(c, wfi, newStep.getId()); List<PoolTask> pooledTasks = poolTaskService.find(c, wfi); for (PoolTask poolTask : pooledTasks) { if (poolTask.getEperson() != null) { currentEpersonOwners.add(poolTask.getEperson()); } else { currentGroupOwners.add(poolTask.getGroup()); } } for (ClaimedTask claimedTask : claimedTasks) { currentEpersonOwners.add(claimedTask.getOwner()); } } String previousWorkflowStepString = null; if (previousStepId != null && previousActionConfigId != null) { previousWorkflowStepString = workflowId + "." + previousStepId + "." + previousActionConfigId; } // Fire our usage event ! UsageWorkflowEvent usageWorkflowEvent = new UsageWorkflowEvent( c, item, wfi, workflowStepString, previousWorkflowStepString, myCollection, actor); usageWorkflowEvent.setEpersonOwners( currentEpersonOwners.toArray(new EPerson[currentEpersonOwners.size()])); usageWorkflowEvent.setGroupOwners( currentGroupOwners.toArray(new Group[currentGroupOwners.size()])); DSpaceServicesFactory.getInstance().getEventService().fireEvent(usageWorkflowEvent); } catch (Exception e) { // Catch all errors we do not want our workflow to crash because the logging threw an // exception log.error( LogManager.getHeader( c, "Error while logging workflow event", "Workflow Item: " + wfi.getID()), e); } }