@Override public ResourcePolicy findByTypeIdGroupAction( Context c, DSpaceObject dso, Group group, int action, int policyID) throws SQLException { List<ResourcePolicy> policies = resourcePolicyService.find(c, dso, group, action, policyID); if (CollectionUtils.isNotEmpty(policies)) { return policies.iterator().next(); } else { return null; } }
/** * 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())); } }