net.grcomputing.opencms.search.lucene
Class SearchParameters

java.lang.Object
  |
  +--net.grcomputing.opencms.search.lucene.SearchParameters
All Implemented Interfaces:
I_XmlConfigConstants

public class SearchParameters
extends java.lang.Object
implements I_XmlConfigConstants

This class retrieves/sets parameters for searching.

Author:
Matt Butcher mbutcher@grcomputing.net
See Also:
http://grcomputing.net

Field Summary
 
Fields inherited from interface net.grcomputing.opencms.search.lucene.I_XmlConfigConstants
ATTR_ENABLED, ATTR_LOCATION, ATTR_NAME, ELE_ANALYZER, ELE_CLASS, ELE_DIRECTORIES, ELE_DIRECTORY, ELE_DOC_FACTORIES, ELE_EXTENSION, ELE_FILE_TYPE, ELE_INDEX_DIR, ELE_JSP_DOC_FACTORY, ELE_MERGE_FACTOR, ELE_PAGE_DOC_FACTORY, ELE_PERM_CHECK, ELE_PLAIN_DOC_FACTORY, ELE_PROJECT, ELE_SECTION, ELE_SUBSEARCH, ELE_XML_TEMPLATE_DOC_FACTORY, LUCENE_SEARCH_ELEMENT
 
Constructor Summary
SearchParameters(CmsObject cmso)
          This method constructs a new SearchParameters by retrieving configuration data from the current system registry.
 
Method Summary
 java.lang.String getAnalyzerName()
          Returns the classname of the appropropriate analyzer.
 java.util.HashMap getDirectories()
          Returns HashMap of (String dirPath, String enabled).
 java.lang.String getIndexPath()
          Returns the path that Lucene should use for creating indexes.
 I_DocumentFactory getJspDocumentFactory()
          returns an instance of a jsp-specific DocumentFactory.
protected  org.w3c.dom.Element getLuceneSearchElement(org.w3c.dom.Element sys)
          Gets the right node from the system element.
 int getMergeFactor()
          returns the mergeFactor for the indexer.
 I_DocumentFactory getPageDocumentFactory()
          returns an instance of a page-specific DocumentFactory.
 I_DocumentFactory getPlainDocumentFactory(CmsFile f)
          Using CmsFile, return the appropriate DocumentFactory.
 java.util.ArrayList getPlainExtensionMappings()
          Get the extension mappings for Plain DocumentFactories.
 java.lang.String getProject()
          Returns the project that the indexer ought to index against.
 I_DocumentFactory getXmlTemplateDocumentFactory()
          returns an instance of an XMLTemplate-specific DocumentFactory.
 boolean isUsingJspDocumentFactory()
          Returns true if the DocumentFactory is enabled for this type.
 boolean isUsingPageDocumentFactory()
          Returns true if the DocumentFactory is enabled for this type.
 boolean isUsingPlainDocumentFactory()
          Returns true if the DocumentFactory is enabled for this type.
 boolean isUsingXmlTemplateDocumentFactory()
          Returns true if the DocumentFactory is enabled for this type.
 boolean needsSecurityCheck()
          Returns true if global viewing permissions should be checked before making the index.
 boolean needsSubsearch()
          Get the value of global subsearching.
protected  void readConfig()
          Reads the config information and stores it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchParameters

public SearchParameters(CmsObject cmso)
                 throws CmsException
This method constructs a new SearchParameters by retrieving configuration data from the current system registry. The registry is usually located somewhere like $TOMCAT/webapps/opencms/WEB-INF/config/registry.xml

Throws:
CmsException - if it can't get the registry or there is no search config present in the registry.
Method Detail

isUsingPageDocumentFactory

public boolean isUsingPageDocumentFactory()
Returns true if the DocumentFactory is enabled for this type.


isUsingPlainDocumentFactory

public boolean isUsingPlainDocumentFactory()
Returns true if the DocumentFactory is enabled for this type.


isUsingJspDocumentFactory

public boolean isUsingJspDocumentFactory()
Returns true if the DocumentFactory is enabled for this type.


isUsingXmlTemplateDocumentFactory

public boolean isUsingXmlTemplateDocumentFactory()
Returns true if the DocumentFactory is enabled for this type.


needsSubsearch

public boolean needsSubsearch()
Get the value of global subsearching. If true, then a subtree search should be run on all directories which do not specify otherwise.


needsSecurityCheck

public boolean needsSecurityCheck()
Returns true if global viewing permissions should be checked before making the index. If true, then file permissions will be checked before indexing.


getMergeFactor

public int getMergeFactor()
returns the mergeFactor for the indexer.


getProject

public java.lang.String getProject()
Returns the project that the indexer ought to index against.

Returns:
project name

getAnalyzerName

public java.lang.String getAnalyzerName()
Returns the classname of the appropropriate analyzer.


getIndexPath

public java.lang.String getIndexPath()
Returns the path that Lucene should use for creating indexes. Path is on real filesystem, not VFS.


getDirectories

public java.util.HashMap getDirectories()
Returns HashMap of (String dirPath, String enabled). The second string should be either true or false, but it may be "" or null as well. It is not checked when it is read in from the filesystem.

Returns:
HashMap of (String path, String enabled)

getPageDocumentFactory

public I_DocumentFactory getPageDocumentFactory()
returns an instance of a page-specific DocumentFactory.

Returns:
DocumentFactory instance or null if disabled.

getJspDocumentFactory

public I_DocumentFactory getJspDocumentFactory()
returns an instance of a jsp-specific DocumentFactory.

Returns:
DocumentFactory instance or null if disabled.

getXmlTemplateDocumentFactory

public I_DocumentFactory getXmlTemplateDocumentFactory()
returns an instance of an XMLTemplate-specific DocumentFactory.

Returns:
DocumentFactory instance or null if disabled.

getPlainDocumentFactory

public I_DocumentFactory getPlainDocumentFactory(CmsFile f)
                                          throws CmsException
Using CmsFile, return the appropriate DocumentFactory. This uses extension mapping to guess the best sort of DocumentFactory for indexing this file.

If the extension is not handled by any ExtensionMaps, then the file ought to be left out of the search index (or you ought to fix your config files/write a new DocumentFactory)

Throws:
CmsException - if it can't get the right class loaded.

getPlainExtensionMappings

public java.util.ArrayList getPlainExtensionMappings()
Get the extension mappings for Plain DocumentFactories. Plain-type documents in OpenCMS represent all kinds of file types, each of which may need a different type of indexer. To work around this, there is a separate method of building Page DocumentFactories.

The ArrayList returned contains ExtensionMapping objects, which map file extensions to the appropriate DocumentFactory. Use these mappings to get the correct DocumentFactory for a plain-type document.

If none of this makes sense to yoou, use the getPlainDocumentFactory method.

See Also:
ExtensionMapping

getLuceneSearchElement

protected org.w3c.dom.Element getLuceneSearchElement(org.w3c.dom.Element sys)
Gets the right node from the system element. Returns null if there is none.


readConfig

protected void readConfig()
                   throws CmsException
Reads the config information and stores it.

CmsException


Copyright © 2003 Matt Butcher of Global Resources for Computing. Reporoduction and modification of this documents are allowed as in accordance with the GPL v2. Refer to COPYING.txt for information on acceptible use