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.portlet.expando.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.security.auth.CompanyThreadLocal;
019    import com.liferay.portlet.expando.model.ExpandoBridge;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class ExpandoBridgeFactoryUtil {
025    
026            public static ExpandoBridge getExpandoBridge(
027                    long companyId, String className) {
028    
029                    PortalRuntimePermission.checkExpandoBridge(className);
030    
031                    return getExpandoBridgeFactory().getExpandoBridge(companyId, className);
032            }
033    
034            public static ExpandoBridge getExpandoBridge(
035                    long companyId, String className, long classPK) {
036    
037                    PortalRuntimePermission.checkExpandoBridge(className);
038    
039                    return getExpandoBridgeFactory().getExpandoBridge(
040                            companyId, className, classPK);
041            }
042    
043            /**
044             * @deprecated As of 6.1.0, replaced by {@link #getExpandoBridge(long,
045             *             String)}
046             */
047            @Deprecated
048            public static ExpandoBridge getExpandoBridge(String className) {
049                    long companyId = CompanyThreadLocal.getCompanyId();
050    
051                    return getExpandoBridge(companyId, className);
052            }
053    
054            /**
055             * @deprecated As of 6.1.0, replaced by {@link #getExpandoBridge(long,
056             *             String, long)}
057             */
058            @Deprecated
059            public static ExpandoBridge getExpandoBridge(
060                    String className, long classPK) {
061    
062                    long companyId = CompanyThreadLocal.getCompanyId();
063    
064                    return getExpandoBridge(companyId, className, classPK);
065            }
066    
067            public static ExpandoBridgeFactory getExpandoBridgeFactory() {
068                    PortalRuntimePermission.checkGetBeanProperty(
069                            ExpandoBridgeFactoryUtil.class);
070    
071                    return _expandoBridgeFactory;
072            }
073    
074            public void setExpandoBridgeFactory(
075                    ExpandoBridgeFactory expandoBridgeFactory) {
076    
077                    PortalRuntimePermission.checkSetBeanProperty(getClass());
078    
079                    _expandoBridgeFactory = expandoBridgeFactory;
080            }
081    
082            private static ExpandoBridgeFactory _expandoBridgeFactory;
083    
084    }