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.portal.kernel.trash;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.util.List;
020    
021    /**
022     * @author Alexander Chow
023     */
024    public class TrashHandlerRegistryUtil {
025    
026            public static TrashHandler getTrashHandler(String className) {
027                    return getTrashHandlerRegistry().getTrashHandler(className);
028            }
029    
030            public static TrashHandlerRegistry getTrashHandlerRegistry() {
031                    PortalRuntimePermission.checkGetBeanProperty(
032                            TrashHandlerRegistryUtil.class);
033    
034                    return _trashHandlerRegistry;
035            }
036    
037            public static List<TrashHandler> getTrashHandlers() {
038                    return getTrashHandlerRegistry().getTrashHandlers();
039            }
040    
041            public static void register(List<TrashHandler> trashHandlers) {
042                    for (TrashHandler trashHandler : trashHandlers) {
043                            register(trashHandler);
044                    }
045            }
046    
047            public static void register(TrashHandler trashHandler) {
048                    getTrashHandlerRegistry().register(trashHandler);
049            }
050    
051            public static void unregister(List<TrashHandler> trashHandlers) {
052                    for (TrashHandler trashHandler : trashHandlers) {
053                            unregister(trashHandler);
054                    }
055            }
056    
057            public static void unregister(TrashHandler trashHandler) {
058                    getTrashHandlerRegistry().unregister(trashHandler);
059            }
060    
061            public void setTrashHandlerRegistry(
062                    TrashHandlerRegistry trashHandlerRegistry) {
063    
064                    PortalRuntimePermission.checkSetBeanProperty(getClass());
065    
066                    _trashHandlerRegistry = trashHandlerRegistry;
067            }
068    
069            private static TrashHandlerRegistry _trashHandlerRegistry;
070    
071    }