📄 cmssearchconfiguration.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/configuration/CmsSearchConfiguration.java,v $
* Date : $Date: 2006/03/27 14:52:46 $
* Version: $Revision: 1.17 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 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.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.search.CmsSearchAnalyzer;
import org.opencms.search.CmsSearchDocumentType;
import org.opencms.search.CmsSearchIndex;
import org.opencms.search.CmsSearchIndexSource;
import org.opencms.search.CmsSearchManager;
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;
/**
* Lucene search configuration class.<p>
*
* @author Thomas Weckert
*
* @version $Revision: 1.17 $
*
* @since 6.0.0
*/
public class CmsSearchConfiguration extends A_CmsXmlConfiguration implements I_CmsXmlConfiguration {
/** The name of the DTD for this configuration. */
public static final String CONFIGURATION_DTD_NAME = "opencms-search.dtd";
/** The name of the default XML file for this configuration. */
public static final String DEFAULT_XML_FILE_NAME = "opencms-search.xml";
/** Node name constant. */
public static final String N_ANALYZER = "analyzer";
/** Node name constant. */
public static final String N_ANALYZERS = "analyzers";
/** Node name constant. */
public static final String N_CACHE = "cache";
/** Node name constant. */
public static final String N_CLASS = "class";
/** Node name constant. */
public static final String N_DIRECTORY = "directory";
/** Node name constant. */
public static final String N_DOCUMENTTYPE = "documenttype";
/** Node name constant. */
public static final String N_DOCUMENTTYPES = "documenttypes";
/** Node name constant. */
public static final String N_DOCUMENTTYPES_INDEXED = "documenttypes-indexed";
/** Node name constant. */
public static final String N_EXCERPT = "excerpt";
/** Node name constant. */
public static final String N_HIGHLIGHTER = "highlighter";
/** Node name constant. */
public static final String N_INDEX = "index";
/** Node name constant. */
public static final String N_INDEXER = "indexer";
/** Node name constant. */
public static final String N_INDEXES = "indexes";
/** Node name constant. */
public static final String N_INDEXSOURCE = "indexsource";
/** Node name constant. */
public static final String N_INDEXSOURCES = "indexsources";
/** Node name constant. */
public static final String N_LOCALE = "locale";
/** Node name constant. */
public static final String N_MIMETYPE = "mimetype";
/** Node name constant. */
public static final String N_MIMETYPES = "mimetypes";
/** Node name constant. */
public static final String N_PROJECT = "project";
/** Node name constant. */
public static final String N_REBUILD = "rebuild";
/** Node name constant. */
public static final String N_RESOURCES = "resources";
/** Node name constant. */
public static final String N_RESOURCETYPE = "resourcetype";
/** Node name constant. */
public static final String N_RESOURCETYPES = "resourcetypes";
/** Node name constant. */
public static final String N_SEARCH = "search";
/** Node name constant. */
public static final String N_SOURCE = "source";
/** Node name constant. */
public static final String N_SOURCES = "sources";
/** Node name constant. */
public static final String N_STEMMER = "stemmer";
/** Node name constant. */
public static final String N_TIMEOUT = "timeout";
/** Node name constant. */
private static final String XPATH_SEARCH = "*/" + N_SEARCH;
/** The configured search manager. */
private CmsSearchManager m_searchManager;
/**
* Public constructor, will be called by configuration manager.<p>
*/
public CmsSearchConfiguration() {
setXmlFileName(DEFAULT_XML_FILE_NAME);
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SEARCH_CONFIG_INIT_0));
}
}
/**
* @see org.opencms.configuration.I_CmsXmlConfiguration#addXmlDigesterRules(org.apache.commons.digester.Digester)
*/
public void addXmlDigesterRules(Digester digester) {
String xPath = null;
// add finish rule
digester.addCallMethod(XPATH_SEARCH, "initializeFinished");
// creation of the search manager
digester.addObjectCreate(XPATH_SEARCH, CmsSearchManager.class);
// search manager finished
digester.addSetNext(XPATH_SEARCH, "setSearchManager");
// result cache size rule
digester.addCallMethod(XPATH_SEARCH + "/" + N_CACHE, "setResultCacheSize", 0);
// directory rule
digester.addCallMethod(XPATH_SEARCH + "/" + N_DIRECTORY, "setDirectory", 0);
// timeout rule
digester.addCallMethod(XPATH_SEARCH + "/" + N_TIMEOUT, "setTimeout", 0);
// rule for the max. char. lenght of the search result excerpt
digester.addCallMethod(XPATH_SEARCH + "/" + N_EXCERPT, "setMaxExcerptLength", 0);
// rule for the highlighter to highlight the search terms in the excerpt of the search result
digester.addCallMethod(XPATH_SEARCH + "/" + N_HIGHLIGHTER, "setHighlighter", 0);
// document type rule
xPath = XPATH_SEARCH + "/" + N_DOCUMENTTYPES + "/" + N_DOCUMENTTYPE;
digester.addObjectCreate(xPath, CmsSearchDocumentType.class);
digester.addCallMethod(xPath + "/" + N_NAME, "setName", 0);
digester.addCallMethod(xPath + "/" + N_CLASS, "setClassName", 0);
digester.addCallMethod(xPath + "/" + N_MIMETYPES + "/" + N_MIMETYPE, "addMimeType", 0);
digester.addCallMethod(xPath + "/" + N_RESOURCETYPES + "/" + N_RESOURCETYPE, "addResourceType", 0);
digester.addSetNext(xPath, "addDocumentTypeConfig");
// analyzer rule
xPath = XPATH_SEARCH + "/" + N_ANALYZERS + "/" + N_ANALYZER;
digester.addObjectCreate(xPath, CmsSearchAnalyzer.class);
digester.addCallMethod(xPath + "/" + N_CLASS, "setClassName", 0);
digester.addCallMethod(xPath + "/" + N_STEMMER, "setStemmerAlgorithm", 0);
digester.addCallMethod(xPath + "/" + N_LOCALE, "setLocale", 0);
digester.addSetNext(xPath, "addAnalyzer");
// search index rule
xPath = XPATH_SEARCH + "/" + N_INDEXES + "/" + N_INDEX;
digester.addObjectCreate(xPath, CmsSearchIndex.class);
digester.addCallMethod(xPath + "/" + N_NAME, "setName", 0);
digester.addCallMethod(xPath + "/" + N_REBUILD, "setRebuildMode", 0);
digester.addCallMethod(xPath + "/" + N_PROJECT, "setProjectName", 0);
digester.addCallMethod(xPath + "/" + N_LOCALE, "setLocale", 0);
digester.addCallMethod(xPath + "/" + N_SOURCES + "/" + N_SOURCE, "addSourceName", 0);
digester.addSetNext(xPath, "addSearchIndex");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -