cmsvfsconfiguration.java

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

JAVA
831
字号
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/configuration/CmsVfsConfiguration.java,v $
 * Date   : $Date: 2007-08-13 16:30:10 $
 * Version: $Revision: 1.43 $
 *
 * 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.file.CmsProperty;
import org.opencms.file.collectors.I_CmsResourceCollector;
import org.opencms.file.types.I_CmsResourceType;
import org.opencms.loader.CmsMimeType;
import org.opencms.loader.CmsResourceManager;
import org.opencms.loader.I_CmsResourceLoader;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.relations.CmsRelationType;
import org.opencms.util.CmsResourceTranslator;
import org.opencms.widgets.I_CmsWidget;
import org.opencms.xml.CmsXmlContentTypeManager;
import org.opencms.xml.types.I_CmsXmlSchemaType;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.digester.Digester;

import org.dom4j.Element;

/**
 * VFS master configuration class.<p>
 * 
 * @author Alexander Kandzior 
 * 
 * @version $Revision: 1.43 $
 * 
 * @since 6.0.0
 */
public class CmsVfsConfiguration extends A_CmsXmlConfiguration implements I_CmsXmlConfiguration {

    /** The widget attribute. */
    public static final String A_DEFAULTWIDGET = "defaultwidget";

    /** The extension attribute name. */
    public static final String A_EXTENSION = "extension";

    /** The source attribute name. */
    public static final String A_SOURCE = "source";

    /** The target attribute name. */
    public static final String A_TARGET = "target";

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

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

    /** The collector node name. */
    public static final String N_COLLECTOR = "collector";

    /** The collectors node name. */
    public static final String N_COLLECTORS = "collectors";

    /** The copy-resource node name.*/
    public static final String N_COPY_RESOURCE = "copy-resource";

    /** The copy-resources node name.*/
    public static final String N_COPY_RESOURCES = "copy-resources";

    /** The defaultfile node name. */
    public static final String N_DEFAULTFILE = "defaultfile";

    /** The defaultfiles node name. */
    public static final String N_DEFAULTFILES = "defaultfiles";

    /** File translations node name. */
    public static final String N_FILETRANSLATIONS = "filetranslations";

    /** Folder translations node name. */
    public static final String N_FOLDERTRANSLATIONS = "foldertranslations";

    /** The node name of an individual resource loader. */
    public static final String N_LOADER = "loader";

    /** The mapping node name. */
    public static final String N_MAPPING = "mapping";

    /** The mappings node name. */
    public static final String N_MAPPINGS = "mappings";

    /** The mimetype node name. */
    public static final String N_MIMETYPE = "mimetype";

    /** The mimetypes node name. */
    public static final String N_MIMETYPES = "mimetypes";

    /** The properties node name. */
    public static final String N_PROPERTIES = "properties";

    /** The relation type node name. */
    public static final String N_RELATIONTYPE = "relationtype";

    /** The relation types node name. */
    public static final String N_RELATIONTYPES = "relationtypes";

    /** The resource loaders node name. */
    public static final String N_RESOURCELOADERS = "resourceloaders";

    /** The main resource node name. */
    public static final String N_RESOURCES = "resources";

    /** The resource types node name. */
    public static final String N_RESOURCETYPES = "resourcetypes";

    /** The schematype node name. */
    public static final String N_SCHEMATYPE = "schematype";

    /** The schematypes node name. */
    public static final String N_SCHEMATYPES = "schematypes";

    /** Individual translation node name. */
    public static final String N_TRANSLATION = "translation";

    /** The translations master node name. */
    public static final String N_TRANSLATIONS = "translations";

    /** The node name of an individual resource type. */
    public static final String N_TYPE = "type";

    /** The node name for the version history. */
    public static final String N_VERSIONHISTORY = "versionhistory";

    /** The main vfs configuration node name. */
    public static final String N_VFS = "vfs";

    /** The widget node name. */
    public static final String N_WIDGET = "widget";

    /** The widgets node name. */
    public static final String N_WIDGETS = "widgets";

    /** The xmlcontent node name. */
    public static final String N_XMLCONTENT = "xmlcontent";

    /** The xmlcontents node name. */
    public static final String N_XMLCONTENTS = "xmlcontents";

    /** The configured XML content type manager. */
    CmsXmlContentTypeManager m_xmlContentTypeManager;

    /** The list of configured default files. */
    private List m_defaultFiles;

    /** Controls if file translation is enabled. */
    private boolean m_fileTranslationEnabled;

    /** The list of file translations. */
    private List m_fileTranslations;

    /** Controls if folder translation is enabled. */
    private boolean m_folderTranslationEnabled;

    /** The list of folder translations. */
    private List m_folderTranslations;

    /** The configured resource manager. */
    private CmsResourceManager m_resourceManager;

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

        setXmlFileName(DEFAULT_XML_FILE_NAME);
        m_fileTranslations = new ArrayList();
        m_folderTranslations = new ArrayList();
        m_defaultFiles = new ArrayList();
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_VFS_CONFIG_INIT_0));
        }
    }

    /**
     * Adds the resource type rules to the given digester.<p>
     * 
     * @param digester the digester to add the rules to
     */
    public static void addResourceTypeXmlRules(Digester digester) {

        // add rules for resource types
        digester.addFactoryCreate("*/" + N_RESOURCETYPES + "/" + N_TYPE, CmsDigesterResourceTypeCreationFactory.class);
        digester.addSetNext("*/" + N_RESOURCETYPES + "/" + N_TYPE, I_CmsResourceType.ADD_RESOURCE_TYPE_METHOD);

        // please note: the order of the rules is very important here,
        // the "set next" rule (above) must be added _before_ the "call method" rule (below)!
        // reason is digester will call the rule that was last added first
        // here we must make sure that the resource type is initialized first (with the "call method" rule)
        // before it is actually added to the resource type container (with the "set next" rule)
        // otherwise there will be an empty resource type added to the container, and validation will not work
        digester.addCallMethod(
            "*/" + N_RESOURCETYPES + "/" + N_TYPE,
            I_CmsConfigurationParameterHandler.INIT_CONFIGURATION_METHOD,
            3);
        // please note: the resource types use a special version of the init method with 3 parameters 
        digester.addCallParam("*/" + N_RESOURCETYPES + "/" + N_TYPE, 0, A_NAME);
        digester.addCallParam("*/" + N_RESOURCETYPES + "/" + N_TYPE, 1, A_ID);
        digester.addCallParam("*/" + N_RESOURCETYPES + "/" + N_TYPE, 2, A_CLASS);

        // add rules for default properties
        digester.addObjectCreate(
            "*/" + N_RESOURCETYPES + "/" + N_TYPE + "/" + N_PROPERTIES + "/" + N_PROPERTY,
            CmsProperty.class);
        digester.addCallMethod("*/"
            + N_RESOURCETYPES
            + "/"
            + N_TYPE
            + "/"
            + N_PROPERTIES
            + "/"
            + N_PROPERTY
            + "/"
            + N_NAME, "setName", 1);
        digester.addCallParam("*/"
            + N_RESOURCETYPES
            + "/"
            + N_TYPE
            + "/"
            + N_PROPERTIES
            + "/"
            + N_PROPERTY
            + "/"
            + N_NAME, 0);

        digester.addCallMethod("*/"
            + N_RESOURCETYPES
            + "/"
            + N_TYPE
            + "/"
            + N_PROPERTIES
            + "/"
            + N_PROPERTY
            + "/"
            + N_VALUE, "setValue", 2);
        digester.addCallParam("*/"
            + N_RESOURCETYPES
            + "/"
            + N_TYPE
            + "/"

⌨️ 快捷键说明

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