Interface ContentStore
- All Known Implementing Classes:
DatabaseContentStore,DatabaseImageStore,DatabaseRawStore,DatabaseTextStore
ContentStore stores the actual content data and is
responsible for managing it.
The store doesn't work with paths, but with content ids. Each id identifies a specific content instance at a certain location and with a certain version number.
Each store is only capable of storing content with certain mime types. The store is optimized for a certain kind of content and will maybe not be able to correctly handle other types.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteContentData(int id) Deletes the content data for a certain content id.getContentForHtml(int id, ContentInfo info, Context context, Route route) Retrieves a content data representation for use in html.getContentType(ContentInfo contentInfo) Generates the HTTP content type that corresponds best to the information in the providedContentInfo.default FormattergetFormatter(MimeType mimeType, boolean fragment) Returns aFormatterinstance that will be used to load and to format the content data.intgetSize(int id) Retrieves the size of the content data for a certain content id.Returns the collection of mime types that the content store supports.booleanhasContentData(int id) Checks whether content data is available for a certain content id.booleaninstall()Installs a content store.booleanremove()Removes a content store.voidserveContentData(Context context, int id) Serves content data for a certain content id through the provided element.booleanstoreContentData(int id, Content content, ContentTransformer transformer) Stores the content data for a certain content id.voiduseContentData(int id, ContentDataUserWithoutResult user) Use the data of a certain content id.<ResultType>
ResultTypeuseContentDataResult(int id, ContentDataUser<ResultType> user) Use the data of a certain content id.
-
Method Details
-
install
Installs a content store.- Returns:
trueif the installation was successful; orfalseif it wasn't.- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-
remove
Removes a content store.- Returns:
trueif the removal was successful; orfalseif it wasn't.- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-
getSupportedMimeTypes
Collection<MimeType> getSupportedMimeTypes()Returns the collection of mime types that the content store supports.- Returns:
- the collection of supported mime types
- Since:
- 1.0
-
getContentType
Generates the HTTP content type that corresponds best to the information in the providedContentInfo.- Parameters:
contentInfo- the content info instance for which the content type has to be generated- Returns:
- the generated content type
- Since:
- 1.0
-
getFormatter
Returns aFormatterinstance that will be used to load and to format the content data.- Parameters:
mimeType- the mime type for which the formatter will be returnedfragment-trueif the content that has to be formatter is a fragment; orfalseotherwise- Returns:
- the corresponding formatter
- Since:
- 1.0
-
storeContentData
boolean storeContentData(int id, Content content, ContentTransformer transformer) throws ContentManagerException Stores the content data for a certain content id.- Parameters:
id- the id of the content whose data will be storedcontent- the content whose data has to be storedtransformer- a transformer that will modify the content data; ornullif the content data should stay intact- Returns:
trueif the storing was successfully; orfalseif it wasn't.- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-
deleteContentData
Deletes the content data for a certain content id.- Parameters:
id- the id of the content whose data will be deleted- Returns:
trueif the deletion was successfully; orfalseif it wasn't.- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-
useContentData
Use the data of a certain content id.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:
id- the id of the content whose data 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(int id, ContentDataUser<ResultType> user) throws ContentManagerException Use the data of a certain content id.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:
id- the id of the content whose data 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 for a certain content id.- Parameters:
id- the id of the content whose data availability will be checked- Returns:
trueif content data is available; orfalseif it isn't.- Throws:
ContentManagerException- if an expected error occurred- Since:
- 1.0
-
getSize
Retrieves the size of the content data for a certain content id.Note that the result is specific to the data store. For instance, text data could return the number of characters, while image data could return the number of bytes.
- Parameters:
id- the id of the content whose data size will be returned- Returns:
-1if no data is available for the provided content id; orthe requested content data size.
- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-
serveContentData
Serves content data for a certain content id 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 contextid- the id of the content whose data will be served- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-
getContentForHtml
String getContentForHtml(int id, ContentInfo info, Context context, Route route) throws ContentManagerException Retrieves a content data 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:
id- the id of the content whose data will be displayedinfo- the content info instance for which the html content has to be generatedcontext- an active web engine contextroute- a route that leads to arife.cmf.elements.ServeContentelement- Returns:
- the html content representation
- Throws:
ContentManagerException- if an unexpected error occurred- Since:
- 1.0
-