001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.mail.service;
016    
017    import com.liferay.mail.model.Filter;
018    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.mail.MailMessage;
021    
022    import java.util.List;
023    
024    import javax.mail.Session;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class MailServiceUtil {
030    
031            public static void addForward(
032                    long companyId, long userId, List<Filter> filters,
033                    List<String> emailAddresses, boolean leaveCopy) {
034    
035                    getService().addForward(
036                            companyId, userId, filters, emailAddresses, leaveCopy);
037            }
038    
039            public static void addUser(
040                    long companyId, long userId, String password, String firstName,
041                    String middleName, String lastName, String emailAddress) {
042    
043                    getService().addUser(
044                            companyId, userId, password, firstName, middleName, lastName,
045                            emailAddress);
046            }
047    
048            public static void addVacationMessage(
049                    long companyId, long userId, String emailAddress,
050                    String vacationMessage) {
051    
052                    getService().addVacationMessage(
053                            companyId, userId, emailAddress, vacationMessage);
054            }
055    
056            public static void clearSession() {
057                    getService().clearSession();
058            }
059    
060            public static void deleteEmailAddress(long companyId, long userId) {
061                    getService().deleteEmailAddress(companyId, userId);
062            }
063    
064            public static void deleteUser(long companyId, long userId) {
065                    getService().deleteUser(companyId, userId);
066            }
067    
068            public static MailService getService() {
069                    if (_service == null) {
070                            _service = (MailService)PortalBeanLocatorUtil.locate(
071                                    MailService.class.getName());
072                    }
073    
074                    return _service;
075            }
076    
077            public static Session getSession() throws SystemException {
078                    return getService().getSession();
079            }
080    
081            public static void sendEmail(MailMessage mailMessage) {
082                    getService().sendEmail(mailMessage);
083            }
084    
085            public static void updateBlocked(
086                    long companyId, long userId, List<String> blocked) {
087    
088                    getService().updateBlocked(companyId, userId, blocked);
089            }
090    
091            public static void updateEmailAddress(
092                    long companyId, long userId, String emailAddress) {
093    
094                    getService().updateEmailAddress(companyId, userId, emailAddress);
095            }
096    
097            public static void updatePassword(
098                    long companyId, long userId, String password) {
099    
100                    getService().updatePassword(companyId, userId, password);
101            }
102    
103            public void setService(MailService service) {
104                    _service = service;
105            }
106    
107            private static MailService _service;
108    
109    }