public abstract class AbstractFileProvider extends 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 String |
DEFAULT_ENCODING
The default encoding.
|
static int |
DEFAULT_MAX_PROPKEYLENGTH |
static int |
DEFAULT_MAX_PROPLIMIT |
static int |
DEFAULT_MAX_PROPVALUELENGTH |
static String |
FILE_EXT
All files should have this extension to be recognized as JSPWiki files.
|
protected 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 String |
PROP_CUSTOMPROP_MAXKEYLENGTH |
static String |
PROP_CUSTOMPROP_MAXLIMIT |
static String |
PROP_CUSTOMPROP_MAXVALUELENGTH |
static 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 Properties |
addCustomProperties(Page page,
Properties props)
By default all page attributes that start with "@" are returned as custom properties.
|
void |
deletePage(String pageName) |
void |
deleteVersion(String pageName,
int version) |
protected File |
findPage(String page)
Finds a Wiki page from the page repository.
|
Collection<SearchResult> |
findPages(QueryItem[] query)
Iterates through all WikiPages, matches them against the given query, and returns a Collection of SearchResult objects.
|
Collection<Page> |
getAllChangedSince(Date date)
Does not work.
|
Collection<Page> |
getAllPages() |
protected void |
getCustomProperties(Page page,
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(String page,
int version)
Always returns the latest version, since FileSystemProvider
does not support versioning.
|
String |
getPageText(String page,
int version)
This implementation just returns the current version, as filesystem does not provide versioning information for now.
|
String |
getProviderInfo() |
List<Page> |
getVersionHistory(String page)
The FileSystemProvider provides only one version.
|
void |
initialize(Engine engine,
Properties properties) |
protected String |
mangleName(String pagename)
This makes sure that the queried page name is still readable by the file system.
|
boolean |
pageExists(String page) |
boolean |
pageExists(String page,
int version) |
void |
putPageText(Page page,
String text) |
protected void |
setCustomProperties(Page page,
Properties properties)
Set the custom properties provided into the given page.
|
protected String |
unmangleName(String filename)
This makes the reverse of mangleName.
|
protected void |
validateCustomPageProperties(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 String m_encoding
public static final String PROP_CUSTOMPROP_MAXLIMIT
public static final String PROP_CUSTOMPROP_MAXKEYLENGTH
public static final 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 String PROP_PAGEDIR
public static final String FILE_EXT
public static final String DEFAULT_ENCODING
public AbstractFileProvider()
public void initialize(Engine engine, Properties properties) throws NoRequiredPropertyException, IOException, FileNotFoundException
initialize in interface WikiProviderFileNotFoundException - If the specified page directory does not exist.IOException - In case the specified page directory is a file, not a directory.NoRequiredPropertyExceptionprotected String mangleName(String pagename)
pagename - The name to mangleprotected String unmangleName(String filename)
filename - The filename to unmangleprotected File findPage(String page)
page - The name of the page.public boolean pageExists(String page)
pageExists in interface PageProviderpublic boolean pageExists(String page, int version)
pageExists in interface PageProviderpublic String getPageText(String page, int version) throws ProviderException
getPageText in interface PageProviderProviderExceptionpublic void putPageText(Page page, String text) throws ProviderException
putPageText in interface PageProviderProviderExceptionpublic Collection<Page> getAllPages() throws ProviderException
getAllPages in interface PageProviderProviderExceptionpublic Collection<Page> getAllChangedSince(Date date)
getAllChangedSince in interface PageProviderdate - public int getPageCount()
getPageCount in interface PageProviderpublic Collection<SearchResult> findPages(QueryItem[] query)
findPages in interface PageProviderpublic Page getPageInfo(String page, int version) throws ProviderException
getPageInfo in interface PageProviderProviderExceptionpublic List<Page> getVersionHistory(String page) throws ProviderException
getVersionHistory in interface PageProviderProviderExceptionpublic String getProviderInfo()
getProviderInfo in interface WikiProviderpublic void deleteVersion(String pageName, int version) throws ProviderException
deleteVersion in interface PageProviderProviderExceptionpublic void deletePage(String pageName) throws ProviderException
deletePage in interface PageProviderProviderExceptionprotected void setCustomProperties(Page page, Properties properties)
protected void getCustomProperties(Page page, Properties defaultProperties) throws IOException
addCustomProperties(Page, Properties), validate them using validateCustomPageProperties(Properties)
and add them to default properties providedIOExceptionprotected Properties addCustomProperties(Page page, Properties props)
validateCustomPageProperties(Properties)page - the current pageprops - the default properties of this pageprotected void validateCustomPageProperties(Properties customProperties) throws 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 addedIOExceptionCopyright © 2001-2020 The Apache Software Foundation. All rights reserved.