001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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.ContentUtil;
022    import com.liferay.portal.util.PropsUtil;
023    
024    import javax.portlet.PortletPreferences;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class InvitationUtil {
030    
031            public static int getEmailMessageMaxRecipients() {
032                    return GetterUtil.getInteger(PropsUtil.get(
033                            PropsKeys.INVITATION_EMAIL_MAX_RECIPIENTS));
034            }
035    
036            public static String getEmailMessageBody(PortletPreferences preferences) {
037                    String emailMessageBody = preferences.getValue(
038                            "email-message-body", StringPool.BLANK);
039    
040                    if (Validator.isNotNull(emailMessageBody)) {
041                            return emailMessageBody;
042                    }
043                    else {
044                            return ContentUtil.get(PropsUtil.get(
045                                    PropsKeys.INVITATION_EMAIL_MESSAGE_BODY));
046                    }
047            }
048    
049            public static String getEmailMessageSubject(
050                    PortletPreferences preferences) {
051    
052                    String emailMessageSubject = preferences.getValue(
053                            "email-message-subject", 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    }