Class CommonsManager

  • All Implemented Interfaces:
    ItemLifecycleListener, java.io.Serializable

    public class CommonsManager
    extends GeneratedCommonsManager
    This extension contains some useful logic for the platform.
    These are:
    • Formatter (via Velocity, FOP, etc.)
    • Translator (Supports translation of e.g. HTML text to another format you specify)
    • ...
    See Also:
    Serialized Form
    • Constructor Detail

      • CommonsManager

        public CommonsManager()
    • Method Detail

      • getInstance

        public static CommonsManager getInstance()
        Returns:
        instance of this manager
      • getJarFileAsString

        public static java.lang.String getJarFileAsString​(java.lang.String filename,
                                                          java.lang.String encoding)
                                                   throws JaloInvalidParameterException,
                                                          JaloItemNotFoundException,
                                                          java.io.IOException,
                                                          java.io.UnsupportedEncodingException
        Returns a file from this extension's JAR file as String (incl. original line break symbols)
        Parameters:
        filename - The name of the file in the JAR file
        encoding - The encoding that the resulting String shall be encoded with
        Returns:
        A String with the content of the original file
        Throws:
        JaloInvalidParameterException - If the filename is not specified
        JaloItemNotFoundException - If the file could not be found in the JAR file
        java.io.IOException - If an error occurs while reading the file
        java.io.UnsupportedEncodingException - If the specified encoding is not supported
      • getVelocityEngine

        @Deprecated(since="6.6",
                    forRemoval=false)
        public org.apache.velocity.app.VelocityEngine getVelocityEngine​(java.util.Properties p)
                                                                 throws java.lang.Exception
        Deprecated.
        since 6.6
        Deprecated - use Velocity singleton instead. Only used in VelocityFormatter due the creation of the VelocityEngine takes much time. So the engine will be hold by the CommonsManager and is only created once. Remember to set the correct properties, they will be given over to the VelocityEngine.init method.
        Parameters:
        p - the init properties or the engine
        Returns:
        the VelocityEngine
        Throws:
        java.lang.Exception
      • getFormatsForItem

        public java.util.Collection<Format> getFormatsForItem​(Item item)
        Parameters:
        item - the item
        Returns:
        a Collection with all Formats for the given item
      • getDocuments

        public java.util.Collection<Document> getDocuments​(Item item,
                                                           Format format)
        Parameters:
        item - the item
        format - the format
        Returns:
        a Collection with all Document for the given item and the given format
      • setDocuments

        public void setDocuments​(Item item,
                                 Format format,
                                 java.util.Collection<Document> documents)
                          throws ConsistencyCheckException
        Sets for the given item and the given Format all Documents which are in the Collection documents. A JaloInvalidParameterException is thrown if a document of the Collection belongs not to the item.
        Parameters:
        item - the item which can have documents
        format - the Format which creates documents
        documents - a Collection of Documents
        Throws:
        ConsistencyCheckException
      • transform

        public java.lang.String transform​(java.lang.String inputXML,
                                          java.io.InputStream inputXSLStream,
                                          boolean appendHeaders)
        Applies an XML Transformation on the inputXML data based on the specified XSL
        Parameters:
        inputXML -
        inputXSLStream -
        appendHeaders -
      • transform

        public java.lang.String transform​(java.io.InputStream inputXMLStream,
                                          java.io.InputStream inputXSLStream,
                                          boolean appendHeaders)
        Applies an XML Transformation on the inputXMLSTream of Data
        Parameters:
        inputXMLStream - specifies the inputXMLStream to be used.
        inputXSLStream - specifies the XSL DataStream to be used for XML transformation
        appendHeaders - specifies whether to make the convert data to well formed HTML.
      • transform

        public java.lang.String transform​(java.lang.String inputXML,
                                          Media inputXSLMedia,
                                          boolean appendHeaders)
        Applies an XML Transformation on the inputXMLSTream of Data
        Parameters:
        inputXML - specifies the inputXMLStream to be used.
        inputXSLMedia - specifies the XSL to be used for XML transformation
        appendHeaders - specifies whether to make the convert data to well formed HTML.
      • transform

        public java.lang.String transform​(java.io.InputStream inputXMLStream,
                                          Media inputXSLMedia,
                                          boolean appendHeaders)
      • registerProductSampleEnhancer

        protected static void registerProductSampleEnhancer()
        Shows how to use configure the CommonsManager.ItemMethodInterceptor for arbitrary item classes.
      • getJaloVelocityRenderers

        public java.util.Collection<JaloVelocityRenderer> getJaloVelocityRenderers()
        Returns all available VelocityHmcRenderers
      • getRenderersPropertyList

        public java.util.Collection<RenderersProperty> getRenderersPropertyList()
        Returns all available RenderersPropertys
      • getJaloTranslatorConfigurationByCode

        public JaloTranslatorConfiguration getJaloTranslatorConfigurationByCode​(java.lang.String code)
        Returns the first found JaloTranslatorConfiguration for the given code
      • getDefaultTranslatorConfiguration

        public TranslatorConfiguration getDefaultTranslatorConfiguration()
        Returns a TranslatorConfiguration that is prepared for common InDesign translations
        (or null, if the TranslatorConfiguration could not be created)
        Returns:
        A TranslatorConfiguration that is prepared for common InDesign translations (or null, if the TranslatorConfiguration could not be created)