1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.invitation.util;
16  
17  import com.liferay.portal.kernel.util.GetterUtil;
18  import com.liferay.portal.kernel.util.PropsKeys;
19  import com.liferay.portal.kernel.util.StringPool;
20  import com.liferay.portal.kernel.util.Validator;
21  import com.liferay.portal.util.ContentUtil;
22  import com.liferay.portal.util.PropsUtil;
23  
24  import javax.portlet.PortletPreferences;
25  
26  /**
27   * <a href="InvitationUtil.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class InvitationUtil {
32  
33      public static int getEmailMessageMaxRecipients() {
34          return GetterUtil.getInteger(PropsUtil.get(
35              PropsKeys.INVITATION_EMAIL_MAX_RECIPIENTS));
36      }
37  
38      public static String getEmailMessageBody(PortletPreferences preferences) {
39          String emailMessageBody = preferences.getValue(
40              "email-message-body", StringPool.BLANK);
41  
42          if (Validator.isNotNull(emailMessageBody)) {
43              return emailMessageBody;
44          }
45          else {
46              return ContentUtil.get(PropsUtil.get(
47                  PropsKeys.INVITATION_EMAIL_MESSAGE_BODY));
48          }
49      }
50  
51      public static String getEmailMessageSubject(
52          PortletPreferences preferences) {
53  
54          String emailMessageSubject = preferences.getValue(
55              "email-message-subject", StringPool.BLANK);
56  
57          if (Validator.isNotNull(emailMessageSubject)) {
58              return emailMessageSubject;
59          }
60          else {
61              return ContentUtil.get(PropsUtil.get(
62                  PropsKeys.INVITATION_EMAIL_MESSAGE_SUBJECT));
63          }
64      }
65  
66  }