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.configuration.CmsConfigurationException;
031import org.opencms.file.CmsObject;
032import org.opencms.main.CmsException;
033import org.opencms.report.I_CmsReport;
034import org.opencms.security.CmsRoleViolationException;
035import org.opencms.xml.CmsXmlException;
036
037import org.dom4j.Document;
038
039/**
040 * An import/export handler is an abstract layer to hide the logic how to import/export a specific
041 * type of Cms data.<p>
042 *
043 * To export data, you would create an instance of a class implementing this interface, and call the
044 * implementation's setter methods to arrange which data should be exported. To write the export,
045 * call {@link org.opencms.importexport.CmsImportExportManager#exportData(CmsObject, I_CmsImportExportHandler, I_CmsReport)}.<p>
046 *
047 * To import data, call {@link org.opencms.importexport.CmsImportExportManager#importData(CmsObject, I_CmsReport, CmsImportParameters)}.
048 * You don't have to worry about the contents of an imported a ZIP archive -
049 * the import/export manager finds the right import/export handler implementation
050 * to import the data. You can assign null to the importPath argument in case of a Cms module import.<p>
051 *
052 * Use {@link org.opencms.main.OpenCms#getImportExportManager()} to get the Cms import/export manager.<p>
053 *
054 * @since 6.0.0
055 */
056public interface I_CmsImportExportHandler {
057
058    /**
059     * Exports the data from the Cms.<p>
060     *
061     * @param cms the current OpenCms context object
062     * @param report a Cms report to print log messages
063     *
064     * @throws CmsImportExportException if operation was not successful
065     * @throws CmsRoleViolationException if the current user has not the required role
066     * @throws CmsConfigurationException if a specified module to be exported does not exist
067     */
068    void exportData(CmsObject cms, I_CmsReport report)
069    throws CmsConfigurationException, CmsImportExportException, CmsRoleViolationException;
070
071    /**
072     * Returns the description of this import/export handler.<p>
073     * The description is useful to print some info about the purpose of this handler.<p>
074     *
075     * @return the description of this import/export handler
076     */
077    String getDescription();
078
079    /**
080     * Returns the import parameters.<p>
081     *
082     * @return the import parameters
083     */
084    CmsImportParameters getImportParameters();
085
086    /**
087     * Imports the data into the Cms.<p>
088     *
089     * @param cms the current OpenCms context object
090     * @param report a Cms report to print log messages
091     *
092     * @throws CmsImportExportException if operation was not successful
093     * @throws CmsRoleViolationException if the current user has not the required role
094     * @throws CmsXmlException if the manifest of the import could not be unmarshalled
095     * @throws CmsException in case of errors accessing the VFS
096     */
097    void importData(CmsObject cms, I_CmsReport report)
098    throws CmsXmlException, CmsImportExportException, CmsRoleViolationException, CmsException;
099
100    /**
101     * Imports the data into the Cms.<p>
102     *
103     * @param cms the current OpenCms context object
104     * @param importFile the name (absolute path) of the resource (zip file or folder) to be imported
105     * @param importPath the name (absolute path) of the destination folder in the Cms (if required)
106     * @param report a Cms report to print log messages
107     *
108     * @throws CmsImportExportException if operation was not successful
109     * @throws CmsRoleViolationException if the current user has not the required role
110     * @throws CmsXmlException if the manifest of the import could not be unmarshalled
111     * @throws CmsException in case of errors accessing the VFS
112     *
113     * @deprecated use {@link #importData(CmsObject, I_CmsReport)} instead
114     */
115    @Deprecated
116    void importData(CmsObject cms, String importFile, String importPath, I_CmsReport report)
117    throws CmsXmlException, CmsImportExportException, CmsRoleViolationException, CmsException;
118
119    /**
120     * Checks, if this import/export handler matches with a specified manifest document of an import,
121     * so that it is able to import the data listed in the manifest document.<p>
122     *
123     * @param manifest the manifest.xml of the import as a dom4j XML document
124     * @return true, this handler is able to import the data listed in the manifest document
125     */
126    boolean matches(Document manifest);
127
128    /**
129     * Sets the description of this import/export handler.<p>
130     * The description is useful to print some info about the purpose of this handler.<p>
131     *
132     * @param description the description of this import/export handler
133     */
134    void setDescription(String description);
135
136    /**
137     * Sets the import parameters.<p>
138     *
139     * @param parameters the import parameters to set
140     */
141    void setImportParameters(CmsImportParameters parameters);
142}