public class CachingProvider extends Object implements WikiPageProvider
This class does not detect if someone has modified the page externally, not through JSPWiki routines.
Heavily based on ideas by Chris Brooking.
Since 2.10 uses the Ehcache library.
Modifier and Type | Field and Description |
---|---|
static String |
CACHE_NAME
Name of the regular page cache.
|
static int |
DEFAULT_CACHECAPACITY |
static int |
DEFAULT_CACHETIMETOIDLESECONDS |
static int |
DEFAULT_CACHETIMETOLIVESECONDS |
static String |
HISTORYCACHE_NAME
Name of the page history cache.
|
static String |
TEXTCACHE_NAME
Name of the page text cache.
|
LATEST_VERSION
Constructor and Description |
---|
CachingProvider() |
Modifier and Type | Method and Description |
---|---|
void |
deletePage(String pageName)
Removes an entire page from the repository.
|
void |
deleteVersion(String pageName,
int version)
Removes a specific version from the repository.
|
Collection<SearchResult> |
findPages(QueryItem[] query)
Finds pages based on the query.
|
Collection<WikiPage> |
getAllChangedSince(Date date)
Gets a list of recent changes.
|
Collection<WikiPage> |
getAllPages()
Returns all pages.
|
int |
getPageCount()
Gets the number of pages.
|
WikiPage |
getPageInfo(String pageName,
int version)
Returns info about the page.
|
String |
getPageText(String pageName,
int version)
Gets a specific version out of the repository.
|
String |
getProviderInfo()
Gets the provider class name, and cache statistics (misscount and hitcount of page cache and history cache).
|
WikiPageProvider |
getRealProvider()
Returns the actual used provider.
|
List<WikiPage> |
getVersionHistory(String pageName)
Returns version history.
|
void |
initialize(WikiEngine engine,
Properties properties)
Initializes the page provider.
|
void |
movePage(String from,
String to)
Move a page
|
boolean |
pageExists(String pageName)
Return true, if page exists.
|
boolean |
pageExists(String pageName,
int version)
Return true, if page with a particular version exists.
|
void |
putPageText(WikiPage page,
String text)
Attempts to save the page text for page "page".
|
public static final String CACHE_NAME
public static final String TEXTCACHE_NAME
public static final String HISTORYCACHE_NAME
public static final int DEFAULT_CACHECAPACITY
public static final int DEFAULT_CACHETIMETOLIVESECONDS
public static final int DEFAULT_CACHETIMETOIDLESECONDS
public CachingProvider()
public void initialize(WikiEngine engine, Properties properties) throws NoRequiredPropertyException, IOException
initialize
in interface WikiProvider
engine
- WikiEngine to own this providerproperties
- A set of properties used to initialize this providerNoRequiredPropertyException
- If the provider needs a property which is not found in the property setIOException
- If there is an IO problempublic boolean pageExists(String pageName, int version)
pageExists
in interface WikiPageProvider
pageName
- The page name to check forversion
- The version to checkpublic boolean pageExists(String pageName)
pageExists
in interface WikiPageProvider
pageName
- The page name.public String getPageText(String pageName, int version) throws ProviderException
getPageText
in interface WikiPageProvider
pageName
- Name of the page to fetch.version
- Version of the page to fetch.ProviderException
- If something goes wrong.public void putPageText(WikiPage page, String text) throws ProviderException
putPageText
in interface WikiPageProvider
page
- The WikiPage to savetext
- The text to save.ProviderException
- If something goes wrong.public Collection<WikiPage> getAllPages() throws ProviderException
getAllPages
in interface WikiPageProvider
ProviderException
- If something goes wrong.public Collection<WikiPage> getAllChangedSince(Date date)
getAllChangedSince
in interface WikiPageProvider
date
- The date to check frompublic int getPageCount() throws ProviderException
getPageCount
in interface WikiPageProvider
ProviderException
- If something goes wrongpublic Collection<SearchResult> findPages(QueryItem[] query)
This method should really be a part of the FastSearch IF.
findPages
in interface WikiPageProvider
query
- An array of QueryItems to matchpublic WikiPage getPageInfo(String pageName, int version) throws ProviderException
getPageInfo
in interface WikiPageProvider
pageName
- The page nameversion
- The version numberProviderException
- If something goes wrong.public List<WikiPage> getVersionHistory(String pageName) throws ProviderException
getVersionHistory
in interface WikiPageProvider
pageName
- The name of the page to get the history from.ProviderException
- If something goes wrong.public String getProviderInfo()
getProviderInfo
in interface WikiProvider
public void deleteVersion(String pageName, int version) throws ProviderException
deleteVersion
in interface WikiPageProvider
pageName
- Name of the page to be removed.version
- Version of the page to be removed. May be LATEST_VERSION.ProviderException
- If the page cannot be removed for some reason.public void deletePage(String pageName) throws ProviderException
The reason why this is named differently from deleteVersion() (logically, this method should be an overloaded version) is that I want to be absolutely sure I don't accidentally use the wrong method. With overloading something like that happens sometimes...
deletePage
in interface WikiPageProvider
pageName
- Name of the page to be removed completely.ProviderException
- If the page could not be removed for some reason.public void movePage(String from, String to) throws ProviderException
movePage
in interface WikiPageProvider
from
- Name of the page to move.to
- New name of the page.ProviderException
- If the page could not be moved for some reason.public WikiPageProvider getRealProvider()
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.