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.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.repository.model.FileVersion;
021    
022    /**
023     * Document library processor responsible for the generation of raw metadata
024     * associated with all of the the files stored in the document library.
025     *
026     * <p>
027     * This processor automatically and assynchronously extracts the metadata from
028     * all of the files stored in the document library. The metadata extraction is
029     * done with the help of {@link
030     * com.liferay.portal.metadata.TikaRawMetadataProcessor}
031     * </p>
032     *
033     * @author Alexander Chow
034     * @author Mika Koivisto
035     * @author Miguel Pastor
036     */
037    public interface RawMetadataProcessor {
038    
039            public void cleanUp(FileEntry fileEntry);
040    
041            public void cleanUp(FileVersion fileVersion);
042    
043            /**
044             * Generates the raw metadata associated with the file entry.
045             *
046             * @param  fileVersion the file version from which the raw metatada is to be
047             *         generated
048             * @throws PortalException if an error occurred in the metadata extraction
049             * @throws SystemException if a system exception occurred
050             */
051            public void generateMetadata(FileVersion fileVersion)
052                    throws PortalException, SystemException;
053    
054            public boolean isSupported(FileVersion fileVersion);
055    
056            public boolean isSupported(String mimeType);
057    
058            /**
059             * Saves the raw metadata present in the file version.
060             *
061             * <p>
062             * The raw metadata present in the file version is extracted and persisted
063             * using {@link com.liferay.portal.metadata.TikaRawMetadataProcessor}.
064             * </p>
065             *
066             * @param  fileVersion the file version from which the raw metatada is to be
067             *         extracted and persisted
068             * @throws PortalException if an error occurred in the metadata extraction
069             * @throws SystemException if a system exception occurred
070             */
071            public void saveMetadata(FileVersion fileVersion)
072                    throws PortalException, SystemException;
073    
074            /**
075             * Launches extraction of raw metadata from the file version.
076             *
077             * <p>
078             * The raw metadata extraction is done asynchronously.
079             * </p>
080             *
081             * @param fileVersion the latest file version from which the raw metadata is
082             *        to be generated
083             */
084            public void trigger(FileVersion fileVersion);
085    
086    }