com.ecyrd.jspwiki.search
Class SearchManager

java.lang.Object
  extended by com.ecyrd.jspwiki.filters.BasicPageFilter
      extended by com.ecyrd.jspwiki.search.SearchManager
All Implemented Interfaces:
WikiEventListener, PageFilter, InternalModule, EventListener

public class SearchManager
extends BasicPageFilter
implements InternalModule, WikiEventListener

Manages searching the Wiki.

Since:
2.2.21.
Author:
Arent-Jan Banck

Nested Class Summary
 class SearchManager.JSONSearch
          Provides a JSON RPC API to the JSPWiki Search Engine.
 
Field Summary
static String JSON_SEARCH
          The name of the JSON object that manages search.
static String PROP_SEARCHPROVIDER
          Property name for setting the search provider.
 
Fields inherited from class com.ecyrd.jspwiki.filters.BasicPageFilter
m_engine
 
Constructor Summary
SearchManager(WikiEngine engine, Properties properties)
          Creates a new SearchManager.
 
Method Summary
 void actionPerformed(WikiEvent event)
          If the page has been deleted, removes it from the index.
 Collection findPages(String query)
          Sends a search to the current search provider.
 SearchProvider getSearchEngine()
          Returns the SearchProvider used.
 void initialize(WikiEngine engine, Properties properties)
          This particular method starts off indexing and all sorts of various activities, so you need to run this last, after things are done.
 void pageRemoved(WikiPage page)
          Removes the page from the search cache (if any).
 void postSave(WikiContext wikiContext, String content)
          Reindexes the page.
 void reindexPage(WikiPage page)
          Forces the reindex of the given page.
 
Methods inherited from class com.ecyrd.jspwiki.filters.BasicPageFilter
destroy, postTranslate, preSave, preTranslate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_SEARCHPROVIDER

public static final String PROP_SEARCHPROVIDER
Property name for setting the search provider. Value is "jspwiki.searchProvider".

See Also:
Constant Field Values

JSON_SEARCH

public static final String JSON_SEARCH
The name of the JSON object that manages search.

See Also:
Constant Field Values
Constructor Detail

SearchManager

public SearchManager(WikiEngine engine,
                     Properties properties)
              throws WikiException
Creates a new SearchManager.

Parameters:
engine - The WikiEngine that owns this SearchManager.
properties - The list of Properties.
Throws:
WikiException - If it cannot be instantiated.
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties properties)
                throws FilterException
This particular method starts off indexing and all sorts of various activities, so you need to run this last, after things are done.

Specified by:
initialize in interface PageFilter
Overrides:
initialize in class BasicPageFilter
Parameters:
engine - the wiki engine
properties - the properties used to initialize the wiki engine
Throws:
FilterException - if the search provider failed to initialize

getSearchEngine

public SearchProvider getSearchEngine()
Returns the SearchProvider used.

Returns:
The current SearchProvider.

findPages

public Collection findPages(String query)
                     throws ProviderException,
                            IOException
Sends a search to the current search provider. The query is is whatever native format the query engine wants to use.

Parameters:
query - The query. Null is safe, and is interpreted as an empty query.
Returns:
A collection of WikiPages that matched.
Throws:
ProviderException - If the provider fails and a search cannot be completed.
IOException - If something else goes wrong.

pageRemoved

public void pageRemoved(WikiPage page)
Removes the page from the search cache (if any).

Parameters:
page - The page to remove

postSave

public void postSave(WikiContext wikiContext,
                     String content)
Reindexes the page.

Specified by:
postSave in interface PageFilter
Overrides:
postSave in class BasicPageFilter
Parameters:
wikiContext - The WikiContext
content - The content which was just stored.

reindexPage

public void reindexPage(WikiPage page)
Forces the reindex of the given page.

Parameters:
page - The page.

actionPerformed

public void actionPerformed(WikiEvent event)
If the page has been deleted, removes it from the index.

Specified by:
actionPerformed in interface WikiEventListener
Parameters:
event - a WikiEvent object