Class CommonsManager

All Implemented Interfaces:
ItemLifecycleListener, 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:
  • Constructor Details

    • CommonsManager

      public CommonsManager()
  • Method Details

    • getInstance

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

      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
      IOException - If an error occurs while reading the file
      UnsupportedEncodingException - If the specified encoding is not supported
    • getVelocityEngine

      @Deprecated(since="6.6", forRemoval=false) public org.apache.velocity.app.VelocityEngine getVelocityEngine(Properties p) throws 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:
      Exception
    • getFormats

      public List<Format> getFormats(ComposedType ct)
      Description copied from class: GeneratedCommonsManager
      Generated method - Getter of the ComposedType.formats attribute.
      Overrides:
      getFormats in class GeneratedCommonsManager
      Parameters:
      ct - the ComposedType
      Returns:
      for the given ComposedType a Collection with all possible Formats.
    • getFormats

      public List<Format> getFormats(SessionContext ctx, ComposedType ct)
      Description copied from class: GeneratedCommonsManager
      Generated method - Getter of the ComposedType.formats attribute.
      Overrides:
      getFormats in class GeneratedCommonsManager
      Parameters:
      ctx - the SessionContext
      ct - the ComposedType
      Returns:
      for the given ComposedType ant SessionContext a Collection with all possible Formats.
    • getFormatsForItem

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

      public 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, 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 String transform(String inputXML, InputStream inputXSLStream, boolean appendHeaders)
      Applies an XML Transformation on the inputXML data based on the specified XSL
      Parameters:
      inputXML -
      inputXSLStream -
      appendHeaders -
    • transform

      public String transform(InputStream inputXMLStream, 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 String transform(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 String transform(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 Collection<JaloVelocityRenderer> getJaloVelocityRenderers()
      Returns all available VelocityHmcRenderers
    • getRenderersPropertyList

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

      public JaloTranslatorConfiguration getJaloTranslatorConfigurationByCode(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)
    • render

      @Deprecated(since="ages", forRemoval=false) public void render(RendererTemplate template, Object context, Writer output)
      Deprecated.
      since ages - as of release 4.3, please use RendererService.render(de.hybris.platform.commons.model.renderer.RendererTemplateModel, Object, Writer)

      Renders a template using the context PLA-5986

      Parameters:
      template - contains the template content
      context - contains the content of value, which will replace the macro in the template
      output - saves the result