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.documentlibrary.util;
016    
017    import com.liferay.portal.kernel.lar.PortletDataContext;
018    import com.liferay.portal.kernel.repository.model.FileEntry;
019    import com.liferay.portal.kernel.repository.model.FileVersion;
020    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021    import com.liferay.portal.kernel.xml.Element;
022    
023    /**
024     * @author Mika Koivisto
025     */
026    public class DLProcessorRegistryUtil {
027    
028            public static void cleanUp(FileEntry fileEntry) {
029                    getDLProcessorRegistry().cleanUp(fileEntry);
030            }
031    
032            public static void cleanUp(FileVersion fileVersion) {
033                    getDLProcessorRegistry().cleanUp(fileVersion);
034            }
035    
036            public static void exportGeneratedFiles(
037                            PortletDataContext portletDataContext, FileEntry fileEntry,
038                            Element fileEntryElement)
039                    throws Exception {
040    
041                    getDLProcessorRegistry().exportGeneratedFiles(
042                            portletDataContext, fileEntry, fileEntryElement);
043            }
044    
045            public static DLProcessor getDLProcessor(String dlProcessorType) {
046                    return getDLProcessorRegistry().getDLProcessor(dlProcessorType);
047            }
048    
049            public static DLProcessorRegistry getDLProcessorRegistry() {
050                    PortalRuntimePermission.checkGetBeanProperty(
051                            DLProcessorRegistryUtil.class);
052    
053                    return _dlProcessorRegistry;
054            }
055    
056            public static void importGeneratedFiles(
057                            PortletDataContext portletDataContext, FileEntry fileEntry,
058                            FileEntry importedFileEntry, Element fileEntryElement)
059                    throws Exception {
060    
061                    getDLProcessorRegistry().importGeneratedFiles(
062                            portletDataContext, fileEntry, importedFileEntry, fileEntryElement);
063            }
064    
065            public static void register(DLProcessor dlProcessor) {
066                    getDLProcessorRegistry().register(dlProcessor);
067            }
068    
069            public static void trigger(FileEntry fileEntry) {
070                    getDLProcessorRegistry().trigger(fileEntry);
071            }
072    
073            public static void trigger(FileEntry fileEntry, boolean trusted) {
074                    getDLProcessorRegistry().trigger(fileEntry, trusted);
075            }
076    
077            public static void unregister(DLProcessor dlProcessor) {
078                    getDLProcessorRegistry().unregister(dlProcessor);
079            }
080    
081            public void setDLProcessorRegistry(
082                    DLProcessorRegistry dlProcessorRegistry) {
083    
084                    PortalRuntimePermission.checkSetBeanProperty(getClass());
085    
086                    _dlProcessorRegistry = dlProcessorRegistry;
087            }
088    
089            private static DLProcessorRegistry _dlProcessorRegistry;
090    
091    }