As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
${person.properties["cm:firstName"]} ${person.properties["cm:lastName"]}
@Override public void sendNotification(NotificationContext notificationContext) { List<String> to = notificationContext.getTo(); if (to != null && to.size() == 1) { String assignee = to.get(0); Map<String, Serializable> args = notificationContext.getTemplateArgs(); try { NodeRef personRef = serviceRegistry.getPersonService().getPerson(assignee, false); args.put("assignee", new TemplateNode(personRef, serviceRegistry, null)); notificationContext.setTemplateArgs(args); } catch (NoSuchPersonException ex) { logger.warn("Could not find a person with the name " + assignee); } } super.sendNotification(notificationContext); }
<#assign assignee=args["assignee"]/>
<#if assignee?exists> ${assignee.properties["cm:firstName"]} ${assignee.properties["cm:lastName"]} </#if>
Missing code how was implemented serviceRegistry
package PACKAGE_NAME; // replace with own package name.import java.io.Serializable;import java.util.List;import java.util.Map;import org.alfresco.repo.template.TemplateNode;import org.alfresco.service.ServiceRegistry;import org.alfresco.service.cmr.notification.NotificationContext;import org.alfresco.service.cmr.repository.NodeRef;import org.alfresco.service.cmr.security.NoSuchPersonException;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;public class EMailNotificationProvider extends org.alfresco.repo.notification.EMailNotificationProvider { private static Log logger = LogFactory.getLog(EMailNotificationProvider.class); private ServiceRegistry serviceRegistry; @Override public void sendNotification(NotificationContext notificationContext) { List<String> to = notificationContext.getTo(); if (to != null && to.size() == 1) { String assignee = to.get(0); Map<String, Serializable> args = notificationContext.getTemplateArgs(); try { NodeRef personRef = this.serviceRegistry.getPersonService().getPerson(assignee, false); args.put("assignee", new TemplateNode(personRef, this.serviceRegistry, null)); notificationContext.setTemplateArgs(args); } catch (NoSuchPersonException ex) { logger.error("Could not find a person with the name " + assignee); } catch (Exception ex){ logger.error("Exception: " + ex.getMessage()); } } super.sendNotification(notificationContext); } /** * @param serviceRegistry provides access to the service APIs */ public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; } }
package PACKAGE_NAME; // replace with own package name.
import java.io.Serializable;import java.util.List;import java.util.Map;import org.alfresco.repo.template.TemplateNode;import org.alfresco.service.ServiceRegistry;import org.alfresco.service.cmr.notification.NotificationContext;import org.alfresco.service.cmr.repository.NodeRef;import org.alfresco.service.cmr.security.NoSuchPersonException;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;
public class EMailNotificationProvider extends org.alfresco.repo.notification.EMailNotificationProvider { private static Log logger = LogFactory.getLog(EMailNotificationProvider.class);
private ServiceRegistry serviceRegistry;
@Override public void sendNotification(NotificationContext notificationContext) { List<String> to = notificationContext.getTo(); if (to != null && to.size() == 1) { String assignee = to.get(0); Map<String, Serializable> args = notificationContext.getTemplateArgs(); try { NodeRef personRef = this.serviceRegistry.getPersonService().getPerson(assignee, false); args.put("assignee", new TemplateNode(personRef, this.serviceRegistry, null)); notificationContext.setTemplateArgs(args); } catch (NoSuchPersonException ex) { logger.error("Could not find a person with the name " + assignee); } catch (Exception ex){ logger.error("Exception: " + ex.getMessage()); } } super.sendNotification(notificationContext); } /** * @param serviceRegistry provides access to the service APIs */ public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; } }
Missing example of bean definition in file module-context.xml
<!-- EMail notification provider, source https://github.com/Alfresco/alfresco-repository/blob/master/src/main/resources/alfresco/notification-services-context.xml --> <bean id="emailNotificationProvider" class="PACKAGE_NAME.EMailNotificationProvider" init-method="init"> <property name="notificationService" ref="notificationService"/> <property name="nodeService" ref="NodeService"/> <property name="actionService" ref="ActionService"/> <property name="personService" ref="PersonService"/> <property name="repository" ref="repositoryHelper"/> <property name="fileFolderService" ref="FileFolderService"/> <property name="repoAdminService" ref="RepoAdminService"/> <property name="serviceRegistry" ref="ServiceRegistry" /> </bean>