001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.invitation.util;
016    
017    import com.liferay.portal.kernel.util.GetterUtil;
018    import com.liferay.portal.kernel.util.PropsKeys;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.kernel.util.Validator;
021    import com.liferay.portal.util.PropsUtil;
022    import com.liferay.util.ContentUtil;
023    
024    import javax.portlet.PortletPreferences;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class InvitationUtil {
030    
031            public static String getEmailMessageBody(PortletPreferences preferences) {
032                    String emailMessageBody = preferences.getValue(
033                            "emailMessageBody", StringPool.BLANK);
034    
035                    if (Validator.isNotNull(emailMessageBody)) {
036                            return emailMessageBody;
037                    }
038                    else {
039                            return ContentUtil.get(PropsUtil.get(
040                                    PropsKeys.INVITATION_EMAIL_MESSAGE_BODY));
041                    }
042            }
043    
044            public static int getEmailMessageMaxRecipients() {
045                    return GetterUtil.getInteger(PropsUtil.get(
046                            PropsKeys.INVITATION_EMAIL_MAX_RECIPIENTS));
047            }
048    
049            public static String getEmailMessageSubject(
050                    PortletPreferences preferences) {
051    
052                    String emailMessageSubject = preferences.getValue(
053                            "emailMessageSubject", StringPool.BLANK);
054    
055                    if (Validator.isNotNull(emailMessageSubject)) {
056                            return emailMessageSubject;
057                    }
058                    else {
059                            return ContentUtil.get(PropsUtil.get(
060                                    PropsKeys.INVITATION_EMAIL_MESSAGE_SUBJECT));
061                    }
062            }
063    
064    }