public abstract class AbstractFileProvider extends java.lang.Object implements PageProvider
All files have ".txt" appended to make life easier for those who insist on using Windows or other software which makes assumptions on the files contents based on its name.
This class functions as a superclass to all file based providers.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractFileProvider.WikiFileFilter
A simple filter which filters only those filenames which correspond to the
file extension used.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_ENCODING
The default encoding.
|
static int |
DEFAULT_MAX_PROPKEYLENGTH |
static int |
DEFAULT_MAX_PROPLIMIT |
static int |
DEFAULT_MAX_PROPVALUELENGTH |
static java.lang.String |
FILE_EXT
All files should have this extension to be recognized as JSPWiki files.
|
protected java.lang.String |
m_encoding |
protected Engine |
m_engine |
static int |
MAX_PROPKEYLENGTH
This number limits the length of a custom page property key length.
|
static int |
MAX_PROPLIMIT
This parameter limits the number of custom page properties allowed on a page
|
static int |
MAX_PROPVALUELENGTH
This number limits the length of a custom page property value length.
|
static java.lang.String |
PROP_CUSTOMPROP_MAXKEYLENGTH |
static java.lang.String |
PROP_CUSTOMPROP_MAXLIMIT |
static java.lang.String |
PROP_CUSTOMPROP_MAXVALUELENGTH |
static java.lang.String |
PROP_PAGEDIR
Name of the property that defines where page directories are.
|
LATEST_VERSION| Constructor and Description |
|---|
AbstractFileProvider() |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Properties |
addCustomProperties(Page page,
java.util.Properties props)
By default all page attributes that start with "@" are returned as custom properties.
|
void |
deletePage(java.lang.String pageName) |
void |
deleteVersion(java.lang.String pageName,
int version) |
protected java.io.File |
findPage(java.lang.String page)
Finds a Wiki page from the page repository.
|
java.util.Collection<SearchResult> |
findPages(QueryItem[] query)
Iterates through all WikiPages, matches them against the given query, and returns a Collection of SearchResult objects.
|
java.util.Collection<Page> |
getAllChangedSince(java.util.Date date)
Does not work.
|
java.util.Collection<Page> |
getAllPages() |
protected void |
getCustomProperties(Page page,
java.util.Properties defaultProperties)
Get custom properties using
addCustomProperties(Page, Properties), validate them using validateCustomPageProperties(Properties)
and add them to default properties provided |
int |
getPageCount() |
Page |
getPageInfo(java.lang.String page,
int version)
Always returns the latest version, since FileSystemProvider
does not support versioning.
|
java.lang.String |
getPageText(java.lang.String page,
int version)
This implementation just returns the current version, as filesystem does not provide versioning information for now.
|
java.lang.String |
getProviderInfo() |
java.util.List<Page> |
getVersionHistory(java.lang.String page)
The FileSystemProvider provides only one version.
|
void |
initialize(Engine engine,
java.util.Properties properties) |
protected java.lang.String |
mangleName(java.lang.String pagename)
This makes sure that the queried page name is still readable by the file system.
|
boolean |
pageExists(java.lang.String page) |
boolean |
pageExists(java.lang.String page,
int version) |
void |
putPageText(Page page,
java.lang.String text) |
protected void |
setCustomProperties(Page page,
java.util.Properties properties)
Set the custom properties provided into the given page.
|
protected java.lang.String |
unmangleName(java.lang.String filename)
This makes the reverse of mangleName.
|
protected void |
validateCustomPageProperties(java.util.Properties customProperties)
Default validation, validates that key and value is ASCII
StringUtils.isAsciiPrintable() and within lengths set up in jspwiki-custom.properties. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmovePageprotected java.lang.String m_encoding
public static final java.lang.String PROP_CUSTOMPROP_MAXLIMIT
public static final java.lang.String PROP_CUSTOMPROP_MAXKEYLENGTH
public static final java.lang.String PROP_CUSTOMPROP_MAXVALUELENGTH
public static final int DEFAULT_MAX_PROPLIMIT
public static final int DEFAULT_MAX_PROPKEYLENGTH
public static final int DEFAULT_MAX_PROPVALUELENGTH
public static int MAX_PROPLIMIT
public static int MAX_PROPKEYLENGTH
public static int MAX_PROPVALUELENGTH
public static final java.lang.String PROP_PAGEDIR
public static final java.lang.String FILE_EXT
public static final java.lang.String DEFAULT_ENCODING
public AbstractFileProvider()
public void initialize(Engine engine, java.util.Properties properties) throws NoRequiredPropertyException, java.io.IOException, java.io.FileNotFoundException
initialize in interface WikiProviderjava.io.FileNotFoundException - If the specified page directory does not exist.java.io.IOException - In case the specified page directory is a file, not a directory.NoRequiredPropertyExceptionprotected java.lang.String mangleName(java.lang.String pagename)
pagename - The name to mangleprotected java.lang.String unmangleName(java.lang.String filename)
filename - The filename to unmangleprotected java.io.File findPage(java.lang.String page)
page - The name of the page.public boolean pageExists(java.lang.String page)
pageExists in interface PageProviderpublic boolean pageExists(java.lang.String page, int version)
pageExists in interface PageProviderpublic java.lang.String getPageText(java.lang.String page, int version) throws ProviderException
getPageText in interface PageProviderProviderExceptionpublic void putPageText(Page page, java.lang.String text) throws ProviderException
putPageText in interface PageProviderProviderExceptionpublic java.util.Collection<Page> getAllPages() throws ProviderException
getAllPages in interface PageProviderProviderExceptionpublic java.util.Collection<Page> getAllChangedSince(java.util.Date date)
getAllChangedSince in interface PageProviderdate - public int getPageCount()
getPageCount in interface PageProviderpublic java.util.Collection<SearchResult> findPages(QueryItem[] query)
findPages in interface PageProviderpublic Page getPageInfo(java.lang.String page, int version) throws ProviderException
getPageInfo in interface PageProviderProviderExceptionpublic java.util.List<Page> getVersionHistory(java.lang.String page) throws ProviderException
getVersionHistory in interface PageProviderProviderExceptionpublic java.lang.String getProviderInfo()
getProviderInfo in interface WikiProviderpublic void deleteVersion(java.lang.String pageName, int version) throws ProviderException
deleteVersion in interface PageProviderProviderExceptionpublic void deletePage(java.lang.String pageName) throws ProviderException
deletePage in interface PageProviderProviderExceptionprotected void setCustomProperties(Page page, java.util.Properties properties)
protected void getCustomProperties(Page page, java.util.Properties defaultProperties) throws java.io.IOException
addCustomProperties(Page, Properties), validate them using validateCustomPageProperties(Properties)
and add them to default properties providedjava.io.IOExceptionprotected java.util.Properties addCustomProperties(Page page, java.util.Properties props)
validateCustomPageProperties(Properties)page - the current pageprops - the default properties of this pageprotected void validateCustomPageProperties(java.util.Properties customProperties) throws java.io.IOException
StringUtils.isAsciiPrintable() and within lengths set up in jspwiki-custom.properties.
This can be overwritten by custom FileSystemProviders to validate additional properties
See https://issues.apache.org/jira/browse/JSPWIKI-856customProperties - the custom page properties being addedjava.io.IOExceptionCopyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.