From 2e1cc03bf4e6358925feb5555261d25dc2ac6336 Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Mon, 11 Jul 2016 18:26:46 +0300 Subject: [PATCH] RM-3651: workaround to skip code execution when first element is not a record --- .../RecordsManagementNotificationHelper.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java index 41c075c4f8..b5c81378f4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java @@ -244,34 +244,38 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod ParameterCheck.mandatory("records", records); if (!records.isEmpty()) { - NodeRef root = getRMRoot(records.get(0)); - String groupName = getGroupName(root); - - if (doesGroupContainUsers(groupName)) + if (nodeService.hasAspect(records.get(0), RecordsManagementModel.ASPECT_RECORD)) { - NotificationContext notificationContext = new NotificationContext(); - notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW)); - notificationContext.setAsyncNotification(false); - notificationContext.setIgnoreNotificationFailure(true); + NodeRef root = getRMRoot(records.get(0)); + String groupName = getGroupName(root); - notificationContext.setBodyTemplate(getDueForReviewTemplate().toString()); - Map args = new HashMap(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()) + if (doesGroupContainUsers(groupName)) { - logger.warn("Unable to send record due for review email notification, because notification group was empty."); - } + NotificationContext notificationContext = new NotificationContext(); + notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW)); + notificationContext.setAsyncNotification(false); + notificationContext.setIgnoreNotificationFailure(true); - throw new AlfrescoRuntimeException("Unable to send record due for review email notification, because notification group was empty."); + notificationContext.setBodyTemplate(getDueForReviewTemplate().toString()); + Map args = new HashMap(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."); + } } } }