Interface ContentManager
- All Known Implementing Classes:
DatabaseContent
ContentManager
manages content that is stored in a back-end
data store.
Content is isolated in repositories that should have unique names. The installation of a content manager creates an initial default repository. If others are needed, they have to be created explicitly.
All content is identified by a unique location
. The
location is formatted like this:
repository:path
If the repository:
prefix is omitted, the content will be
stored in the default repository (see ContentRepository.DEFAULT
).
The path should start with a slash that makes it 'absolute', this is completely analogue to file system paths.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsRepository
(String name) Checks if the content manager contains a certain repository.boolean
createRepository
(String name) Creates a new repository.boolean
deleteContent
(String location) Delete the content at a certain location.getContentForHtml
(String location, Context context, Route route) Retrieves a content representation for use in html.getContentInfo
(String location) Retrieves the content info from a certain location.boolean
hasContentData
(String location) Checks whether content data is available at a certain location.boolean
install()
Installs a content manager.boolean
remove()
Removes a content manager.void
serveContentData
(Context context, String location) Serves content data from a certain location through the provided element.boolean
storeContent
(String location, Content content, ContentTransformer transformer) Store content at a certain location.void
useContentData
(String location, ContentDataUserWithoutResult user) Use the data of content at a certain location.<ResultType>
ResultTypeuseContentDataResult
(String location, ContentDataUser<ResultType> user) Use the data of content at a certain location.
-
Method Details
-
install
Installs a content manager.- Returns:
true
if the installation was successful; orfalse
if it wasn't.- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
remove
Removes a content manager.- Returns:
true
if the removal was successful; orfalse
if it wasn't.- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
createRepository
Creates a new repository.- Parameters:
name
- the name of the repository to create- Returns:
true
if the creation was successful; orfalse
if it wasn't.- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
containsRepository
Checks if the content manager contains a certain repository.- Parameters:
name
- the name of the repository to check- Returns:
true
if the repository exists; orfalse
if it doesn't.- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.4
-
storeContent
boolean storeContent(String location, Content content, ContentTransformer transformer) throws ContentManagerException Store content at a certain location.If content is already present at this location, the new content will become the current version and the old content remains available as an older version.
- Parameters:
location
- the location where the content has to be stored.content
- the content that has to be storedtransformer
- a transformer that will modify the content data; ornull
if the content data should stay intact- Returns:
true
if the storing was successfully; orfalse
if it wasn't.- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
deleteContent
Delete the content at a certain location.This will delete all versions of the content at that location.
- Parameters:
location
- the location where the content has to be deleted- Returns:
true
if the deletion was successfully; orfalse
if it wasn't.- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
useContentData
void useContentData(String location, ContentDataUserWithoutResult user) throws ContentManagerException Use the data of content at a certain location.Some content data will only be available during this method call due to their volatile nature (certain streams for instance). Therefore, one has to be careful when trying to move the data that is provided to the content user outside this method. The behaviour is undefined.
- Parameters:
location
- the location whose content will be useduser
- the content user instance that will be called to use content data- Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
useContentDataResult
<ResultType> ResultType useContentDataResult(String location, ContentDataUser<ResultType> user) throws ContentManagerException Use the data of content at a certain location.Some content data will only be available during this method call due to their volatile nature (certain streams for instance). Therefore, one has to be careful when trying to move the data that is provided to the content user outside this method. The behaviour is undefined.
- Parameters:
location
- the location whose content will be useduser
- the content user instance that will be called to use content data- Returns:
- the data that the
ContentDataUser.useContentData(Object)
returns after its usage - Throws:
ContentManagerException
- if an unexpected error occurred- Since:
- 1.0
-
hasContentData
Checks whether content data is available at a certain location.- Parameters:
location
- the location that has to be checked- Returns:
true
if content data is available; orfalse
if it isn't.- Throws:
ContentManagerException
- if an expected error occurred- Since:
- 1.0
-
getContentInfo
Retrieves the content info from a certain location.- Parameters:
location
- the location whose content info has to be retrieved- Returns:
- an instance of
ContentInfo
; ornull
if no content is present at the location - Throws:
ContentManagerException
- if an expected error occurred- Since:
- 1.0
-
serveContentData
Serves content data from a certain location through the provided element.This is intended to take over the complete handling of the request, so no other content should be output and no headers manipulated in the element if this method is called.
- Parameters:
context
- an active web engine contextlocation
- the location whose content data has to be served- Throws:
ContentManagerException
- if an expected error occurred- Since:
- 1.0
-
getContentForHtml
String getContentForHtml(String location, Context context, Route route) throws ContentManagerException Retrieves a content representation for use in html.This is mainly used to integrate content data inside a html document. For instance, html content will be displayed as-is, while image content will cause an image tag to be generated with the correct source URL to serve the image.
- Parameters:
location
- the location whose content will be displayedcontext
- an active web engine contextroute
- a route that leads to arife.cmf.elements.ServeContent
element- Throws:
ContentManagerException
- if an expected error occurred- Since:
- 1.0
-