001    /**
002     * Copyright (c) 2000-2013 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.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.MethodCache;
020    import com.liferay.portal.kernel.util.ReferenceRegistry;
021    
022    /**
023     * @author Alexander Chow
024     */
025    public class CyrusServiceUtil {
026    
027            public static void addUser(
028                            long userId, String emailAddress, String password)
029                    throws SystemException {
030    
031                    getService().addUser(userId, emailAddress, password);
032            }
033    
034            public static void deleteEmailAddress(long companyId, long userId)
035                    throws SystemException {
036    
037                    getService().deleteEmailAddress(companyId, userId);
038            }
039    
040            public static void deleteUser(long userId) throws SystemException {
041                    getService().deleteUser(userId);
042            }
043    
044            public static CyrusService getService() {
045                    if (_service == null) {
046                            _service = (CyrusService)PortalBeanLocatorUtil.locate(
047                                    CyrusService.class.getName());
048    
049                            ReferenceRegistry.registerReference(
050                                    CyrusServiceUtil.class, "_service");
051    
052                            MethodCache.remove(CyrusService.class);
053                    }
054    
055                    return _service;
056            }
057    
058            public static void updateEmailAddress(
059                            long companyId, long userId, String emailAddress)
060                    throws SystemException {
061    
062                    getService().updateEmailAddress(companyId, userId, emailAddress);
063            }
064    
065            public static void updatePassword(
066                            long companyId, long userId, String password)
067                    throws SystemException {
068    
069                    getService().updatePassword(companyId, userId, password);
070            }
071    
072            public void setService(CyrusService service) {
073                    _service = service;
074    
075                    ReferenceRegistry.registerReference(CyrusServiceUtil.class, "_service");
076    
077                    MethodCache.remove(CyrusService.class);
078            }
079    
080            private static CyrusService _service;
081    
082    }