Package com.logicaldoc.core.conversion
Class FormatConverterManager
java.lang.Object
com.logicaldoc.core.conversion.FormatConverterManager
Manager class used to handle format converters. For each couple
inFormat-outFormat you may have different possible converters, they are taken
by the FormatConverter extension point. The actual converter uses is
the one pointed by the context property names converter.inExt-outExt.
- Since:
- 7.1.3
- Author:
- Marco Meschieri - LogicalDOC
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(Document document, String fileVersion, String format, DocumentHistory transaction) Converts a document into another format and saves the resulting file in the same foldervoid
Converts a file into a different formatvoid
convertToFile
(Document document, String fileVersion, File out, DocumentHistory transaction) Converts a document and writes the content of the conversion into a file.void
convertToPdf
(Document document, String sid) Shortcut for convertToPdf(document, null, transaction)void
convertToPdf
(Document document, String fileVersion, String sid) Creates the pdf for the specified document and file version (suffix PDF_CONVERSION_SUFFIX).Returns the list of possible convertersgetAllOutputFormats
(String inFileName) Returns all the possible output formats for the given input formatgetAvailableConverters
(String inFileName, String outFileName) Returns the list of possible converters for a given in and out formatReturns all the possible input formatsgetConverter
(String inFileName, String outFileName) Loads the proper converter for the passed file names.getEnabledOutputFormats
(String srcFilename) Returns the available output formats for the given input formatbyte[]
getPdfContent
(Document document, String fileVersion, String sid) Retrieves the content of the Pdf conversion.void
init()
Initializes the converters mapvoid
setConfig
(ContextProperties config) void
setDocumentManager
(DocumentManager documentManager) void
void
setTenantDao
(TenantDAO tenantDao) void
writePdfToFile
(Document document, String fileVersion, File out, String sid) Write the content of the Pdf conversion into a file.
-
Field Details
-
PDF_CONVERSION_SUFFIX
- See Also:
-
-
Constructor Details
-
FormatConverterManager
public FormatConverterManager()
-
-
Method Details
-
getPdfContent
Retrieves the content of the Pdf conversion. If the Pdf conversion is not available in the store, it is created.- Parameters:
document
- The document to be processedfileVersion
- The file version(optional)sid
- (optional)- Returns:
- The content of the PDF as bytes
- Throws:
IOException
- If something went wrong
-
writePdfToFile
public void writePdfToFile(Document document, String fileVersion, File out, String sid) throws IOException Write the content of the Pdf conversion into a file. If the Pdf conversion is not available in the store, it is created.- Parameters:
document
- The document to be processedfileVersion
- The file version(optional)out
- the output filesid
- (optional)- Throws:
IOException
- If something went wrong
-
convertToPdf
Creates the pdf for the specified document and file version (suffix PDF_CONVERSION_SUFFIX). If the Pdf conversion already exists it, nothing happens.- Parameters:
document
- The document to be processedfileVersion
- The file version(optional)sid
- (optional)- Throws:
IOException
- If something went wrong
-
convertToPdf
Shortcut for convertToPdf(document, null, transaction)- Parameters:
document
- The document to be processedsid
- identifier of the session- Throws:
IOException
- If something went wrong
-
convert
public Document convert(Document document, String fileVersion, String format, DocumentHistory transaction) throws IOException, PersistenceException Converts a document into another format and saves the resulting file in the same folder- Parameters:
document
- The document to be processedfileVersion
- The file version(optional)format
- the extension used to define the output formattransaction
- details of the current session- Returns:
- the document that represents the conversion
- Throws:
IOException
- I/O errorPersistenceException
- Error in the database
-
convertToFile
public void convertToFile(Document document, String fileVersion, File out, DocumentHistory transaction) throws IOException Converts a document and writes the content of the conversion into a file.- Parameters:
document
- The document to be processedfileVersion
- The file version(optional)out
- the target file, the extension of this filename is used to detect the output formattransaction
- informations about the session- Throws:
IOException
- if an error happens during the conversion
-
convertFile
public void convertFile(File in, String inFilename, File out, String outFormat, String sid) throws IOException Converts a file into a different format- Parameters:
in
- input file (the filename extension determines the source format, in case you do not use inFilename)inFilename
- file name of the inputout
- output file (if outFormat is null, the filename extension determines the output format)outFormat
- extension of the outputsid
- session ID (optional)- Throws:
IOException
- if an error happens during the conversion
-
getEnabledOutputFormats
Returns the available output formats for the given input format- Parameters:
srcFilename
- name of the file- Returns:
- identifiers of the possible output extensions
-
getAllOutputFormats
Returns all the possible output formats for the given input format- Parameters:
inFileName
- name of the file to convert- Returns:
- list of possible output formats
-
getAvailableInputFormats
Returns all the possible input formats- Returns:
- the collection of all available input formats
-
getAvailableConverters
Returns the list of possible converters for a given in and out format- Parameters:
inFileName
- input file nameoutFileName
- conversion file name- Returns:
- the collection of all installed format converters
-
getAllConverters
Returns the list of possible converters- Returns:
- the collection of all installed format converters
-
getConverter
Loads the proper converter for the passed file names. The right converter used is defined in the configuration parameter converter.composeKey()- Parameters:
inFileName
- file name of the input contentoutFileName
- file name of the conversion- Returns:
- The right format converter
-
init
public void init()Initializes the converters map -
getConverters
-
setStorer
-
setTenantDao
-
setDocumentManager
-
setConfig
-