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.model.Filter;
26  import com.liferay.mail.service.MailService;
27  import com.liferay.mail.service.jms.MailProducer;
28  import com.liferay.portal.SystemException;
29  import com.liferay.portal.kernel.mail.MailMessage;
30  import com.liferay.portal.kernel.util.BooleanWrapper;
31  import com.liferay.portal.kernel.util.LongWrapper;
32  import com.liferay.portal.kernel.util.MethodWrapper;
33  import com.liferay.portal.util.PropsValues;
34  
35  import java.util.List;
36  
37  import org.apache.commons.logging.Log;
38  import org.apache.commons.logging.LogFactory;
39  
40  /**
41   * <a href="MailServiceImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * @author Brian Wing Shun Chan
44   *
45   */
46  public class MailServiceImpl implements MailService {
47  
48      public void addForward(
49              long userId, List<Filter> filters, List<String> emailAddresses,
50              boolean leaveCopy)
51          throws SystemException {
52  
53          if (_log.isDebugEnabled()) {
54              _log.debug("addForward");
55          }
56  
57          MethodWrapper methodWrapper = new MethodWrapper(
58              PropsValues.MAIL_HOOK_IMPL, "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          MethodWrapper methodWrapper = new MethodWrapper(
77              PropsValues.MAIL_HOOK_IMPL, "addUser",
78              new Object[] {
79                  new LongWrapper(userId), password, firstName, middleName,
80                  lastName, emailAddress
81              });
82  
83          MailProducer.produce(methodWrapper);
84      }
85  
86      public void addVacationMessage(
87              long userId, String emailAddress, String vacationMessage)
88          throws SystemException {
89  
90          if (_log.isDebugEnabled()) {
91              _log.debug("addVacationMessage");
92          }
93  
94          MethodWrapper methodWrapper = new MethodWrapper(
95              PropsValues.MAIL_HOOK_IMPL, "addVacationMessage",
96              new Object[] {
97                  new LongWrapper(userId), emailAddress, vacationMessage
98              });
99  
100         MailProducer.produce(methodWrapper);
101     }
102 
103     public void deleteEmailAddress(long userId) throws SystemException {
104         if (_log.isDebugEnabled()) {
105             _log.debug("deleteEmailAddress");
106         }
107 
108         MethodWrapper methodWrapper = new MethodWrapper(
109             PropsValues.MAIL_HOOK_IMPL, "deleteEmailAddress",
110             new Object[] {new LongWrapper(userId)});
111 
112         MailProducer.produce(methodWrapper);
113     }
114 
115     public void deleteUser(long userId) throws SystemException {
116         if (_log.isDebugEnabled()) {
117             _log.debug("deleteUser");
118         }
119 
120         MethodWrapper methodWrapper = new MethodWrapper(
121             PropsValues.MAIL_HOOK_IMPL, "deleteUser",
122             new Object[] {new LongWrapper(userId)});
123 
124         MailProducer.produce(methodWrapper);
125     }
126 
127     public void sendEmail(MailMessage mailMessage) throws SystemException {
128         if (_log.isDebugEnabled()) {
129             _log.debug("sendEmail");
130         }
131 
132         MailProducer.produce(mailMessage);
133     }
134 
135     public void updateBlocked(long userId, List<String> blocked)
136         throws SystemException {
137 
138         if (_log.isDebugEnabled()) {
139             _log.debug("updateBlocked");
140         }
141 
142         MethodWrapper methodWrapper = new MethodWrapper(
143             PropsValues.MAIL_HOOK_IMPL, "updateBlocked",
144             new Object[] {new LongWrapper(userId), blocked});
145 
146         MailProducer.produce(methodWrapper);
147     }
148 
149     public void updateEmailAddress(long userId, String emailAddress)
150         throws SystemException {
151 
152         if (_log.isDebugEnabled()) {
153             _log.debug("updateEmailAddress");
154         }
155 
156         MethodWrapper methodWrapper = new MethodWrapper(
157             PropsValues.MAIL_HOOK_IMPL, "updateEmailAddress",
158             new Object[] {new LongWrapper(userId), emailAddress});
159 
160         MailProducer.produce(methodWrapper);
161     }
162 
163     public void updatePassword(long userId, String password)
164         throws SystemException {
165 
166         if (_log.isDebugEnabled()) {
167             _log.debug("updatePassword");
168         }
169 
170         MethodWrapper methodWrapper = new MethodWrapper(
171             PropsValues.MAIL_HOOK_IMPL, "updatePassword",
172             new Object[] {new LongWrapper(userId), password});
173 
174         MailProducer.produce(methodWrapper);
175     }
176 
177     private static Log _log = LogFactory.getLog(MailServiceImpl.class);
178 
179 }