001    /**
002     * Copyright (c) 2000-2013 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.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 {@link #getExpandoBridge(long, String)}
045             */
046            public static ExpandoBridge getExpandoBridge(String className) {
047                    long companyId = CompanyThreadLocal.getCompanyId();
048    
049                    return getExpandoBridge(companyId, className);
050            }
051    
052            /**
053             * @deprecated {@link #getExpandoBridge(long, String, long)}
054             */
055            public static ExpandoBridge getExpandoBridge(
056                    String className, long classPK) {
057    
058                    long companyId = CompanyThreadLocal.getCompanyId();
059    
060                    return getExpandoBridge(companyId, className, classPK);
061            }
062    
063            public static ExpandoBridgeFactory getExpandoBridgeFactory() {
064                    PortalRuntimePermission.checkGetBeanProperty(
065                            ExpandoBridgeFactoryUtil.class);
066    
067                    return _expandoBridgeFactory;
068            }
069    
070            public void setExpandoBridgeFactory(
071                    ExpandoBridgeFactory expandoBridgeFactory) {
072    
073                    PortalRuntimePermission.checkSetBeanProperty(getClass());
074    
075                    _expandoBridgeFactory = expandoBridgeFactory;
076            }
077    
078            private static ExpandoBridgeFactory _expandoBridgeFactory;
079    
080    }