001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.importexport;
029
030import org.opencms.file.CmsObject;
031import org.opencms.report.I_CmsReport;
032import org.opencms.xml.CmsXmlException;
033
034import java.io.File;
035import java.util.zip.ZipFile;
036
037import org.dom4j.Document;
038
039/**
040 * This interface describes a import class which is used to import resources into the VFS.<p>
041 *
042 * OpenCms supports different import versions, for each version a own import class must be implemented.<p>
043 *
044 * @since 6.0.0
045 */
046public interface I_CmsImport {
047
048    /**
049     * Returns the version of the import implementation.<p>
050     *
051     * <ul>
052     * <li>0 indicates an export file without a version number, that is before version 4.3.23 of OpenCms</li>
053     * <li>1 indicates an export file of OpenCms with a version before 5.0.0</li>
054     * <li>2 indicates an export file of OpenCms with a version before 5.1.2</li>
055     * <li>3 indicates an export file of OpenCms with a version before 5.1.6</li>
056     * <li>4 indicates an export file of OpenCms with a version before 6.3.0</li>
057     * <li>5 indicates an export file of OpenCms with a version before 6.5.6</li>
058     * <li>6 indicates an export file of OpenCms with a version before 7.0.4</li>
059     * <li>7 indicates an export file of OpenCms with a version after 7.0.3</li>
060     * </ul>
061     *
062     * @return the version of the import implementation
063     */
064    int getVersion();
065
066    /**
067     * Imports the data.<p>
068     *
069     * @param cms the current users OpenCms context
070     * @param report a report object to output the progress information to
071     * @param parameters the parameters to use during the import
072     *
073     * @throws CmsImportExportException if something goes wrong
074     * @throws CmsXmlException if the manifest file could not be unmarshalled
075     */
076    void importData(CmsObject cms, I_CmsReport report, CmsImportParameters parameters)
077    throws CmsImportExportException, CmsXmlException;
078
079    /**
080     * Imports the resources.<p>
081     *
082     * @param cms the current users OpenCms context
083     * @param importPath the path in the OpenCms VFS to import into
084     * @param report a report object to output the progress information to
085     * @param importResource the import-resource (folder) to load resources from
086     * @param importZip the import-resource (zip) to load resources from
087     * @param docXml the <code>manifest.xml</code> file which contains the meta information of the imported files
088     *
089     * @throws CmsImportExportException if something goes wrong
090     *
091     * @deprecated use {@link #importData(CmsObject, I_CmsReport, CmsImportParameters)} instead
092     */
093    @Deprecated
094    void importResources(
095        CmsObject cms,
096        String importPath,
097        I_CmsReport report,
098        File importResource,
099        ZipFile importZip,
100        Document docXml) throws CmsImportExportException;
101
102    /**
103     * Checks if the file given as parameter matches this import version implementation.<p>
104     *
105     * @param parameters the parameters to use during matching
106     *
107     * @return <code>true</code> if the file can be imported by this import version implementation
108     *
109     * @throws CmsImportExportException if something goes wrong
110     */
111    boolean matches(CmsImportParameters parameters) throws CmsImportExportException;
112}