Example usage for com.liferay.portal.kernel.util PrefsPropsUtil getString

List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getString

Introduction

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

Prototype

public static String getString(String name, String defaultValue) 

Source Link

Usage

From source file:org.opencps.util.MessageBusUtil.java

License:Open Source License

public static void sendEmailActiveAccount(User user, String password, ServiceContext serviceContext)
        throws SystemException {

    if (!PrefsPropsUtil.getBoolean(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_USER_ADDED_ENABLED)) {

        return;/*w  w  w  .j  ava 2 s . c  o m*/
    }

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

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

    String subject = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_USER_ADDED_SUBJECT);

    String body = null;

    if (Validator.isNotNull(password)) {
        body = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_USER_ADDED_BODY);
    } else {
        body = PrefsPropsUtil.getContent(user.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_USER_ADDED_NO_PASSWORD_BODY);
    }

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(user.getCompanyId());
    subscriptionSender.setContextAttributes("[$USER_ID$]", user.getUserId(), "[$USER_PASSWORD$]", password,
            "[$USER_SCREENNAME$]", user.getScreenName());
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("user", user.getUserId(), System.currentTimeMillis(),
            PwdGenerator.getPassword());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUserId(user.getUserId());

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
}

From source file:org.opencps.util.MessageBusUtil.java

License:Open Source License

public static void sendEmailWelcomeNewUser(User user, ServiceContext serviceContext) throws SystemException {

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

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

    String subject = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_USER_ADDED_SUBJECT);

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(serviceContext.getCompanyId(), true);

    /*//from w ww.  j  a  va2  s .co  m
     * String emailWelcomeSubject = GetterUtil .getString(preferences
     * .getValue("WELCOME_NEW_USER_SUBJECT", StringPool.BLANK));
     */
    String emailWelcomeBody = GetterUtil
            .getString(preferences.getValue("WELCOME_NEW_USER_BODY", StringPool.BLANK));

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(emailWelcomeBody);
    subscriptionSender.setCompanyId(user.getCompanyId());

    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("user", user.getUserId(), System.currentTimeMillis(),
            PwdGenerator.getPassword());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUserId(user.getUserId());

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
}