org.opencms.search
Class CmsVfsIndexer

java.lang.Object
  extended byorg.opencms.search.CmsVfsIndexer
All Implemented Interfaces:
I_CmsIndexer

public class CmsVfsIndexer
extends java.lang.Object
implements I_CmsIndexer

Implementation for an indexer indexing VFS Cms resources.

Since:
6.0.0
Version:
$Revision: 1.34 $
Author:
Carsten Weinholz, Thomas Weckert

Constructor Summary
CmsVfsIndexer()
           
 
Method Summary
 void deleteResources(org.apache.lucene.index.IndexReader reader, java.util.List resourcesToDelete)
          Incremental index update - delete the index entry for all resources in the given list.
 A_CmsIndexResource getIndexResource(CmsObject cms, org.apache.lucene.document.Document doc)
          Returns an index resource for a specified Lucene search result document.
 CmsSearchIndexUpdateData getUpdateData(CmsSearchIndexSource source, java.util.List publishedResources)
          Calculates the data for an incremental search index update.
protected  boolean isResourceInTimeWindow(CmsPublishedResource resource)
          Checks if the published resource is inside the time window set with release and expiration date.
 I_CmsIndexer newInstance(CmsObject cms, I_CmsReport report, CmsSearchIndex index)
          Creates and initializes a new instance of this indexer implementation.
 void rebuildIndex(org.apache.lucene.index.IndexWriter writer, CmsIndexingThreadManager threadManager, CmsSearchIndexSource source)
          Rebuilds the index for the given configured index source.
protected  void updateResource(org.apache.lucene.index.IndexWriter writer, CmsIndexingThreadManager threadManager, CmsResource resource)
          Updates (writes) a single resource in the index.
 void updateResources(org.apache.lucene.index.IndexWriter writer, CmsIndexingThreadManager threadManager, java.util.List resourcesToUpdate)
          Incremental index update - create a new index entry for all resources in the given list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsVfsIndexer

public CmsVfsIndexer()
Method Detail

deleteResources

public void deleteResources(org.apache.lucene.index.IndexReader reader,
                            java.util.List resourcesToDelete)
Description copied from interface: I_CmsIndexer
Incremental index update - delete the index entry for all resources in the given list.

Specified by:
deleteResources in interface I_CmsIndexer
Parameters:
reader - the index reader to delete the entries from
resourcesToDelete - a list of CmsPublishedResource instances that must be deleted
See Also:
I_CmsIndexer.deleteResources(org.apache.lucene.index.IndexReader, java.util.List)

getIndexResource

public A_CmsIndexResource getIndexResource(CmsObject cms,
                                           org.apache.lucene.document.Document doc)
                                    throws CmsException
Description copied from interface: I_CmsIndexer
Returns an index resource for a specified Lucene search result document.

Implementations of this method have to check if the current user has read permissions on the Cms resource represented by the Lucene document.

If this check fails, the implementation must return null as a result.

Specified by:
getIndexResource in interface I_CmsIndexer
Parameters:
cms - the OpenCms context to use when reading resources from the VFS
doc - the Lucene search result document
Returns:
a new index resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsIndexer.getIndexResource(org.opencms.file.CmsObject, org.apache.lucene.document.Document)

getUpdateData

public CmsSearchIndexUpdateData getUpdateData(CmsSearchIndexSource source,
                                              java.util.List publishedResources)
Description copied from interface: I_CmsIndexer
Calculates the data for an incremental search index update.

Specified by:
getUpdateData in interface I_CmsIndexer
Parameters:
source - the search index source to update
publishedResources - a list of CmsPublishedResource objects that are to be updated
Returns:
a container with the information about the resources to delete and / or update
See Also:
I_CmsIndexer.getUpdateData(org.opencms.search.CmsSearchIndexSource, java.util.List)

newInstance

public I_CmsIndexer newInstance(CmsObject cms,
                                I_CmsReport report,
                                CmsSearchIndex index)
Description copied from interface: I_CmsIndexer
Creates and initializes a new instance of this indexer implementation.

Specified by:
newInstance in interface I_CmsIndexer
Parameters:
cms - the OpenCms user context to use when reading resources from the VFS during indexing
report - the report to write the indexing output to
index - the search index to update
Returns:
a new instance of this indexer implementation
See Also:
I_CmsIndexer.newInstance(org.opencms.file.CmsObject, org.opencms.report.I_CmsReport, org.opencms.search.CmsSearchIndex)

rebuildIndex

public void rebuildIndex(org.apache.lucene.index.IndexWriter writer,
                         CmsIndexingThreadManager threadManager,
                         CmsSearchIndexSource source)
                  throws CmsIndexException
Description copied from interface: I_CmsIndexer
Rebuilds the index for the given configured index source.

This is used when the index is fully rebuild, not for updating only some parts of an existing index.

Specified by:
rebuildIndex in interface I_CmsIndexer
Parameters:
writer - the index writer to write the update to
source - the search index source to update
threadManager - the thread manager to use when extracting the document text
Throws:
CmsIndexException - if something goes wrong
See Also:
I_CmsIndexer.rebuildIndex(org.apache.lucene.index.IndexWriter, org.opencms.search.CmsIndexingThreadManager, org.opencms.search.CmsSearchIndexSource)

updateResources

public void updateResources(org.apache.lucene.index.IndexWriter writer,
                            CmsIndexingThreadManager threadManager,
                            java.util.List resourcesToUpdate)
                     throws CmsIndexException
Description copied from interface: I_CmsIndexer
Incremental index update - create a new index entry for all resources in the given list.

Specified by:
updateResources in interface I_CmsIndexer
Parameters:
writer - the index writer to write the update to
resourcesToUpdate - a list of CmsPublishedResource instances that must be updated
threadManager - the thread manager to use when extracting the document text
Throws:
CmsIndexException - if something goes wrong
See Also:
I_CmsIndexer.updateResources(org.apache.lucene.index.IndexWriter, org.opencms.search.CmsIndexingThreadManager, java.util.List)

isResourceInTimeWindow

protected boolean isResourceInTimeWindow(CmsPublishedResource resource)
Checks if the published resource is inside the time window set with release and expiration date.

Parameters:
resource - the published resource to check
Returns:
true if the published resource is inside the time window, otherwise false

updateResource

protected void updateResource(org.apache.lucene.index.IndexWriter writer,
                              CmsIndexingThreadManager threadManager,
                              CmsResource resource)
                       throws CmsIndexException
Updates (writes) a single resource in the index.

Parameters:
writer - the index writer to use
threadManager - the thread manager to use when extracting the document text
resource - the resource to update
Throws:
CmsIndexException - if something goes wrong