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