Esri Geoportal Server
1.0

com.esri.gpt.catalog.lucene
Class LuceneIndexAdapter

java.lang.Object
  extended by com.esri.gpt.framework.sql.BaseDao
      extended by com.esri.gpt.catalog.context.CatalogIndexAdapter
          extended by com.esri.gpt.catalog.lucene.LuceneIndexAdapter

public class LuceneIndexAdapter
extends CatalogIndexAdapter

Maintains a Lucene index of approved metadata documents.


Field Summary
static String BATCH_INDEXWRITER_KEY
           
 
Constructor Summary
LuceneIndexAdapter(RequestContext requestContext)
          Constructs with an associated request context.
 
Method Summary
 void closeSearcher(IndexSearcher searcher)
          Closes an index searcher.
protected  void closeWriter(IndexWriter writer)
          Closes an index writer.
 int countDocuments()
          Counts the documents within the index.
 void deleteDocuments(String[] uuids)
          Deletes a collection of documents from the index.
protected  Logger getLogger()
          Gets the logger.
protected  LuceneConfig getLuceneConfig()
          Gets the Lucene configuration.
 Analyzer newAnalyzer()
          Makes an analyzer for catalog documents.
 IndexSearcher newSearcher()
          Makes a searcher for catalog documents.
protected  IndexWriter newWriter()
          Makes a writer for catalog documents.
 Lock obtainBackgroundLock()
          Obtains a write lock intended for background synchronization and optimization processes.
 void publishDocument(String uuid, Timestamp updateDate, Schema schema, String acl)
          Publishes a document to the index based upon a metadata schema.
 void purgeIndex()
          Purges the entire catalog index.
 String[] queryAcls(String uuid)
          Queries the ACL values indexed for a document.
 Timestamp queryModifiedDate(String uuid)
          Queries the system modified date associated with an indexed document.
 void touch()
          Opens and closes a writer.
 
Methods inherited from class com.esri.gpt.catalog.context.CatalogIndexAdapter
deleteDocument, publishDocument
 
Methods inherited from class com.esri.gpt.framework.sql.BaseDao
appendExpression, appendValueFilter, closeResultSet, closeStatement, getApplicationConfiguration, getRequestContext, logExpression, returnConnection, setRequestContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BATCH_INDEXWRITER_KEY

public static final String BATCH_INDEXWRITER_KEY
See Also:
Constant Field Values
Constructor Detail

LuceneIndexAdapter

public LuceneIndexAdapter(RequestContext requestContext)
Constructs with an associated request context.

Parameters:
requestContext - the request context
Method Detail

getLogger

protected Logger getLogger()
Gets the logger.

Overrides:
getLogger in class CatalogIndexAdapter
Returns:
the logger

getLuceneConfig

protected LuceneConfig getLuceneConfig()
Gets the Lucene configuration.

Returns:
the Lucene configuration

closeSearcher

public void closeSearcher(IndexSearcher searcher)
Closes an index searcher.

Parameters:
searcher - the searcher to close.

closeWriter

protected void closeWriter(IndexWriter writer)
Closes an index writer.

Parameters:
writer - the writer to close.

countDocuments

public int countDocuments()
                   throws CatalogIndexException
Counts the documents within the index.

Specified by:
countDocuments in class CatalogIndexAdapter
Throws:
CatalogIndexException - if an exception occurs

deleteDocuments

public void deleteDocuments(String[] uuids)
                     throws CatalogIndexException
Deletes a collection of documents from the index.

Specified by:
deleteDocuments in class CatalogIndexAdapter
Parameters:
uuids - the collection of document UUIDS to delete
Throws:
CatalogIndexException - if an exception occurs

newAnalyzer

public Analyzer newAnalyzer()
Makes an analyzer for catalog documents.
Currently returns a StandardAnalyzer.

Returns:
the analyzer

newSearcher

public IndexSearcher newSearcher()
                          throws CorruptIndexException,
                                 IOException
Makes a searcher for catalog documents.

The searcher is created from the value returned by getCatalogIndexPath().

Returns:
the writer
Throws:
CorruptIndexException - if the index is corrupt
IOException - if the directory cannot be read/written to, or if it does not exist and create is false or if there is any other low-level IO error

newWriter

protected IndexWriter newWriter()
                         throws CorruptIndexException,
                                LockObtainFailedException,
                                IOException
Makes a writer for catalog documents.

The writer is created from the values returned by getCatalogIndexPath() and newCatalogAnalyzer().
The index will be creating it if it does not already exist.
The writer must be closed after use.

Returns:
the writer
Throws:
CorruptIndexException - if the index is corrupt
LockObtainFailedException - if another writer has this index open (write.lock could not be obtained)
IOException - if the directory cannot be read/written to, or if it does not exist and create is false or if there is any other low-level IO error

obtainBackgroundLock

public Lock obtainBackgroundLock()
                          throws LockObtainFailedException
Obtains a write lock intended for background synchronization and optimization processes.
There will be no wait time for this type of lock, if not obtained immediately an exception will be thrown.
It is recommended to use LuceneIndexAdapter.touck() prior to obtaining the background lock to ensure a proper directory structure.
The lock must be closed when the background process is complete.

Returns:
the obtained lock
Throws:
LockObtainFailedException - if the lock wwas not obtained

publishDocument

public void publishDocument(String uuid,
                            Timestamp updateDate,
                            Schema schema,
                            String acl)
                     throws CatalogIndexException
Description copied from class: CatalogIndexAdapter
Publishes a document to the index based upon a metadata schema.
The document will not be written if the UUID is null or zero-length.
Existing documents that match the supplied UUID will be replaced.

Specified by:
publishDocument in class CatalogIndexAdapter
Parameters:
uuid - the document's UUID
updateDate - the document's update date
schema - the evaluated schema associated with the document to be indexed
acl - an XML string represent the access control information associated the document (if null, no ACL information is indexed)
Throws:
CatalogIndexException - if an exception occurs

purgeIndex

public void purgeIndex()
                throws CatalogIndexException
Purges the entire catalog index.

Specified by:
purgeIndex in class CatalogIndexAdapter
Throws:
CatalogIndexException - if an exception occurs

queryAcls

public String[] queryAcls(String uuid)
                   throws CatalogIndexException
Queries the ACL values indexed for a document.

Specified by:
queryAcls in class CatalogIndexAdapter
Parameters:
uuid - the document UUID
Returns:
the ACL values (can be null)
Throws:
CatalogIndexException - if an exception occurs

queryModifiedDate

public Timestamp queryModifiedDate(String uuid)
                            throws CatalogIndexException
Queries the system modified date associated with an indexed document.

Specified by:
queryModifiedDate in class CatalogIndexAdapter
Parameters:
uuid - the document UUID
Returns:
the update date (null if none was found)
Throws:
CatalogIndexException - if an exception occurs

touch

public void touch()
           throws CatalogIndexException
Opens and closes a writer.
This ensures that a directory folder structure exists.

Throws:
CatalogIndexException - if an exception occurs

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.