001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 CyrusService getService() {
035                    if (_service == null) {
036                            _service = (CyrusService)PortalBeanLocatorUtil.locate(
037                                    CyrusService.class.getName());
038    
039                            ReferenceRegistry.registerReference(
040                                    CyrusServiceUtil.class, "_service");
041    
042                            MethodCache.remove(CyrusService.class);
043                    }
044    
045                    return _service;
046            }
047    
048            public static void deleteEmailAddress(long companyId, long userId)
049                    throws SystemException {
050    
051                    getService().deleteEmailAddress(companyId, userId);
052            }
053    
054            public static void deleteUser(long userId) throws SystemException {
055                    getService().deleteUser(userId);
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    }