Example usage for com.liferay.portal.kernel.util SubscriptionSender SubscriptionSender

List of usage examples for com.liferay.portal.kernel.util SubscriptionSender SubscriptionSender

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util SubscriptionSender SubscriptionSender.

Prototype

SubscriptionSender

Source Link

Usage

From source file:com.liferay.asset.publisher.web.internal.messaging.AssetEntriesCheckerUtil.java

License:Open Source License

private static SubscriptionSender _getSubscriptionSender(PortletPreferences portletPreferences,
        List<AssetEntry> assetEntries) {

    if (assetEntries.isEmpty()) {
        return null;
    }//from w  ww  .ja  v  a2 s.  c  o  m

    AssetEntry assetEntry = assetEntries.get(0);

    String fromName = _assetPublisherWebUtil.getEmailFromName(portletPreferences, assetEntry.getCompanyId());
    String fromAddress = _assetPublisherWebUtil.getEmailFromAddress(portletPreferences,
            assetEntry.getCompanyId());

    Map<Locale, String> localizedSubjectMap = _assetPublisherWebUtil
            .getEmailAssetEntryAddedSubjectMap(portletPreferences);
    Map<Locale, String> localizedBodyMap = _assetPublisherWebUtil
            .getEmailAssetEntryAddedBodyMap(portletPreferences);

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setCompanyId(assetEntry.getCompanyId());
    subscriptionSender.setContextAttributes("[$ASSET_ENTRIES$]",
            ListUtil.toString(assetEntries, _titleAccessor, StringPool.COMMA_AND_SPACE));
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedBodyMap(localizedBodyMap);
    subscriptionSender
            .setLocalizedPortletTitleMap(PortletConfigurationUtil.getPortletTitleMap(portletPreferences));
    subscriptionSender.setLocalizedSubjectMap(localizedSubjectMap);
    subscriptionSender.setMailId("asset_entry", assetEntry.getEntryId());
    subscriptionSender.setPortletId(AssetPublisherPortletKeys.ASSET_PUBLISHER);
    subscriptionSender.setReplyToAddress(fromAddress);

    return subscriptionSender;
}

From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java

License:Open Source License

protected void notify(long reporterUserId, Company company, Group group, String reporterEmailAddress,
        String reporterUserName, String reportedEmailAddress, String reportedUserName, String reportedUserURL,
        long contentId, String contentTitle, String contentType, String contentURL, String reason,
        String fromName, String fromAddress, String toName, String toAddress, String subject, String body,
        ServiceContext serviceContext) throws Exception {

    Date now = new Date();

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(body);/*from ww w  . ja  va2  s. c om*/
    subscriptionSender.setCompanyId(company.getCompanyId());
    subscriptionSender.setContextAttributes("[$CONTENT_ID$]", contentId, "[$CONTENT_TYPE$]", contentType,
            "[$DATE$]", now.toString(), "[$REASON$]", reason, "[$REPORTED_USER_ADDRESS$]", reportedEmailAddress,
            "[$REPORTED_USER_NAME$]", reportedUserName, "[$REPORTED_USER_URL$]", reportedUserURL,
            "[$REPORTER_USER_ADDRESS$]", reporterEmailAddress, "[$REPORTER_USER_NAME$]", reporterUserName);
    subscriptionSender.setContextAttribute("[$CONTENT_TITLE$]", contentTitle, false);
    subscriptionSender.setContextAttribute("[$CONTENT_URL$]", contentURL, false);
    subscriptionSender.setCreatorUserId(reporterUserId);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedContextAttributeWithFunction("[$SITE_NAME$]",
            locale -> _getGroupDescriptiveName(group, locale));
    subscriptionSender.setMailId("flags_request", contentId);
    subscriptionSender.setPortletId(PortletKeys.FLAGS);
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected void sendEmail(JournalArticle article, String articleURL, PortletPreferences preferences,
        String emailType, ServiceContext serviceContext) throws PortalException {

    JournalGroupServiceConfiguration journalGroupServiceConfiguration = getJournalGroupServiceConfiguration(
            article.getGroupId());//from   w  w w.j  ava 2s. c  om

    if (preferences == null) {
        return;
    } else if (emailType.equals("denied")
            && journalGroupServiceConfiguration.emailArticleApprovalDeniedEnabled()) {
    } else if (emailType.equals("granted")
            && journalGroupServiceConfiguration.emailArticleApprovalGrantedEnabled()) {
    } else if (emailType.equals("requested")
            && journalGroupServiceConfiguration.emailArticleApprovalRequestedEnabled()) {
    } else if (emailType.equals("review") && journalGroupServiceConfiguration.emailArticleReviewEnabled()) {
    } else {
        return;
    }

    Company company = companyLocalService.getCompany(article.getCompanyId());

    User user = userLocalService.getUser(article.getUserId());

    String fromName = journalGroupServiceConfiguration.emailFromName();
    String fromAddress = journalGroupServiceConfiguration.emailFromAddress();

    String toName = user.getFullName();
    String toAddress = user.getEmailAddress();

    if (emailType.equals("requested")) {
        String tempToName = fromName;
        String tempToAddress = fromAddress;

        fromName = toName;
        fromAddress = toAddress;

        toName = tempToName;
        toAddress = tempToAddress;
    }

    Map<Locale, String> localizedSubjectMap = null;
    Map<Locale, String> localizedBodyMap = null;

    if (emailType.equals("denied")) {
        localizedSubjectMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleApprovalDeniedSubject());
        localizedBodyMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleApprovalDeniedBody());
    } else if (emailType.equals("granted")) {
        localizedSubjectMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleApprovalGrantedSubject());
        localizedBodyMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleApprovalGrantedBody());
    } else if (emailType.equals("requested")) {
        localizedSubjectMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleApprovalGrantedSubject());
        localizedBodyMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleApprovalGrantedBody());
    } else if (emailType.equals("review")) {
        localizedSubjectMap = LocalizationUtil
                .getMap(journalGroupServiceConfiguration.emailArticleReviewSubject());
        localizedBodyMap = LocalizationUtil.getMap(journalGroupServiceConfiguration.emailArticleReviewBody());
    }

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setCompanyId(company.getCompanyId());
    subscriptionSender.setContextAttributes("[$ARTICLE_ID$]", article.getArticleId(), "[$ARTICLE_TITLE$]",
            article.getTitle(serviceContext.getLanguageId()), "[$ARTICLE_URL$]", articleURL,
            "[$ARTICLE_USER_NAME$]", article.getUserName(), "[$ARTICLE_VERSION$]", article.getVersion());
    subscriptionSender.setContextCreatorUserPrefix("ARTICLE");
    subscriptionSender.setCreatorUserId(article.getUserId());
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedBodyMap(localizedBodyMap);
    subscriptionSender.setLocalizedSubjectMap(localizedSubjectMap);
    subscriptionSender.setMailId("journal_article", article.getId());

    String portletId = PortletProviderUtil.getPortletId(JournalArticle.class.getName(),
            PortletProvider.Action.EDIT);

    subscriptionSender.setPortletId(portletId);

    subscriptionSender.setScopeGroupId(article.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.mentions.internal.service.MentionsWikiPageServiceWrapper.java

License:Open Source License

protected void notifySubscribers(long userId, WikiPage page, String pageURL, ServiceContext serviceContext)
        throws PortalException {

    if (!page.isApproved() || Validator.isNull(pageURL)) {
        return;//from  w w w  .j a  v a2s . c o  m
    }

    WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = _configurationProvider
            .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME));

    boolean update = false;

    if (page.getVersion() > WikiPageConstants.VERSION_DEFAULT) {
        update = true;
    }

    if (!update && wikiGroupServiceOverriddenConfiguration.emailPageAddedEnabled()) {
    } else if (update && wikiGroupServiceOverriddenConfiguration.emailPageUpdatedEnabled()) {
    } else {
        return;
    }

    String portalURL = serviceContext.getPortalURL();

    WikiPage previousVersionPage = getPreviousVersionPage(page);

    String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(serviceContext.getPathMain(),
            serviceContext.getPlid(), page.getNodeId(), page.getTitle());

    attachmentURLPrefix = portalURL + attachmentURLPrefix;

    String pageDiffs = StringPool.BLANK;

    try {
        pageDiffs = _wikiEngineRenderer.diffHtml(previousVersionPage, page, null, null, attachmentURLPrefix);
    } catch (Exception e) {
    }

    String pageContent = null;

    if (Objects.equals(page.getFormat(), "creole")) {
        pageContent = _wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);
    } else {
        pageContent = page.getContent();
        pageContent = WikiUtil.processContent(pageContent);
    }

    String pageTitle = page.getTitle();

    String fromName = wikiGroupServiceOverriddenConfiguration.emailFromName();
    String fromAddress = wikiGroupServiceOverriddenConfiguration.emailFromAddress();

    LocalizedValuesMap subjectLocalizedValuesMap = null;
    LocalizedValuesMap bodyLocalizedValuesMap = null;

    if (update) {
        subjectLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageUpdatedSubject();
        bodyLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageUpdatedBody();
    } else {
        subjectLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageAddedSubject();
        bodyLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageAddedBody();
    }

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setClassName(page.getModelClassName());
    subscriptionSender.setClassPK(page.getPageId());
    subscriptionSender.setCompanyId(page.getCompanyId());
    subscriptionSender.setContextAttribute("[$PAGE_CONTENT$]", pageContent, false);
    subscriptionSender.setContextAttribute("[$PAGE_DIFFS$]", DiffHtmlUtil.replaceStyles(pageDiffs), false);

    WikiNode node = page.getNode();

    subscriptionSender.setContextAttributes("[$DIFFS_URL$]",
            getDiffsURL(page, previousVersionPage, serviceContext), "[$NODE_NAME$]", node.getName(),
            "[$PAGE_DATE_UPDATE$]", page.getModifiedDate(), "[$PAGE_ID$]", page.getPageId(), "[$PAGE_SUMMARY$]",
            page.getSummary(), "[$PAGE_TITLE$]", pageTitle, "[$PAGE_URL$]", pageURL);

    subscriptionSender.setContextCreatorUserPrefix("PAGE");
    subscriptionSender.setCreatorUserId(page.getUserId());
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(pageTitle);
    subscriptionSender.setEntryURL(pageURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);

    if (bodyLocalizedValuesMap != null) {
        subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap));
    }

    if (subjectLocalizedValuesMap != null) {
        subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap));
    }

    subscriptionSender.setMailId("wiki_page", page.getNodeId(), page.getPageId());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

    if (update) {
        notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY;
    }

    subscriptionSender.setNotificationType(notificationType);

    subscriptionSender.setPortletId(WikiPortletKeys.WIKI);
    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(page.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);

    subscriptionSender.addPersistedSubscribers(User.class.getName(), userId);

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.mentions.internal.util.DefaultMentionsNotifier.java

License:Open Source License

@Override
public void notify(long userId, long groupId, String title, String content, String className, long classPK,
        LocalizedValuesMap subjectLocalizedValuesMap, LocalizedValuesMap bodyLocalizedValuesMap,
        ServiceContext serviceContext) throws PortalException {

    String[] mentionedUsersScreenNames = getMentionedUsersScreenNames(userId, className, content);

    if (ArrayUtil.isEmpty(mentionedUsersScreenNames)) {
        return;//from   w  ww  . j  av a 2  s . com
    }

    User user = _userLocalService.getUser(userId);

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    String messageUserEmailAddress = _portal.getUserEmailAddress(userId);
    String messageUserName = _portal.getUserName(userId, StringPool.BLANK);

    String fromName = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap));
    subscriptionSender.setClassName(className);
    subscriptionSender.setClassPK(classPK);
    subscriptionSender.setCompanyId(user.getCompanyId());
    subscriptionSender.setContextAttribute("[$CONTENT$]", content, false);
    subscriptionSender.setContextAttributes("[$USER_ADDRESS$]", messageUserEmailAddress, "[$USER_NAME$]",
            messageUserName, "[$CONTENT_URL$]", contentURL);
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(title);
    subscriptionSender.setEntryURL(contentURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedContextAttributeWithFunction("[$ASSET_ENTRY_NAME$]",
            locale -> getAssetEntryName(className, locale));
    subscriptionSender.setMailId("mb_discussion", classPK);
    subscriptionSender.setNotificationType(MentionsConstants.NOTIFICATION_TYPE_MENTION);
    subscriptionSender.setPortletId(MentionsPortletKeys.MENTIONS);
    subscriptionSender.setScopeGroupId(groupId);
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap));

    for (String mentionedUserScreenName : mentionedUsersScreenNames) {
        User mentionedUser = _userLocalService.fetchUserByScreenName(user.getCompanyId(),
                mentionedUserScreenName);

        if (mentionedUser == null) {
            continue;
        }

        subscriptionSender.addRuntimeSubscribers(mentionedUser.getEmailAddress(), mentionedUser.getFullName());
    }

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.message.boards.internal.service.SubscriptionMBMessageLocalServiceWrapper.java

License:Open Source License

protected void notifyDiscussionSubscribers(long userId, MBMessage message, ServiceContext serviceContext)
        throws PortalException {

    if (!PrefsPropsUtil.getBoolean(message.getCompanyId(), PropsKeys.DISCUSSION_EMAIL_COMMENTS_ADDED_ENABLED)) {

        return;/*from w ww .jav  a 2  s.  c o m*/
    }

    MBDiscussion mbDiscussion = _mbDiscussionLocalService.getThreadDiscussion(message.getThreadId());

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    contentURL = _http.addParameter(contentURL, serviceContext.getAttribute("namespace") + "messageId",
            message.getMessageId());

    String userAddress = StringPool.BLANK;
    String userName = (String) serviceContext.getAttribute("pingbackUserName");

    if (Validator.isNull(userName)) {
        userAddress = _portal.getUserEmailAddress(message.getUserId());
        userName = _portal.getUserName(message.getUserId(), StringPool.BLANK);
    }

    String fromName = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

    String subject = PrefsPropsUtil.getContent(message.getCompanyId(), PropsKeys.DISCUSSION_EMAIL_SUBJECT);
    String body = PrefsPropsUtil.getContent(message.getCompanyId(), PropsKeys.DISCUSSION_EMAIL_BODY);

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(message.getCompanyId());
    subscriptionSender.setClassName(MBDiscussion.class.getName());
    subscriptionSender.setClassPK(mbDiscussion.getDiscussionId());
    subscriptionSender.setContextAttribute("[$COMMENTS_BODY$]", message.getBody(message.isFormatBBCode()),
            false);
    subscriptionSender.setContextAttributes("[$COMMENTS_USER_ADDRESS$]", userAddress, "[$COMMENTS_USER_NAME$]",
            userName, "[$CONTENT_URL$]", contentURL);
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(message.getBody());
    subscriptionSender.setEntryURL(contentURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);

    Date modifiedDate = message.getModifiedDate();

    subscriptionSender.setMailId("mb_discussion", message.getCategoryId(), message.getMessageId(),
            modifiedDate.getTime());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

    if (serviceContext.isCommandUpdate()) {
        notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY;
    }

    subscriptionSender.setNotificationType(notificationType);

    String portletId = PortletProviderUtil.getPortletId(Comment.class.getName(), PortletProvider.Action.VIEW);

    subscriptionSender.setPortletId(portletId);

    subscriptionSender.setScopeGroupId(message.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUniqueMailId(false);

    String className = (String) serviceContext.getAttribute("className");
    long classPK = ParamUtil.getLong(serviceContext, "classPK");

    subscriptionSender.addPersistedSubscribers(className, classPK);

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

protected void notifySubscribers(long userId, WikiPage page, String pageURL, ServiceContext serviceContext)
        throws PortalException {

    if (!page.isApproved() || Validator.isNull(pageURL)) {
        return;//  w ww .j  a  v  a2  s .c  om
    }

    WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = configurationProvider
            .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME));

    boolean update = false;

    if (page.getVersion() > WikiPageConstants.VERSION_DEFAULT) {
        update = true;
    }

    if (!update && wikiGroupServiceOverriddenConfiguration.emailPageAddedEnabled()) {
    } else if (update && wikiGroupServiceOverriddenConfiguration.emailPageUpdatedEnabled()) {
    } else {
        return;
    }

    String portalURL = serviceContext.getPortalURL();

    WikiPage previousVersionPage = getPreviousVersionPage(page);

    String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(serviceContext.getPathMain(),
            serviceContext.getPlid(), page.getNodeId(), page.getTitle());

    attachmentURLPrefix = portalURL + attachmentURLPrefix;

    String pageDiffs = StringPool.BLANK;

    try {
        pageDiffs = wikiEngineRenderer.diffHtml(previousVersionPage, page, null, null, attachmentURLPrefix);
    } catch (Exception e) {
    }

    String pageContent = null;

    if (Objects.equals(page.getFormat(), "creole")) {
        pageContent = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);
    } else {
        pageContent = page.getContent();
        pageContent = WikiUtil.processContent(pageContent);
    }

    String pageTitle = page.getTitle();

    String fromName = wikiGroupServiceOverriddenConfiguration.emailFromName();
    String fromAddress = wikiGroupServiceOverriddenConfiguration.emailFromAddress();

    LocalizedValuesMap subjectLocalizedValuesMap = null;
    LocalizedValuesMap bodyLocalizedValuesMap = null;

    if (update) {
        subjectLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageUpdatedSubject();
        bodyLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageUpdatedBody();
    } else {
        subjectLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageAddedSubject();
        bodyLocalizedValuesMap = wikiGroupServiceOverriddenConfiguration.emailPageAddedBody();
    }

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setClassName(page.getModelClassName());
    subscriptionSender.setClassPK(page.getPageId());
    subscriptionSender.setCompanyId(page.getCompanyId());
    subscriptionSender.setContextAttribute("[$PAGE_CONTENT$]", pageContent, false);
    subscriptionSender.setContextAttribute("[$PAGE_DIFFS$]", DiffHtmlUtil.replaceStyles(pageDiffs), false);

    WikiNode node = page.getNode();

    subscriptionSender.setContextAttributes("[$DIFFS_URL$]",
            getDiffsURL(page, previousVersionPage, serviceContext), "[$NODE_NAME$]", node.getName(),
            "[$PAGE_DATE_UPDATE$]", page.getModifiedDate(), "[$PAGE_ID$]", page.getPageId(), "[$PAGE_SUMMARY$]",
            page.getSummary(), "[$PAGE_TITLE$]", pageTitle, "[$PAGE_URL$]", pageURL);

    subscriptionSender.setContextCreatorUserPrefix("PAGE");
    subscriptionSender.setCreatorUserId(page.getUserId());
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(pageTitle);
    subscriptionSender.setEntryURL(pageURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);

    if (bodyLocalizedValuesMap != null) {
        subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap));
    }

    if (subjectLocalizedValuesMap != null) {
        subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap));
    }

    subscriptionSender.setMailId("wiki_page", page.getNodeId(), page.getPageId());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

    if (update) {
        notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY;
    }

    subscriptionSender.setNotificationType(notificationType);

    subscriptionSender.setPortletId(WikiPortletKeys.WIKI);
    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(page.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);

    subscriptionSender.addPersistedSubscribers(WikiNode.class.getName(), page.getNodeId());

    subscriptionSender.addPersistedSubscribers(WikiPage.class.getName(), page.getResourcePrimKey());

    subscriptionSender.flushNotificationsAsync();
}