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 getThumbnailAsStream(
050                            FileVersion fileVersion, int thumbnailIndex)
051                    throws Exception {
052    
053                    return getImageProcessor().getThumbnailAsStream(
054                            fileVersion, thumbnailIndex);
055            }
056    
057            public static long getThumbnailFileSize(
058                            FileVersion fileVersion, int thumbnailIndex)
059                    throws Exception {
060    
061                    return getImageProcessor().getThumbnailFileSize(
062                            fileVersion, thumbnailIndex);
063            }
064    
065            public static boolean hasImages(FileVersion fileVersion) {
066                    return getImageProcessor().hasImages(fileVersion);
067            }
068    
069            public static boolean isImageSupported(FileVersion fileVersion) {
070                    return getImageProcessor().isImageSupported(fileVersion);
071            }
072    
073            public static boolean isImageSupported(String mimeType) {
074                    return getImageProcessor().isImageSupported(mimeType);
075            }
076    
077            public static boolean isSupported(String mimeType) {
078                    return getImageProcessor().isSupported(mimeType);
079            }
080    
081            public static void storeThumbnail(
082                            long companyId, long groupId, long fileEntryId, long fileVersionId,
083                            long custom1ImageId, long custom2ImageId,
084                            InputStream is, String type)
085                    throws Exception {
086    
087                    getImageProcessor().storeThumbnail(
088                            companyId, groupId, fileEntryId, fileVersionId, custom1ImageId,
089                            custom2ImageId, is, type);
090            }
091    
092            public static void trigger(FileVersion fileVersion) {
093                    getImageProcessor().trigger(fileVersion);
094            }
095    
096            public void setImageProcessor(ImageProcessor imageProcessor) {
097                    _imageProcessor = imageProcessor;
098            }
099    
100            private static ImageProcessor _imageProcessor;
101    
102    }