001    /**
002     * Copyright (c) 2000-2013 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.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 final String MESSAGE_POP_PORTLET_PREFIX = "invitation";
032    
033            public static String getEmailMessageBody(PortletPreferences preferences) {
034                    String emailMessageBody = preferences.getValue(
035                            "emailMessageBody", StringPool.BLANK);
036    
037                    if (Validator.isNotNull(emailMessageBody)) {
038                            return emailMessageBody;
039                    }
040                    else {
041                            return ContentUtil.get(
042                                    PropsUtil.get(PropsKeys.INVITATION_EMAIL_MESSAGE_BODY));
043                    }
044            }
045    
046            public static int getEmailMessageMaxRecipients() {
047                    return GetterUtil.getInteger(
048                            PropsUtil.get(PropsKeys.INVITATION_EMAIL_MAX_RECIPIENTS));
049            }
050    
051            public static String getEmailMessageSubject(
052                    PortletPreferences preferences) {
053    
054                    String emailMessageSubject = preferences.getValue(
055                            "emailMessageSubject", StringPool.BLANK);
056    
057                    if (Validator.isNotNull(emailMessageSubject)) {
058                            return emailMessageSubject;
059                    }
060                    else {
061                            return ContentUtil.get(
062                                    PropsUtil.get(PropsKeys.INVITATION_EMAIL_MESSAGE_SUBJECT));
063                    }
064            }
065    
066    }