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             */
048            public void generateMetadata(FileVersion fileVersion)
049                    throws PortalException;
050    
051            public boolean isSupported(FileVersion fileVersion);
052    
053            public boolean isSupported(String mimeType);
054    
055            /**
056             * Saves the raw metadata present in the file version.
057             *
058             * <p>
059             * The raw metadata present in the file version is extracted and persisted
060             * using {@link com.liferay.portal.metadata.TikaRawMetadataProcessor}.
061             * </p>
062             *
063             * @param fileVersion the file version from which the raw metatada is to be
064             *        extracted and persisted
065             */
066            public void saveMetadata(FileVersion fileVersion) throws PortalException;
067    
068            /**
069             * Launches extraction of raw metadata from the file version.
070             *
071             * <p>
072             * The raw metadata extraction is done asynchronously.
073             * </p>
074             *
075             * @param fileVersion the latest file version from which the raw metadata is
076             *        to be generated
077             */
078            public void trigger(FileVersion fileVersion);
079    
080    }