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.portlet.asset;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portlet.asset.model.AssetRendererFactory;
019    
020    import java.util.List;
021    
022    /**
023     * @author Bruno Farache
024     * @author Marcellus Tavares
025     */
026    public class AssetRendererFactoryRegistryUtil {
027    
028            public static List<AssetRendererFactory> getAssetRendererFactories() {
029                    return getAssetRendererFactoryRegistry().getAssetRendererFactories();
030            }
031    
032            public static AssetRendererFactory getAssetRendererFactoryByClassName(
033                    String className) {
034    
035                    return getAssetRendererFactoryRegistry().
036                            getAssetRendererFactoryByClassName(className);
037            }
038    
039            public static AssetRendererFactory getAssetRendererFactoryByType(
040                    String type) {
041    
042                    return getAssetRendererFactoryRegistry().getAssetRendererFactoryByType(
043                            type);
044            }
045    
046            public static AssetRendererFactoryRegistry
047                    getAssetRendererFactoryRegistry() {
048    
049                    PortalRuntimePermission.checkGetBeanProperty(
050                            AssetRendererFactoryRegistryUtil.class);
051    
052                    return _assetRendererFactoryRegistry;
053            }
054    
055            public static long[] getClassNameIds() {
056                    return getAssetRendererFactoryRegistry().getClassNameIds();
057            }
058    
059            public static void register(AssetRendererFactory assetRendererFactory) {
060                    getAssetRendererFactoryRegistry().register(assetRendererFactory);
061            }
062    
063            public static void register(
064                    List<AssetRendererFactory> assetRendererFactories) {
065    
066                    for (AssetRendererFactory assetRendererFactory :
067                                    assetRendererFactories) {
068    
069                            register(assetRendererFactory);
070                    }
071            }
072    
073            public static void unregister(AssetRendererFactory assetRendererFactory) {
074                    getAssetRendererFactoryRegistry().unregister(assetRendererFactory);
075            }
076    
077            public static void unregister(
078                    List<AssetRendererFactory> assetRendererFactories) {
079    
080                    for (AssetRendererFactory assetRendererFactory :
081                                    assetRendererFactories) {
082    
083                            unregister(assetRendererFactory);
084                    }
085            }
086    
087            public void setAssetRendererFactoryRegistry(
088                    AssetRendererFactoryRegistry assetRendererFactoryRegistry) {
089    
090                    PortalRuntimePermission.checkSetBeanProperty(getClass());
091    
092                    _assetRendererFactoryRegistry = assetRendererFactoryRegistry;
093            }
094    
095            private static AssetRendererFactoryRegistry _assetRendererFactoryRegistry;
096    
097    }