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 boolean isPreviewableSize(FileVersion fileVersion) {
066                    return getDLProcessorRegistry().isPreviewableSize(fileVersion);
067            }
068    
069            public static void register(DLProcessor dlProcessor) {
070                    getDLProcessorRegistry().register(dlProcessor);
071            }
072    
073            public static void trigger(FileEntry fileEntry, FileVersion fileVersion) {
074                    getDLProcessorRegistry().trigger(fileEntry, fileVersion);
075            }
076    
077            public static void trigger(
078                    FileEntry fileEntry, FileVersion fileVersion, boolean trusted) {
079    
080                    getDLProcessorRegistry().trigger(fileEntry, fileVersion, trusted);
081            }
082    
083            public static void unregister(DLProcessor dlProcessor) {
084                    getDLProcessorRegistry().unregister(dlProcessor);
085            }
086    
087            public void setDLProcessorRegistry(
088                    DLProcessorRegistry dlProcessorRegistry) {
089    
090                    PortalRuntimePermission.checkSetBeanProperty(getClass());
091    
092                    _dlProcessorRegistry = dlProcessorRegistry;
093            }
094    
095            private static DLProcessorRegistry _dlProcessorRegistry;
096    
097    }