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