1   /**
2    * Copyright (c) 2000-2007 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.service.MailService;
26  import com.liferay.mail.service.jms.MailProducer;
27  import com.liferay.portal.SystemException;
28  import com.liferay.portal.kernel.mail.MailMessage;
29  import com.liferay.portal.kernel.util.BooleanWrapper;
30  import com.liferay.portal.kernel.util.LongWrapper;
31  import com.liferay.portal.kernel.util.MethodWrapper;
32  import com.liferay.portal.util.PropsUtil;
33  
34  import java.util.List;
35  
36  import org.apache.commons.logging.Log;
37  import org.apache.commons.logging.LogFactory;
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 filters, List emailAddresses, boolean leaveCopy)
49          throws SystemException {
50  
51          if (_log.isDebugEnabled()) {
52              _log.debug("addForward");
53          }
54  
55          String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
56  
57          MethodWrapper methodWrapper = new MethodWrapper(
58              hookImpl, "addForward",
59              new Object[] {
60                  new LongWrapper(userId), filters, emailAddresses,
61                  new BooleanWrapper(leaveCopy)
62              });
63  
64          MailProducer.produce(methodWrapper);
65      }
66  
67      public void addUser(
68              long userId, String password, String firstName, String middleName,
69              String lastName, String emailAddress)
70          throws SystemException {
71  
72          if (_log.isDebugEnabled()) {
73              _log.debug("addUser");
74          }
75  
76          String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
77  
78          MethodWrapper methodWrapper = new MethodWrapper(
79              hookImpl, "addUser",
80              new Object[] {
81                  new LongWrapper(userId), password, firstName, middleName,
82                  lastName, emailAddress
83              });
84  
85          MailProducer.produce(methodWrapper);
86      }
87  
88      public void addVacationMessage(
89              long userId, String emailAddress, String vacationMessage)
90          throws SystemException {
91  
92          if (_log.isDebugEnabled()) {
93              _log.debug("addVacationMessage");
94          }
95  
96          String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
97  
98          MethodWrapper methodWrapper = new MethodWrapper(
99              hookImpl, "addVacationMessage",
100             new Object[] {
101                 new LongWrapper(userId), emailAddress, vacationMessage
102             });
103 
104         MailProducer.produce(methodWrapper);
105     }
106 
107     public void deleteEmailAddress(long userId) throws SystemException {
108         if (_log.isDebugEnabled()) {
109             _log.debug("deleteEmailAddress");
110         }
111 
112         String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
113 
114         MethodWrapper methodWrapper = new MethodWrapper(
115             hookImpl, "deleteEmailAddress",
116             new Object[] {new LongWrapper(userId)});
117 
118         MailProducer.produce(methodWrapper);
119     }
120 
121     public void deleteUser(long userId) throws SystemException {
122         if (_log.isDebugEnabled()) {
123             _log.debug("deleteUser");
124         }
125 
126         String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
127 
128         MethodWrapper methodWrapper = new MethodWrapper(
129             hookImpl, "deleteUser", new Object[] {new LongWrapper(userId)});
130 
131         MailProducer.produce(methodWrapper);
132     }
133 
134     public void sendEmail(MailMessage mailMessage) throws SystemException {
135         if (_log.isDebugEnabled()) {
136             _log.debug("sendEmail");
137         }
138 
139         MailProducer.produce(mailMessage);
140     }
141 
142     public void updateBlocked(long userId, List blocked)
143         throws SystemException {
144 
145         if (_log.isDebugEnabled()) {
146             _log.debug("updateBlocked");
147         }
148 
149         String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
150 
151         MethodWrapper methodWrapper = new MethodWrapper(
152             hookImpl, "updateBlocked",
153             new Object[] {new LongWrapper(userId), blocked});
154 
155         MailProducer.produce(methodWrapper);
156     }
157 
158     public void updateEmailAddress(long userId, String emailAddress)
159         throws SystemException {
160 
161         if (_log.isDebugEnabled()) {
162             _log.debug("updateEmailAddress");
163         }
164 
165         String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
166 
167         MethodWrapper methodWrapper = new MethodWrapper(
168             hookImpl, "updateEmailAddress",
169             new Object[] {new LongWrapper(userId), emailAddress});
170 
171         MailProducer.produce(methodWrapper);
172     }
173 
174     public void updatePassword(long userId, String password)
175         throws SystemException {
176 
177         if (_log.isDebugEnabled()) {
178             _log.debug("updatePassword");
179         }
180 
181         String hookImpl = PropsUtil.get(PropsUtil.MAIL_HOOK_IMPL);
182 
183         MethodWrapper methodWrapper = new MethodWrapper(
184             hookImpl, "updatePassword",
185             new Object[] {new LongWrapper(userId), password});
186 
187         MailProducer.produce(methodWrapper);
188     }
189 
190     private static Log _log = LogFactory.getLog(MailServiceImpl.class);
191 
192 }