Package org.apache.wiki.providers
Class AbstractFileProvider
java.lang.Object
org.apache.wiki.providers.AbstractFileProvider
- All Implemented Interfaces:
org.apache.wiki.api.providers.PageProvider,org.apache.wiki.api.providers.WikiProvider
- Direct Known Subclasses:
FileSystemProvider,VersioningFileProvider
public abstract class AbstractFileProvider
extends Object
implements org.apache.wiki.api.providers.PageProvider
Provides a simple directory based repository for Wiki pages.
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.
- Since:
- 2.1.21.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA simple filter which filters only those filenames which correspond to the file extension used. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default encoding.static final intstatic final intstatic final intstatic final StringAll files should have this extension to be recognized as JSPWiki files.protected Stringprotected org.apache.wiki.api.core.Enginestatic intThis number limits the length of a custom page property key length.static intThis parameter limits the number of custom page properties allowed on a pagestatic intThis number limits the length of a custom page property value length.static final Stringstatic final Stringstatic final Stringstatic final StringName of the property that defines where page directories are.Fields inherited from interface org.apache.wiki.api.providers.WikiProvider
LATEST_VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PropertiesaddCustomProperties(org.apache.wiki.api.core.Page page, Properties props) By default all page attributes that start with "@" are returned as custom properties.voiddeletePage(String pageName) voiddeleteVersion(String pageName, int version) deobfuscate(String pageContent) An api hook to provide deobfuscation of data before it's written to disk.protected FileFinds a Wiki page from the page repository.Collection<org.apache.wiki.api.search.SearchResult>findPages(org.apache.wiki.api.search.QueryItem[] query) Iterates through all WikiPages, matches them against the given query, and returns a Collection of SearchResult objects.Collection<org.apache.wiki.api.core.Page>getAllChangedSince(Date date) Does not work.Collection<org.apache.wiki.api.core.Page>protected voidgetCustomProperties(org.apache.wiki.api.core.Page page, Properties defaultProperties) Get custom properties usingaddCustomProperties(Page, Properties), validate them usingvalidateCustomPageProperties(Properties)and add them to default properties providedintorg.apache.wiki.api.core.PagegetPageInfo(String page, int version) Always returns the latest version, since FileSystemProvider does not support versioning.getPageText(String page, int version) This implementation just returns the current version, as filesystem does not provide versioning information for now.List<org.apache.wiki.api.core.Page>getVersionHistory(String page) The FileSystemProvider provides only one version.voidinitialize(org.apache.wiki.api.core.Engine engine, Properties properties) protected StringmangleName(String pagename) This makes sure that the queried page name is still readable by the file system.An api hook to provide obfuscation of data before it's written to disk.booleanpageExists(String page) booleanpageExists(String page, int version) voidputPageText(org.apache.wiki.api.core.Page page, String text) protected voidsetCustomProperties(org.apache.wiki.api.core.Page page, Properties properties) Set the custom properties provided into the given page.protected StringunmangleName(String filename) This makes the reverse of mangleName.protected voidvalidateCustomPageProperties(Properties customProperties) Default validation, validates that key and value is ASCIIStringUtils.isAsciiPrintable()and within lengths set up in jspwiki-custom.properties.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.wiki.api.providers.PageProvider
movePage
-
Field Details
-
m_encoding
-
m_engine
-
PROP_CUSTOMPROP_MAXLIMIT
- See Also:
-
PROP_CUSTOMPROP_MAXKEYLENGTH
- See Also:
-
PROP_CUSTOMPROP_MAXVALUELENGTH
- See Also:
-
DEFAULT_MAX_PROPLIMIT
- See Also:
-
DEFAULT_MAX_PROPKEYLENGTH
- See Also:
-
DEFAULT_MAX_PROPVALUELENGTH
- See Also:
-
MAX_PROPLIMIT
This parameter limits the number of custom page properties allowed on a page -
MAX_PROPKEYLENGTH
This number limits the length of a custom page property key length. The default value here designed with future JDBC providers in mind. -
MAX_PROPVALUELENGTH
This number limits the length of a custom page property value length. The default value here designed with future JDBC providers in mind. -
PROP_PAGEDIR
Name of the property that defines where page directories are.- See Also:
-
FILE_EXT
All files should have this extension to be recognized as JSPWiki files. We default to .txt, because that is probably easiest for Windows users, and guarantees correct handling.- See Also:
-
DEFAULT_ENCODING
The default encoding.
-
-
Constructor Details
-
AbstractFileProvider
public AbstractFileProvider()
-
-
Method Details
-
initialize
public void initialize(org.apache.wiki.api.core.Engine engine, Properties properties) throws org.apache.wiki.api.exceptions.NoRequiredPropertyException, IOException, FileNotFoundException - Specified by:
initializein interfaceorg.apache.wiki.api.providers.WikiProvider- Throws:
FileNotFoundException- If the specified page directory does not exist.IOException- In case the specified page directory is a file, not a directory.org.apache.wiki.api.exceptions.NoRequiredPropertyException
-
mangleName
This makes sure that the queried page name is still readable by the file system. For example, all XML entities and slashes are encoded with the percent notation.- Parameters:
pagename- The name to mangle- Returns:
- The mangled name.
-
unmangleName
This makes the reverse of mangleName.- Parameters:
filename- The filename to unmangle- Returns:
- The unmangled name.
-
findPage
Finds a Wiki page from the page repository.- Parameters:
page- The name of the page.- Returns:
- A File to the page. May be null.
-
pageExists
- Specified by:
pageExistsin interfaceorg.apache.wiki.api.providers.PageProvider
-
pageExists
- Specified by:
pageExistsin interfaceorg.apache.wiki.api.providers.PageProvider
-
getPageText
public String getPageText(String page, int version) throws org.apache.wiki.api.exceptions.ProviderException This implementation just returns the current version, as filesystem does not provide versioning information for now.- Specified by:
getPageTextin interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
obfuscate
An api hook to provide obfuscation of data before it's written to disk. Useful for wiring in your own custom encryption mechanism if so desired.- Parameters:
pageContent-- Returns:
- Since:
- 3.0.0
-
deobfuscate
An api hook to provide deobfuscation of data before it's written to disk. Useful for wiring in your own custom decryption mechanism if so desired.- Parameters:
pageContent-- Returns:
- Since:
- 3.0.0
-
putPageText
public void putPageText(org.apache.wiki.api.core.Page page, String text) throws org.apache.wiki.api.exceptions.ProviderException - Specified by:
putPageTextin interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
getAllPages
public Collection<org.apache.wiki.api.core.Page> getAllPages() throws org.apache.wiki.api.exceptions.ProviderException- Specified by:
getAllPagesin interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
getAllChangedSince
Does not work.- Specified by:
getAllChangedSincein interfaceorg.apache.wiki.api.providers.PageProvider- Parameters:
date-- Returns:
-
getPageCount
- Specified by:
getPageCountin interfaceorg.apache.wiki.api.providers.PageProvider
-
findPages
public Collection<org.apache.wiki.api.search.SearchResult> findPages(org.apache.wiki.api.search.QueryItem[] query) Iterates through all WikiPages, matches them against the given query, and returns a Collection of SearchResult objects.- Specified by:
findPagesin interfaceorg.apache.wiki.api.providers.PageProvider
-
getPageInfo
public org.apache.wiki.api.core.Page getPageInfo(String page, int version) throws org.apache.wiki.api.exceptions.ProviderException Always returns the latest version, since FileSystemProvider does not support versioning.- Specified by:
getPageInfoin interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
getVersionHistory
public List<org.apache.wiki.api.core.Page> getVersionHistory(String page) throws org.apache.wiki.api.exceptions.ProviderException The FileSystemProvider provides only one version.- Specified by:
getVersionHistoryin interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
getProviderInfo
- Specified by:
getProviderInfoin interfaceorg.apache.wiki.api.providers.WikiProvider
-
deleteVersion
public void deleteVersion(String pageName, int version) throws org.apache.wiki.api.exceptions.ProviderException - Specified by:
deleteVersionin interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
deletePage
- Specified by:
deletePagein interfaceorg.apache.wiki.api.providers.PageProvider- Throws:
org.apache.wiki.api.exceptions.ProviderException
-
setCustomProperties
Set the custom properties provided into the given page.- Since:
- 2.10.2
-
getCustomProperties
protected void getCustomProperties(org.apache.wiki.api.core.Page page, Properties defaultProperties) throws IOException Get custom properties usingaddCustomProperties(Page, Properties), validate them usingvalidateCustomPageProperties(Properties)and add them to default properties provided- Throws:
IOException- Since:
- 2.10.2
-
addCustomProperties
By default all page attributes that start with "@" are returned as custom properties. This can be overwritten by custom FileSystemProviders to save additional properties. CustomPageProperties are validated byvalidateCustomPageProperties(Properties)- Parameters:
page- the current pageprops- the default properties of this page- Returns:
- default implementation returns empty Properties.
- Since:
- 2.10.2
-
validateCustomPageProperties
Default validation, validates that key and value is ASCIIStringUtils.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-856- Parameters:
customProperties- the custom page properties being added- Throws:
IOException- Since:
- 2.10.2
-