001    /**
002     * Copyright (c) 2000-present 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.mail.MailMessage;
020    import com.liferay.portal.kernel.util.ReferenceRegistry;
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                            ReferenceRegistry.registerReference(
074                                    MailServiceUtil.class, "_service");
075                    }
076    
077                    return _service;
078            }
079    
080            public static Session getSession() {
081                    return getService().getSession();
082            }
083    
084            public static void sendEmail(MailMessage mailMessage) {
085                    getService().sendEmail(mailMessage);
086            }
087    
088            public static void updateBlocked(
089                    long companyId, long userId, List<String> blocked) {
090    
091                    getService().updateBlocked(companyId, userId, blocked);
092            }
093    
094            public static void updateEmailAddress(
095                    long companyId, long userId, String emailAddress) {
096    
097                    getService().updateEmailAddress(companyId, userId, emailAddress);
098            }
099    
100            public static void updatePassword(
101                    long companyId, long userId, String password) {
102    
103                    getService().updatePassword(companyId, userId, password);
104            }
105    
106            public void setService(MailService service) {
107                    _service = service;
108    
109                    ReferenceRegistry.registerReference(MailServiceUtil.class, "_service");
110            }
111    
112            private static MailService _service;
113    
114    }