cmsimportexportconfiguration.java

来自「找了很久才找到到源代码」· Java 代码 · 共 999 行 · 第 1/3 页

JAVA
999
字号
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/configuration/CmsImportExportConfiguration.java,v $
 * Date   : $Date: 2007-08-29 13:30:25 $
 * Version: $Revision: 1.32 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) 2002 - 2007 Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.configuration;

import org.opencms.db.CmsUserExportSettings;
import org.opencms.importexport.CmsImportExportManager;
import org.opencms.importexport.I_CmsImportExportHandler;
import org.opencms.main.CmsLog;
import org.opencms.repository.A_CmsRepository;
import org.opencms.repository.CmsRepositoryFilter;
import org.opencms.repository.CmsRepositoryManager;
import org.opencms.security.I_CmsPrincipal;
import org.opencms.staticexport.CmsStaticExportExportRule;
import org.opencms.staticexport.CmsStaticExportManager;
import org.opencms.staticexport.CmsStaticExportRfsRule;

import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import org.apache.commons.digester.Digester;

import org.dom4j.Element;

/**
 * Import / export master configuration class.<p>
 * 
 * @author Alexander Kandzior 
 * 
 * @version $Revision: 1.32 $
 * 
 * @since 6.0.0
 */
public class CmsImportExportConfiguration extends A_CmsXmlConfiguration implements I_CmsXmlConfiguration {

    /** The name of the DTD for this configuration. */
    public static final String CONFIGURATION_DTD_NAME = "opencms-importexport.dtd";

    /** The name of the default XML file for this configuration. */
    public static final String DEFAULT_XML_FILE_NAME = "opencms-importexport.xml";

    /**  The node name of the column node. */
    public static final String N_COLUMN = "column";

    /**  The node name of the columns node. */
    public static final String N_COLUMNS = "columns";

    /** Node that indicates page conversion. */
    public static final String N_CONVERT = "convert";

    /** The node name of the repository filter node. */
    public static final String N_FILTER = "filter";

    /** Node that contains a list of properties ignored during import. */
    public static final String N_IGNOREDPROPERTIES = "ignoredproperties";

    /** The import immutable resources node. */
    public static final String N_IMMUTABLES = "immutables";

    /** The node name of the import subconfiguration. */
    public static final String N_IMPORT = "import";

    /** The main configuration node name. */
    public static final String N_IMPORTEXPORT = "importexport";

    /** The node name of an individual import/export handler. */
    public static final String N_IMPORTEXPORTHANDLER = "importexporthandler";

    /** Master node for import/export handlers. */
    public static final String N_IMPORTEXPORTHANDLERS = "importexporthandlers";

    /** The node name of an individual import version class. */
    public static final String N_IMPORTVERSION = "importversion";

    /** Master node for import version class names. */
    public static final String N_IMPORTVERSIONS = "importversions";

    /**  The node name of the static export handler node. */
    public static final String N_LINKSUBSTITUTION_HANDLER = "linksubstitutionhandler";

    /** Node the contains an optional URL of old web application. */
    public static final String N_OLDWEBAPPURL = "oldwebappurl";

    /** The import overwrite node name. */
    public static final String N_OVERWRITE = "overwrite";

    /** The node name of the repository params node. */
    public static final String N_PARAMS = "params";

    /** An individual principal translation node. */
    public static final String N_PRINCIPALTRANSLATION = "principaltranslation";

    /** The principal translation node. */
    public static final String N_PRINCIPALTRANSLATIONS = "principaltranslations";

    /** The node name of the repository filter regex node. */
    public static final String N_REGEX = "regex";

    /** The node name of the repositories node. */
    public static final String N_REPOSITORIES = "repositories";

    /** The node name of the repository node. */
    public static final String N_REPOSITORY = "repository";

    /**  The node name of the separator node. */
    public static final String N_SEPARATOR = "separator";

    /**  The main configuration node for static export name. */
    public static final String N_STATICEXPORT = "staticexport";

    /**  The node name of the static export acceptcharset node. */
    public static final String N_STATICEXPORT_ACCEPTCHARSET = "acceptcharset";

    /**  The node name of the static export acceptlanguage node. */
    public static final String N_STATICEXPORT_ACCEPTLANGUAGE = "acceptlanguage";

    /**  The node name of the static export default node. */
    public static final String N_STATICEXPORT_DEFAULT = "defaultpropertyvalue";

    /**  The node name of the static export defualtsuffix node. */
    public static final String N_STATICEXPORT_DEFAULTSUFFIXES = "defaultsuffixes";

    /**  The node name of the static export rule description nodes. */
    public static final String N_STATICEXPORT_DESCRIPTION = "description";

    /**  The node name of the static export export-rule export node. */
    public static final String N_STATICEXPORT_EXPORT = "export-resources";

    /**  The node name of the static export exportbackups node. */
    public static final String N_STATICEXPORT_EXPORTBACKUPS = "exportbackups";

    /**  The node name of the static export exportheaders node. */
    public static final String N_STATICEXPORT_EXPORTHEADERS = "exportheaders";

    /**  The node name of the static export exportpath node. */
    public static final String N_STATICEXPORT_EXPORTPATH = "exportpath";

    /**  The node name of the static export export-rule node. */
    public static final String N_STATICEXPORT_EXPORTRULE = "export-rule";

    /**  The node name of the static export export-rules node. */
    public static final String N_STATICEXPORT_EXPORTRULES = "export-rules";

    /**  The node name of the static export exporturl node. */
    public static final String N_STATICEXPORT_EXPORTURL = "exporturl";

    /**  The node name of the static export exportworkpath node. */
    public static final String N_STATICEXPORT_EXPORTWORKPATH = "exportworkpath";

    /**  The node name of the static export handler node. */
    public static final String N_STATICEXPORT_HANDLER = "staticexporthandler";

    /**  The node name of the static export header node. */
    public static final String N_STATICEXPORT_HEADER = "header";

    /**  The node name of the static export export-rule modified node. */
    public static final String N_STATICEXPORT_MODIFIED = "modified-resources";

    /**  The node name of the static export rule name nodes. */
    public static final String N_STATICEXPORT_NAME = "name";

    /**  The node name of the static export plainoptimization node. */
    public static final String N_STATICEXPORT_PLAINOPTIMIZATION = "plainoptimization";

    /**  The node name of the static export regex node. */
    public static final String N_STATICEXPORT_REGEX = "regex";

    /**  The node name of the static export related-system-res node. */
    public static final String N_STATICEXPORT_RELATED_SYSTEM_RES = "related-system-res";

    /**  The node name of the static export relativelinks node. */
    public static final String N_STATICEXPORT_RELATIVELINKS = "userelativelinks";

    /**  The node name of the static export remoteaddr node. */
    public static final String N_STATICEXPORT_REMOTEADDR = "remoteaddr";

    /**  The node name of the static export rendersettings node. */
    public static final String N_STATICEXPORT_RENDERSETTINGS = "rendersettings";

    /**  The node name of the static export requestheaders node. */
    public static final String N_STATICEXPORT_REQUESTHEADERS = "requestheaders";

    /**  The node name of the static export resourcestorender node. */
    public static final String N_STATICEXPORT_RESOURCESTORENDER = "resourcestorender";

    /**  The node name of the static export rfx-prefix node. */
    public static final String N_STATICEXPORT_RFS_PREFIX = "rfs-prefix";

    /**  The node name of the static export rfx-rule node. */
    public static final String N_STATICEXPORT_RFS_RULE = "rfs-rule";

    /**  The node name of the static export rfx-rules node. */
    public static final String N_STATICEXPORT_RFS_RULES = "rfs-rules";

    /**  The node name of the static export rfx-rule source node. */
    public static final String N_STATICEXPORT_SOURCE = "source";

    /**  The node name of the static export suffix node. */
    public static final String N_STATICEXPORT_SUFFIX = "suffix";

    /**  The node name of the static export testresource node. */
    public static final String N_STATICEXPORT_TESTRESOURCE = "testresource";

    /**  The node name of the static export export-rule export uri node. */
    public static final String N_STATICEXPORT_URI = "uri";

    /**  The node name of the static export vfx-prefix node. */
    public static final String N_STATICEXPORT_VFS_PREFIX = "vfs-prefix";

    /**  The node name of the user csv export node. */
    public static final String N_USERCSVEXPORT = "usercsvexport";

    /** The configured import/export manager. */
    private CmsImportExportManager m_importExportManager;

    /** The configured repository manager. */
    private CmsRepositoryManager m_repositoryManager;

    /** The configured static export manager. */
    private CmsStaticExportManager m_staticExportManager;

    /**
     * Public constructor, will be called by configuration manager.<p> 
     */
    public CmsImportExportConfiguration() {

        setXmlFileName(DEFAULT_XML_FILE_NAME);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_IMPORT_CONFIG_INIT_0));
        }
    }

    /**
     * @see org.opencms.configuration.I_CmsXmlConfiguration#addXmlDigesterRules(org.apache.commons.digester.Digester)
     */
    public void addXmlDigesterRules(Digester digester) {

        // add finish rule
        digester.addCallMethod("*/" + N_IMPORTEXPORT, "initializeFinished");

        // creation of the import/export manager        
        digester.addObjectCreate("*/" + N_IMPORTEXPORT, CmsImportExportManager.class);
        // import/export manager finished
        digester.addSetNext("*/" + N_IMPORTEXPORT, "setImportExportManager");

        // add rules for import/export handlers
        digester.addObjectCreate(
            "*/" + N_IMPORTEXPORT + "/" + N_IMPORTEXPORTHANDLERS + "/" + N_IMPORTEXPORTHANDLER,
            A_CLASS,
            CmsConfigurationException.class);
        digester.addSetNext(
            "*/" + N_IMPORTEXPORT + "/" + N_IMPORTEXPORTHANDLERS + "/" + N_IMPORTEXPORTHANDLER,
            "addImportExportHandler");

        // overwrite rule
        digester.addCallMethod(
            "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_OVERWRITE,
            "setOverwriteCollidingResources",
            0);

        // convert rule
        digester.addCallMethod("*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_CONVERT, "setConvertToXmlPage", 0);

        // old webapp rule
        digester.addCallMethod("*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_OLDWEBAPPURL, "setOldWebAppUrl", 0);

        // add rules for the import versions
        digester.addObjectCreate("*/"
            + N_IMPORTEXPORT
            + "/"
            + N_IMPORT
            + "/"
            + N_IMPORTVERSIONS
            + "/"
            + N_IMPORTVERSION, A_CLASS, CmsConfigurationException.class);
        digester.addSetNext(
            "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMPORTVERSIONS + "/" + N_IMPORTVERSION,
            "addImportVersionClass");

        // add rules for the import immutables
        digester.addCallMethod(
            "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMMUTABLES + "/" + N_RESOURCE,
            "addImmutableResource",
            1);
        digester.addCallParam("*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMMUTABLES + "/" + N_RESOURCE, 0, A_URI);

        // add rules for the import princial translations
        digester.addCallMethod("*/"
            + N_IMPORTEXPORT
            + "/"
            + N_IMPORT
            + "/"
            + N_PRINCIPALTRANSLATIONS
            + "/"
            + N_PRINCIPALTRANSLATION, "addImportPrincipalTranslation", 3);
        digester.addCallParam("*/"
            + N_IMPORTEXPORT
            + "/"
            + N_IMPORT
            + "/"
            + N_PRINCIPALTRANSLATIONS
            + "/"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?