Example usage for com.liferay.portal.util PropsValues MESSAGE_BOARDS_EMAIL_BULK

List of usage examples for com.liferay.portal.util PropsValues MESSAGE_BOARDS_EMAIL_BULK

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues MESSAGE_BOARDS_EMAIL_BULK.

Prototype

boolean MESSAGE_BOARDS_EMAIL_BULK

To view the source code for com.liferay.portal.util PropsValues MESSAGE_BOARDS_EMAIL_BULK.

Click Source Link

Usage

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

License:Open Source License

protected MBSubscriptionSender getSubscriptionSender(long userId, MBCategory category, MBMessage message,
        String messageURL, String entryTitle, boolean htmlFormat, String messageBody, String messageSubject,
        String messageSubjectPrefix, String inReplyTo, String fromName, String fromAddress,
        String replyToAddress, String emailAddress, String fullName,
        LocalizedValuesMap subjectLocalizedValuesMap, LocalizedValuesMap bodyLocalizedValuesMap,
        ServiceContext serviceContext) {

    MBSubscriptionSender subscriptionSender = new MBSubscriptionSender(MBPermission.RESOURCE_NAME);

    subscriptionSender.setAnonymous(message.isAnonymous());
    subscriptionSender.setBulk(PropsValues.MESSAGE_BOARDS_EMAIL_BULK);
    subscriptionSender.setClassName(message.getModelClassName());
    subscriptionSender.setClassPK(message.getMessageId());
    subscriptionSender.setCompanyId(message.getCompanyId());
    subscriptionSender.setContextAttribute("[$MESSAGE_BODY$]", messageBody, false);

    long groupId = message.getGroupId();

    if (category.getCategoryId() != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

        subscriptionSender.setContextAttribute("[$CATEGORY_NAME$]", category.getName(), true);
    } else {//from w  w w.j  ava 2 s .c o m
        try {
            Group group = _groupLocalService.getGroup(groupId);

            subscriptionSender.setLocalizedContextAttribute("[$CATEGORY_NAME$]",
                    new EscapableLocalizableFunction(locale -> _getLocalizedRootCategoryName(group, locale)));
        } catch (PortalException pe) {
            ReflectionUtil.throwException(pe);
        }
    }

    subscriptionSender.setContextAttributes("[$MAILING_LIST_ADDRESS$]", replyToAddress, "[$MESSAGE_ID$]",
            message.getMessageId(), "[$MESSAGE_SUBJECT$]", messageSubject, "[$MESSAGE_SUBJECT_PREFIX$]",
            messageSubjectPrefix, "[$MESSAGE_URL$]", messageURL, "[$MESSAGE_USER_ADDRESS$]", emailAddress,
            "[$MESSAGE_USER_NAME$]", fullName);
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(entryTitle);
    subscriptionSender.setEntryURL(messageURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setFullName(fullName);
    subscriptionSender.setHtmlFormat(htmlFormat);
    subscriptionSender.setInReplyTo(inReplyTo);

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

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

    Date modifiedDate = message.getModifiedDate();

    subscriptionSender.setMailId(MBUtil.MESSAGE_POP_PORTLET_PREFIX, 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(MBMessage.class.getName(), PortletProvider.Action.VIEW);

    subscriptionSender.setPortletId(portletId);

    subscriptionSender.setReplyToAddress(replyToAddress);
    subscriptionSender.setScopeGroupId(groupId);
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setUniqueMailId(false);

    return subscriptionSender;
}