Package org.ametys.plugins.flipbook
Class AbstractConvertDocument2ImagesComponent
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.flipbook.AbstractConvertDocument2ImagesComponent
- All Implemented Interfaces:
Initializable
,Component
,LogEnabled
,Serviceable
,ThreadSafe
- Direct Known Subclasses:
ConvertContentAttachment2ImagesComponent
,ConvertExternalResource2ImagesComponent
,ConvertMetadata2ImagesComponent
,ConvertResource2ImagesComponent
public abstract class AbstractConvertDocument2ImagesComponent
extends AbstractLogEnabled
implements ThreadSafe, Initializable, Serviceable, Component
Document to images action: converts the document into one image per page if it is not already done.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Context
The cocoon contextprotected Document2ImagesConvertor
The document to images convertor.protected AmetysObjectResolver
The ametys object resolver. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
cache
(String relativeCachePath, String md5sum, InputStream documentInputStream, String documentName, String documentId, String documentMimeType) Create the images and put it into the cacheprotected void
cleanCache
(String relativeCachePath) Clean a cache folder if it exists.protected void
createImages
(InputStream documentInputStream, String documentName, File baseFolder) Create images for a resource, in a specified folder.static File
getCacheFile
(String relativeCachePath) Get the cache filevoid
protected boolean
isMimeTypeSupported
(String mimeType) Test if the mimetype is supported for conversionvoid
service
(ServiceManager serviceManager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_resolver
The ametys object resolver. -
_documentToImages
The document to images convertor. -
_cocoonContext
The cocoon context
-
-
Constructor Details
-
AbstractConvertDocument2ImagesComponent
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
isMimeTypeSupported
Test if the mimetype is supported for conversion- Parameters:
mimeType
- the mime type- Returns:
- true if the mimetype can be transformed
-
cache
protected String cache(String relativeCachePath, String md5sum, InputStream documentInputStream, String documentName, String documentId, String documentMimeType) throws IOException, FlipbookException Create the images and put it into the cache- Parameters:
relativeCachePath
- the path of the relative cachemd5sum
- the md5 sumdocumentInputStream
- the input stream of the documentdocumentName
- the document's namedocumentId
- the id of the documentdocumentMimeType
- the mime type of the document- Returns:
- The absolute cache path
- Throws:
IOException
- if an error occurs while manipulating filesFlipbookException
- if an error occurs while manipulating the flipbookUnsupportedOperationException
- If the mime type is not supported
-
cleanCache
Clean a cache folder if it exists. This method is intended to invalidate cache created by the cache method- Parameters:
relativeCachePath
- the relative cache path
-
getCacheFile
Get the cache file- Parameters:
relativeCachePath
- the object path- Returns:
- the cache file
-
createImages
protected void createImages(InputStream documentInputStream, String documentName, File baseFolder) throws IOException, FlipbookException Create images for a resource, in a specified folder.- Parameters:
documentInputStream
- the input stream of the documentdocumentName
- the name of the documentbaseFolder
- the base folder.- Throws:
IOException
- if an error occurs while manipulating filesFlipbookException
- if an error occurs while manipulating the flipbook
-