use of org.alfresco.service.cmr.notification.NotificationContext in project records-management by Alfresco.
the class RecordsManagementNotificationHelper method recordsDueForReviewEmailNotification.
/**
* Sends records due for review email notification.
*
* @param records records due for review
*/
public void recordsDueForReviewEmailNotification(final List<NodeRef> records) {
ParameterCheck.mandatory("records", records);
if (!records.isEmpty()) {
if (nodeService.hasAspect(records.get(0), RecordsManagementModel.ASPECT_RECORD)) {
NodeRef root = getRMRoot(records.get(0));
String groupName = getGroupName(root);
if (doesGroupContainUsers(groupName)) {
NotificationContext notificationContext = new NotificationContext();
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW));
notificationContext.setAsyncNotification(false);
notificationContext.setIgnoreNotificationFailure(true);
notificationContext.setBodyTemplate(getDueForReviewTemplate().toString());
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put("records", (Serializable) records);
args.put("site", getSiteName(root));
notificationContext.setTemplateArgs(args);
notificationContext.addTo(groupName);
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
} else {
if (logger.isWarnEnabled()) {
logger.warn("Unable to send record due for review email notification, because notification group was empty.");
}
throw new AlfrescoRuntimeException("Unable to send record due for review email notification, because notification group was empty.");
}
}
}
}
use of org.alfresco.service.cmr.notification.NotificationContext in project records-management by Alfresco.
the class RecordsManagementNotificationHelper method recordRejectedEmailNotification.
/**
* Sends record rejected email notification.
*
* @param record rejected record
*/
public void recordRejectedEmailNotification(NodeRef record, String recordId, String recordCreator) {
ParameterCheck.mandatory("record", record);
if (canSendRejectEmail(record, recordCreator)) {
String site = siteService.getSite(record).getShortName();
String rejectReason = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON);
String rejectedPerson = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID);
Date rejectDate = (Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE);
String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
Map<String, Serializable> args = new HashMap<String, Serializable>(8);
args.put("record", record);
args.put("site", site);
args.put("recordCreator", recordCreator);
args.put("rejectReason", rejectReason);
args.put("rejectedPerson", rejectedPerson);
args.put("rejectDate", rejectDate);
args.put("recordId", recordId);
args.put("recordName", recordName);
NotificationContext notificationContext = new NotificationContext();
notificationContext.setAsyncNotification(true);
notificationContext.setIgnoreNotificationFailure(true);
notificationContext.addTo(recordCreator);
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_REJECTED));
notificationContext.setBodyTemplate(getRejectedTemplate().toString());
notificationContext.setTemplateArgs(args);
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
}
}
use of org.alfresco.service.cmr.notification.NotificationContext in project records-management by Alfresco.
the class RecordsManagementNotificationHelper method recordSupersededEmailNotification.
/**
* Sends record superseded email notification.
*
* @param record superseded record
*/
public void recordSupersededEmailNotification(final NodeRef record) {
ParameterCheck.mandatory("record", record);
NodeRef root = getRMRoot(record);
String groupName = getGroupName(root);
if (doesGroupContainUsers(groupName)) {
NotificationContext notificationContext = new NotificationContext();
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_SUPERCEDED));
notificationContext.setAsyncNotification(false);
notificationContext.setIgnoreNotificationFailure(true);
notificationContext.setBodyTemplate(supersededTemplate.toString());
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put("record", record);
args.put("site", getSiteName(root));
notificationContext.setTemplateArgs(args);
notificationContext.addTo(groupName);
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
} else {
if (logger.isWarnEnabled()) {
logger.warn("Unable to send record superseded email notification, because notification group was empty.");
}
}
}
Aggregations