Class FormatConverterManager


  • public class FormatConverterManager
    extends Object
    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
    • Constructor Detail

      • FormatConverterManager

        public FormatConverterManager()
    • Method Detail

      • getPdfContent

        public byte[] getPdfContent​(Document document,
                                    String fileVersion,
                                    String sid)
                             throws IOException
        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 processed
        fileVersion - 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 processed
        fileVersion - The file version(optional)
        out - the output file
        sid - (optional)
        Throws:
        IOException - If something went wrong
      • convertToPdf

        public void convertToPdf​(Document document,
                                 String fileVersion,
                                 String sid)
                          throws IOException
        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 processed
        fileVersion - The file version(optional)
        sid - (optional)
        Throws:
        IOException - If something went wrong
      • convertToPdf

        public void convertToPdf​(Document document,
                                 String sid)
                          throws IOException
        Shortcut for convertToPdf(document, null, transaction)
        Parameters:
        document - The document to be processed
        sid - identifier of the session
        Throws:
        IOException - If something went wrong
      • convert

        public Document convert​(Document document,
                                String fileVersion,
                                String format,
                                DocumentHistory transaction)
                         throws Exception
        Converts a document into another format and saves the resulting file in the same folder
        Parameters:
        document - The document to be processed
        fileVersion - The file version(optional)
        format - the extension used to define the output format
        transaction - details of the current session
        Returns:
        the document that represents the conversion
        Throws:
        Exception - If something went wrong
      • 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 processed
        fileVersion - The file version(optional)
        out - the target file, the extension of this filename is used to detect the output format
        transaction - iformations 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 input
        out - output file (if outFormat is null, the filename extension determines the output format)
        outFormat - extension of the output
        sid - session ID (optional)
        Throws:
        IOException - if an error happens during the conversion
      • getEnabledOutputFormats

        public List<String> getEnabledOutputFormats​(String srcFilename)
        Returns the available output formats for the given input format
        Parameters:
        srcFilename - name of the file
        Returns:
        identifiers of the possible output extensions
      • getAllOutputFormats

        public List<String> getAllOutputFormats​(String inFileName)
        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

        public List<String> getAvailableInputFormats()
        Returns all the possible input formats
        Returns:
        the collection of all available input formats
      • getAvailableConverters

        public List<FormatConverter> getAvailableConverters​(String inFileName,
                                                            String outFileName)
        Returns the list of possible converters for a given in and out format
        Parameters:
        inFileName - input file name
        outFileName - convertion file name
        Returns:
        the collection of all installed format converters
      • getAllConverters

        public Collection<FormatConverter> getAllConverters()
        Returns the list of possible converters
        Returns:
        the collection of all installed format converters
      • getConverter

        public FormatConverter getConverter​(String inFileName,
                                            String outFileName)
        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 content
        outFileName - file name of the conversion
        Returns:
        The right format converter
      • setStorer

        public void setStorer​(Storer storer)
      • setTenantDao

        public void setTenantDao​(TenantDAO tenantDao)
      • setDocumentManager

        public void setDocumentManager​(DocumentManager documentManager)