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.FileEntry;
018    import com.liferay.portal.kernel.repository.model.FileVersion;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    
021    import java.io.InputStream;
022    
023    import java.util.Set;
024    
025    /**
026     * @author Sergio González
027     */
028    public class ImageProcessorUtil {
029    
030            public static void cleanUp(FileEntry fileEntry) {
031                    getImageProcessor().cleanUp(fileEntry);
032            }
033    
034            public static void cleanUp(FileVersion fileVersion) {
035                    getImageProcessor().cleanUp(fileVersion);
036            }
037    
038            public static void generateImages(FileVersion fileVersion) {
039                    getImageProcessor().generateImages(fileVersion);
040            }
041    
042            public static Set<String> getImageMimeTypes() {
043                    return getImageProcessor().getImageMimeTypes();
044            }
045    
046            public static ImageProcessor getImageProcessor() {
047                    PortalRuntimePermission.checkGetBeanProperty(ImageProcessorUtil.class);
048    
049                    return _imageProcessor;
050            }
051    
052            public static InputStream getPreviewAsStream(FileVersion fileVersion)
053                    throws Exception {
054    
055                    return getImageProcessor().getPreviewAsStream(fileVersion);
056            }
057    
058            public static long getPreviewFileSize(FileVersion fileVersion)
059                    throws Exception {
060    
061                    return getImageProcessor().getPreviewFileSize(fileVersion);
062            }
063    
064            public static String getPreviewType(FileVersion fileVersion) {
065                    return getImageProcessor().getPreviewType(fileVersion);
066            }
067    
068            public static InputStream getThumbnailAsStream(
069                            FileVersion fileVersion, int index)
070                    throws Exception {
071    
072                    return getImageProcessor().getThumbnailAsStream(fileVersion, index);
073            }
074    
075            public static long getThumbnailFileSize(FileVersion fileVersion, int index)
076                    throws Exception {
077    
078                    return getImageProcessor().getThumbnailFileSize(fileVersion, index);
079            }
080    
081            public static String getThumbnailType(FileVersion fileVersion) {
082                    return getImageProcessor().getThumbnailType(fileVersion);
083            }
084    
085            public static boolean hasImages(FileVersion fileVersion) {
086                    return getImageProcessor().hasImages(fileVersion);
087            }
088    
089            public static boolean isImageSupported(FileVersion fileVersion) {
090                    return getImageProcessor().isImageSupported(fileVersion);
091            }
092    
093            public static boolean isImageSupported(String mimeType) {
094                    return getImageProcessor().isImageSupported(mimeType);
095            }
096    
097            public static boolean isSupported(String mimeType) {
098                    return getImageProcessor().isSupported(mimeType);
099            }
100    
101            public static void storeThumbnail(
102                            long companyId, long groupId, long fileEntryId, long fileVersionId,
103                            long custom1ImageId, long custom2ImageId, InputStream is,
104                            String type)
105                    throws Exception {
106    
107                    getImageProcessor().storeThumbnail(
108                            companyId, groupId, fileEntryId, fileVersionId, custom1ImageId,
109                            custom2ImageId, is, type);
110            }
111    
112            public static void trigger(FileVersion fileVersion) {
113                    getImageProcessor().trigger(fileVersion);
114            }
115    
116            public void setImageProcessor(ImageProcessor imageProcessor) {
117                    PortalRuntimePermission.checkSetBeanProperty(getClass());
118    
119                    _imageProcessor = imageProcessor;
120            }
121    
122            private static ImageProcessor _imageProcessor;
123    
124    }