1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.mail.service.impl;
24  
25  import com.liferay.mail.model.Filter;
26  import com.liferay.mail.service.MailService;
27  import com.liferay.portal.kernel.log.Log;
28  import com.liferay.portal.kernel.log.LogFactoryUtil;
29  import com.liferay.portal.kernel.mail.MailMessage;
30  import com.liferay.portal.kernel.messaging.DestinationNames;
31  import com.liferay.portal.kernel.messaging.MessageBusUtil;
32  import com.liferay.portal.kernel.util.BooleanWrapper;
33  import com.liferay.portal.kernel.util.LongWrapper;
34  import com.liferay.portal.kernel.util.MethodWrapper;
35  import com.liferay.portal.util.PropsValues;
36  
37  import java.util.List;
38  
39  /**
40   * <a href="MailServiceImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * @author Brian Wing Shun Chan
43   *
44   */
45  public class MailServiceImpl implements MailService {
46  
47      public void addForward(
48          long userId, List<Filter> filters, List<String> emailAddresses,
49          boolean leaveCopy) {
50  
51          if (_log.isDebugEnabled()) {
52              _log.debug("addForward");
53          }
54  
55          MethodWrapper methodWrapper = new MethodWrapper(
56              PropsValues.MAIL_HOOK_IMPL, "addForward",
57              new Object[] {
58                  new LongWrapper(userId), filters, emailAddresses,
59                  new BooleanWrapper(leaveCopy)
60              });
61  
62          MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
63      }
64  
65      public void addUser(
66          long userId, String password, String firstName, String middleName,
67          String lastName, String emailAddress) {
68  
69          if (_log.isDebugEnabled()) {
70              _log.debug("addUser");
71          }
72  
73          MethodWrapper methodWrapper = new MethodWrapper(
74              PropsValues.MAIL_HOOK_IMPL, "addUser",
75              new Object[] {
76                  new LongWrapper(userId), password, firstName, middleName,
77                  lastName, emailAddress
78              });
79  
80          MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
81      }
82  
83      public void addVacationMessage(
84          long userId, String emailAddress, String vacationMessage) {
85  
86          if (_log.isDebugEnabled()) {
87              _log.debug("addVacationMessage");
88          }
89  
90          MethodWrapper methodWrapper = new MethodWrapper(
91              PropsValues.MAIL_HOOK_IMPL, "addVacationMessage",
92              new Object[] {
93                  new LongWrapper(userId), emailAddress, vacationMessage
94              });
95  
96          MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
97      }
98  
99      public void deleteEmailAddress(long userId) {
100         if (_log.isDebugEnabled()) {
101             _log.debug("deleteEmailAddress");
102         }
103 
104         MethodWrapper methodWrapper = new MethodWrapper(
105             PropsValues.MAIL_HOOK_IMPL, "deleteEmailAddress",
106             new Object[] {new LongWrapper(userId)});
107 
108         MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
109     }
110 
111     public void deleteUser(long userId, String companyMx) {
112         if (_log.isDebugEnabled()) {
113             _log.debug("deleteUser");
114         }
115 
116         MethodWrapper methodWrapper = new MethodWrapper(
117             PropsValues.MAIL_HOOK_IMPL, "deleteUser",
118             new Object[] {new LongWrapper(userId), companyMx});
119 
120         MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
121     }
122 
123     public void sendEmail(MailMessage mailMessage) {
124         if (_log.isDebugEnabled()) {
125             _log.debug("sendEmail");
126         }
127 
128         MessageBusUtil.sendMessage(DestinationNames.MAIL, mailMessage);
129     }
130 
131     public void updateBlocked(long userId, List<String> blocked) {
132         if (_log.isDebugEnabled()) {
133             _log.debug("updateBlocked");
134         }
135 
136         MethodWrapper methodWrapper = new MethodWrapper(
137             PropsValues.MAIL_HOOK_IMPL, "updateBlocked",
138             new Object[] {new LongWrapper(userId), blocked});
139 
140         MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
141     }
142 
143     public void updateEmailAddress(long userId, String emailAddress) {
144         if (_log.isDebugEnabled()) {
145             _log.debug("updateEmailAddress");
146         }
147 
148         MethodWrapper methodWrapper = new MethodWrapper(
149             PropsValues.MAIL_HOOK_IMPL, "updateEmailAddress",
150             new Object[] {new LongWrapper(userId), emailAddress});
151 
152         MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
153     }
154 
155     public void updatePassword(long userId, String password) {
156         if (_log.isDebugEnabled()) {
157             _log.debug("updatePassword");
158         }
159 
160         MethodWrapper methodWrapper = new MethodWrapper(
161             PropsValues.MAIL_HOOK_IMPL, "updatePassword",
162             new Object[] {new LongWrapper(userId), password});
163 
164         MessageBusUtil.sendMessage(DestinationNames.MAIL, methodWrapper);
165     }
166 
167     private static Log _log = LogFactoryUtil.getLog(MailServiceImpl.class);
168 
169 }