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
Fields Modifier and Type Field Description protected Context
_cocoonContext
The cocoon contextprotected Document2ImagesConvertor
_documentToImages
The document to images convertor.private ConcurrentMap<String,ReentrantLock>
_locks
Map of locks, indexed by resource ID.protected AmetysObjectResolver
_resolver
The ametys object resolver.
-
Constructor Summary
Constructors Constructor Description AbstractConvertDocument2ImagesComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
cache(String relativeCachePath, String md5sum, InputStream documentInputStream, String documentName, String documentId, String documentMimeType)
Create the images and put it into the cacheprotected void
createImages(InputStream documentInputStream, String documentName, File baseFolder)
Create images for a resource, in a specified folder.void
initialize()
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 Detail
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_documentToImages
protected Document2ImagesConvertor _documentToImages
The document to images convertor.
-
_cocoonContext
protected Context _cocoonContext
The cocoon context
-
_locks
private ConcurrentMap<String,ReentrantLock> _locks
Map of locks, indexed by resource ID.
-
-
Constructor Detail
-
AbstractConvertDocument2ImagesComponent
public AbstractConvertDocument2ImagesComponent()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
isMimeTypeSupported
protected boolean isMimeTypeSupported(String mimeType)
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
-
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
-
-