001    /**
002     * Copyright (c) 2000-2012 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.documentlibrary.util;
016    
017    import com.liferay.portal.kernel.repository.model.FileVersion;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    
020    import java.io.InputStream;
021    
022    import java.util.Properties;
023    
024    /**
025     * @author Sergio González
026     */
027    public class PDFProcessorUtil {
028    
029            public static void generateImages(FileVersion fileVersion)
030                    throws Exception {
031    
032                    getPDFProcessor().generateImages(fileVersion);
033            }
034    
035            public static String getGlobalSearchPath() throws Exception {
036                    return getPDFProcessor().getGlobalSearchPath();
037            }
038    
039            public static PDFProcessor getPDFProcessor() {
040                    PortalRuntimePermission.checkGetBeanProperty(PDFProcessorUtil.class);
041    
042                    return _pdfProcessor;
043            }
044    
045            public static InputStream getPreviewAsStream(
046                            FileVersion fileVersion, int index)
047                    throws Exception {
048    
049                    return getPDFProcessor().getPreviewAsStream(fileVersion, index);
050            }
051    
052            public static int getPreviewFileCount(FileVersion fileVersion) {
053                    return getPDFProcessor().getPreviewFileCount(fileVersion);
054            }
055    
056            public static long getPreviewFileSize(FileVersion fileVersion, int index)
057                    throws Exception {
058    
059                    return getPDFProcessor().getPreviewFileSize(fileVersion, index);
060            }
061    
062            public static Properties getResourceLimitsProperties() throws Exception {
063                    return getPDFProcessor().getResourceLimitsProperties();
064            }
065    
066            public static InputStream getThumbnailAsStream(
067                            FileVersion fileVersion, int index)
068                    throws Exception {
069    
070                    return getPDFProcessor().getThumbnailAsStream(fileVersion, index);
071            }
072    
073            public static long getThumbnailFileSize(FileVersion fileVersion, int index)
074                    throws Exception {
075    
076                    return getPDFProcessor().getThumbnailFileSize(fileVersion, index);
077            }
078    
079            public static boolean hasImages(FileVersion fileVersion) {
080                    return getPDFProcessor().hasImages(fileVersion);
081            }
082    
083            public static boolean isDocumentSupported(FileVersion fileVersion) {
084                    return getPDFProcessor().isDocumentSupported(fileVersion);
085            }
086    
087            public static boolean isDocumentSupported(String mimeType) {
088                    return getPDFProcessor().isDocumentSupported(mimeType);
089            }
090    
091            public static boolean isImageMagickEnabled() throws Exception {
092                    return getPDFProcessor().isImageMagickEnabled();
093            }
094    
095            public static boolean isSupported(String mimeType) {
096                    return getPDFProcessor().isSupported(mimeType);
097            }
098    
099            public static void reset() throws Exception {
100                    getPDFProcessor().reset();
101            }
102    
103            public static void trigger(FileVersion fileVersion) {
104                    getPDFProcessor().trigger(fileVersion);
105            }
106    
107            public void setPDFProcessor(PDFProcessor pdfProcessor) {
108                    PortalRuntimePermission.checkSetBeanProperty(getClass());
109    
110                    _pdfProcessor = pdfProcessor;
111            }
112    
113            private static PDFProcessor _pdfProcessor;
114    
115    }