mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-330: Error of sending notifications about review due
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@38464 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="nodeService" />
|
||||||
<property name="searchService" ref="searchService" />
|
<property name="searchService" ref="searchService" />
|
||||||
<property name="recordsManagementNotificationHelper" ref="recordsManagementNotificationHelper" />
|
<property name="recordsManagementNotificationHelper" ref="recordsManagementNotificationHelper" />
|
||||||
|
<property name="retryingTransactionHelper" ref="retryingTransactionHelper" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="scheduledNotifyOfRecordsDueForReviewJobTrigger" class="org.alfresco.util.CronTriggerBean">
|
<bean id="scheduledNotifyOfRecordsDueForReviewJobTrigger" class="org.alfresco.util.CronTriggerBean">
|
||||||
|
@@ -856,6 +856,7 @@
|
|||||||
<property name="namespaceService" ref="namespaceService"/>
|
<property name="namespaceService" ref="namespaceService"/>
|
||||||
<property name="searchService" ref="searchService"/>
|
<property name="searchService" ref="searchService"/>
|
||||||
<property name="siteService" ref="SiteService" />
|
<property name="siteService" ref="SiteService" />
|
||||||
|
<property name="authorityService" ref="authorityService" />
|
||||||
<property name="notificationRole" value="${rm.notification.role}"/>
|
<property name="notificationRole" value="${rm.notification.role}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@@ -22,7 +22,9 @@ import java.io.Serializable;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.Role;
|
import org.alfresco.module.org_alfresco_module_rm.security.Role;
|
||||||
@@ -35,10 +37,14 @@ import org.alfresco.service.cmr.notification.NotificationService;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +55,8 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
*/
|
*/
|
||||||
public class RecordsManagementNotificationHelper
|
public class RecordsManagementNotificationHelper
|
||||||
{
|
{
|
||||||
|
private static Log logger = LogFactory.getLog(RecordsManagementNotificationHelper.class);
|
||||||
|
|
||||||
/** I18n */
|
/** I18n */
|
||||||
private static final String MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW = "notification.dueforreview.subject";
|
private static final String MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW = "notification.dueforreview.subject";
|
||||||
private static final String MSG_SUBJECT_RECORD_SUPERCEDED = "notification.superseded.subject";
|
private static final String MSG_SUBJECT_RECORD_SUPERCEDED = "notification.superseded.subject";
|
||||||
@@ -64,6 +72,7 @@ public class RecordsManagementNotificationHelper
|
|||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
private AuthorityService authorityService;
|
||||||
|
|
||||||
/** Notification role */
|
/** Notification role */
|
||||||
private String notificationRole;
|
private String notificationRole;
|
||||||
@@ -137,6 +146,14 @@ public class RecordsManagementNotificationHelper
|
|||||||
this.siteService = siteService;
|
this.siteService = siteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param authorityService authority service
|
||||||
|
*/
|
||||||
|
public void setAuthorityService(AuthorityService authorityService)
|
||||||
|
{
|
||||||
|
this.authorityService = authorityService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return superseded email template
|
* @return superseded email template
|
||||||
*/
|
*/
|
||||||
@@ -177,7 +194,10 @@ public class RecordsManagementNotificationHelper
|
|||||||
if (records.isEmpty() == false)
|
if (records.isEmpty() == false)
|
||||||
{
|
{
|
||||||
NodeRef root = getRMRoot(records.get(0));
|
NodeRef root = getRMRoot(records.get(0));
|
||||||
|
String groupName = getGroupName(root);
|
||||||
|
|
||||||
|
if (doesGroupContainUsers(groupName) == true)
|
||||||
|
{
|
||||||
NotificationContext notificationContext = new NotificationContext();
|
NotificationContext notificationContext = new NotificationContext();
|
||||||
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW));
|
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORDS_DUE_FOR_REVIEW));
|
||||||
notificationContext.setAsyncNotification(false);
|
notificationContext.setAsyncNotification(false);
|
||||||
@@ -189,11 +209,20 @@ public class RecordsManagementNotificationHelper
|
|||||||
args.put("site", getSiteName(root));
|
args.put("site", getSiteName(root));
|
||||||
notificationContext.setTemplateArgs(args);
|
notificationContext.setTemplateArgs(args);
|
||||||
|
|
||||||
String groupName = getGroupName(root);
|
|
||||||
notificationContext.addTo(groupName);
|
notificationContext.addTo(groupName);
|
||||||
|
|
||||||
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
|
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled() == true)
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +235,10 @@ public class RecordsManagementNotificationHelper
|
|||||||
ParameterCheck.mandatory("record", record);
|
ParameterCheck.mandatory("record", record);
|
||||||
|
|
||||||
NodeRef root = getRMRoot(record);
|
NodeRef root = getRMRoot(record);
|
||||||
|
String groupName = getGroupName(root);
|
||||||
|
|
||||||
|
if (doesGroupContainUsers(groupName) == true)
|
||||||
|
{
|
||||||
NotificationContext notificationContext = new NotificationContext();
|
NotificationContext notificationContext = new NotificationContext();
|
||||||
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_SUPERCEDED));
|
notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_SUPERCEDED));
|
||||||
notificationContext.setAsyncNotification(false);
|
notificationContext.setAsyncNotification(false);
|
||||||
@@ -218,11 +250,20 @@ public class RecordsManagementNotificationHelper
|
|||||||
args.put("site", getSiteName(root));
|
args.put("site", getSiteName(root));
|
||||||
notificationContext.setTemplateArgs(args);
|
notificationContext.setTemplateArgs(args);
|
||||||
|
|
||||||
String groupName = getGroupName(root);
|
|
||||||
notificationContext.addTo(groupName);
|
notificationContext.addTo(groupName);
|
||||||
|
|
||||||
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
|
notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.warn("Unable to send record superseded email notification, because notification group was empty.");
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AlfrescoRuntimeException("Unable to send record superseded email notification, because notification group was empty.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the rm root given a context node.
|
* Gets the rm root given a context node.
|
||||||
@@ -264,6 +305,19 @@ public class RecordsManagementNotificationHelper
|
|||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean doesGroupContainUsers(final String groupName)
|
||||||
|
{
|
||||||
|
return AuthenticationUtil.runAs(new RunAsWork<Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Boolean doWork() throws Exception
|
||||||
|
{
|
||||||
|
Set<String> users = authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true);
|
||||||
|
return !users.isEmpty();
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the site name, default if none/undetermined.
|
* Get the site name, default if none/undetermined.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user