1   /**
2    * Copyright (c) 2000-2008 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.PropsValues;
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          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          MailProducer.produce(methodWrapper);
63      }
64  
65      public void addUser(
66              long userId, String password, String firstName, String middleName,
67              String lastName, String emailAddress)
68          throws SystemException {
69  
70          if (_log.isDebugEnabled()) {
71              _log.debug("addUser");
72          }
73  
74          MethodWrapper methodWrapper = new MethodWrapper(
75              PropsValues.MAIL_HOOK_IMPL, "addUser",
76              new Object[] {
77                  new LongWrapper(userId), password, firstName, middleName,
78                  lastName, emailAddress
79              });
80  
81          MailProducer.produce(methodWrapper);
82      }
83  
84      public void addVacationMessage(
85              long userId, String emailAddress, String vacationMessage)
86          throws SystemException {
87  
88          if (_log.isDebugEnabled()) {
89              _log.debug("addVacationMessage");
90          }
91  
92          MethodWrapper methodWrapper = new MethodWrapper(
93              PropsValues.MAIL_HOOK_IMPL, "addVacationMessage",
94              new Object[] {
95                  new LongWrapper(userId), emailAddress, vacationMessage
96              });
97  
98          MailProducer.produce(methodWrapper);
99      }
100 
101     public void deleteEmailAddress(long userId) throws SystemException {
102         if (_log.isDebugEnabled()) {
103             _log.debug("deleteEmailAddress");
104         }
105 
106         MethodWrapper methodWrapper = new MethodWrapper(
107             PropsValues.MAIL_HOOK_IMPL, "deleteEmailAddress",
108             new Object[] {new LongWrapper(userId)});
109 
110         MailProducer.produce(methodWrapper);
111     }
112 
113     public void deleteUser(long userId) throws SystemException {
114         if (_log.isDebugEnabled()) {
115             _log.debug("deleteUser");
116         }
117 
118         MethodWrapper methodWrapper = new MethodWrapper(
119             PropsValues.MAIL_HOOK_IMPL, "deleteUser",
120             new Object[] {new LongWrapper(userId)});
121 
122         MailProducer.produce(methodWrapper);
123     }
124 
125     public void sendEmail(MailMessage mailMessage) throws SystemException {
126         if (_log.isDebugEnabled()) {
127             _log.debug("sendEmail");
128         }
129 
130         MailProducer.produce(mailMessage);
131     }
132 
133     public void updateBlocked(long userId, List blocked)
134         throws SystemException {
135 
136         if (_log.isDebugEnabled()) {
137             _log.debug("updateBlocked");
138         }
139 
140         MethodWrapper methodWrapper = new MethodWrapper(
141             PropsValues.MAIL_HOOK_IMPL, "updateBlocked",
142             new Object[] {new LongWrapper(userId), blocked});
143 
144         MailProducer.produce(methodWrapper);
145     }
146 
147     public void updateEmailAddress(long userId, String emailAddress)
148         throws SystemException {
149 
150         if (_log.isDebugEnabled()) {
151             _log.debug("updateEmailAddress");
152         }
153 
154         MethodWrapper methodWrapper = new MethodWrapper(
155             PropsValues.MAIL_HOOK_IMPL, "updateEmailAddress",
156             new Object[] {new LongWrapper(userId), emailAddress});
157 
158         MailProducer.produce(methodWrapper);
159     }
160 
161     public void updatePassword(long userId, String password)
162         throws SystemException {
163 
164         if (_log.isDebugEnabled()) {
165             _log.debug("updatePassword");
166         }
167 
168         MethodWrapper methodWrapper = new MethodWrapper(
169             PropsValues.MAIL_HOOK_IMPL, "updatePassword",
170             new Object[] {new LongWrapper(userId), password});
171 
172         MailProducer.produce(methodWrapper);
173     }
174 
175     private static Log _log = LogFactory.getLog(MailServiceImpl.class);
176 
177 }