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.portal.security.exportimport;
016    
017    import com.liferay.portal.model.Contact;
018    import com.liferay.portal.model.User;
019    import com.liferay.registry.Registry;
020    import com.liferay.registry.RegistryUtil;
021    import com.liferay.registry.ServiceTracker;
022    
023    import java.io.Serializable;
024    
025    import java.util.Map;
026    
027    /**
028     * @author Edward Han
029     * @author Michael C. Han
030     * @author Brian Wing Shun Chan
031     * @author Marcellus Tavares
032     * @author Raymond Aug??
033     */
034    public class UserExporterUtil {
035    
036            public static void exportUser(
037                            Contact contact, Map<String, Serializable> contactExpandoAttributes)
038                    throws Exception {
039    
040                    _getInstance().exportUser(contact, contactExpandoAttributes);
041            }
042    
043            public static void exportUser(
044                            long userId, long userGroupId, UserOperation userOperation)
045                    throws Exception {
046    
047                    _getInstance().exportUser(userId, userGroupId, userOperation);
048            }
049    
050            public static void exportUser(
051                            User user, Map<String, Serializable> userExpandoAttributes)
052                    throws Exception {
053    
054                    _getInstance().exportUser(user, userExpandoAttributes);
055            }
056    
057            private static UserExporter _getInstance() {
058                    return _instance._serviceTracker.getService();
059            }
060    
061            private UserExporterUtil() {
062                    Registry registry = RegistryUtil.getRegistry();
063    
064                    _serviceTracker = registry.trackServices(UserExporter.class);
065    
066                    _serviceTracker.open();
067            }
068    
069            private static final UserExporterUtil _instance = new UserExporterUtil();
070    
071            private final ServiceTracker<UserExporter, UserExporter> _serviceTracker;
072    
073    }