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.xml.Element;
021    
022    /**
023     * Common interface for all the processors of the document library. All document
024     * library processors must implement this interface.
025     *
026     * @author Alexander Chow
027     * @author Mika Koivisto
028     * @see    AudioProcessor
029     * @see    DLPreviewableProcessor
030     * @see    ImageProcessor
031     * @see    PDFProcessor
032     * @see    RawMetadataProcessor
033     * @see    VideoProcessor
034     */
035    public interface DLProcessor {
036    
037            public void afterPropertiesSet() throws Exception;
038    
039            public void cleanUp(FileEntry fileEntry);
040    
041            public void cleanUp(FileVersion fileVersion);
042    
043            public void copy(
044                    FileVersion sourceFileVersion, FileVersion destinationFileVersion);
045    
046            public void exportGeneratedFiles(
047                            PortletDataContext portletDataContext, FileEntry fileEntry,
048                            Element fileEntryElement)
049                    throws Exception;
050    
051            public void importGeneratedFiles(
052                            PortletDataContext portletDataContext, FileEntry fileEntry,
053                            FileEntry importedFileEntry, Element fileEntryElement)
054                    throws Exception;
055    
056            public boolean isSupported(FileVersion fileVersion);
057    
058            public boolean isSupported(String mimeType);
059    
060            /**
061             * Launches the processor's work with respect to the given file version.
062             *
063             * @param sourceFileVersion the file version to copy previews and thumbnails
064             *        from (optionally <code>null</code>)
065             * @param destinationFileVersion the latest file version to process
066             */
067            public void trigger(
068                    FileVersion sourceFileVersion, FileVersion destinationFileVersion);
069    
070    }