1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.mail.service;
16  
17  import com.liferay.mail.model.Filter;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
20  import com.liferay.portal.kernel.mail.MailMessage;
21  import com.liferay.portal.kernel.util.MethodCache;
22  import com.liferay.portal.kernel.util.ReferenceRegistry;
23  
24  import java.util.List;
25  
26  import javax.mail.Session;
27  
28  /**
29   * <a href="MailServiceUtil.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class MailServiceUtil {
34  
35      public static void addForward(
36          long companyId, long userId, List<Filter> filters,
37          List<String> emailAddresses, boolean leaveCopy) {
38  
39          getService().addForward(
40              companyId, userId, filters, emailAddresses, leaveCopy);
41      }
42  
43      public static void addUser(
44          long companyId, long userId, String password, String firstName,
45          String middleName, String lastName, String emailAddress) {
46  
47          getService().addUser(
48              companyId, userId, password, firstName, middleName, lastName,
49              emailAddress);
50      }
51  
52      public static void addVacationMessage(
53          long companyId, long userId, String emailAddress,
54          String vacationMessage) {
55  
56          getService().addVacationMessage(
57              companyId, userId, emailAddress, vacationMessage);
58      }
59  
60      public static void clearSession() {
61          getService().clearSession();
62      }
63  
64      public static void deleteEmailAddress(long companyId, long userId) {
65          getService().deleteEmailAddress(companyId, userId);
66      }
67  
68      public static void deleteUser(long companyId, long userId) {
69          getService().deleteUser(companyId, userId);
70      }
71  
72      public static MailService getService() {
73          if (_service == null) {
74              _service = (MailService)PortalBeanLocatorUtil.locate(
75                  MailService.class.getName());
76  
77              ReferenceRegistry.registerReference(
78                  MailServiceUtil.class, "_service");
79  
80              MethodCache.remove(MailService.class);
81          }
82  
83          return _service;
84      }
85  
86      public static Session getSession() throws SystemException {
87          return getService().getSession();
88      }
89  
90      public static void sendEmail(MailMessage mailMessage) {
91          getService().sendEmail(mailMessage);
92      }
93  
94      public static void updateBlocked(
95          long companyId, long userId, List<String> blocked) {
96  
97          getService().updateBlocked(companyId, userId, blocked);
98      }
99  
100     public static void updateEmailAddress(
101         long companyId, long userId, String emailAddress) {
102 
103         getService().updateEmailAddress(companyId, userId, emailAddress);
104     }
105 
106     public static void updatePassword(
107         long companyId, long userId, String password) {
108 
109         getService().updatePassword(companyId, userId, password);
110     }
111 
112     public void setService(MailService service) {
113         _service = service;
114 
115         ReferenceRegistry.registerReference(MailServiceUtil.class, "_service");
116 
117         MethodCache.remove(MailService.class);
118     }
119 
120     private static MailService _service;
121 
122 }