Class TransformerDebug

    • Constructor Summary

      Constructors 
      Constructor Description
      TransformerDebug​(org.alfresco.service.cmr.repository.NodeService nodeService, org.alfresco.service.cmr.repository.MimetypeService mimetypeService, ContentTransformerRegistry transformerRegistry, TransformerConfig transformerConfig, org.apache.commons.logging.Log transformerLog, org.apache.commons.logging.Log transformerDebugLog)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activeTransformer​(int mimetypePairCount, ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes, boolean firstMimetypePair)  
      void activeTransformer​(java.lang.String sourceMimetype, java.lang.String targetMimetype, int transformerCount, ContentTransformer transformer, long maxSourceSizeKBytes, boolean firstTransformer)  
      void availableTransformers​(java.util.List<ContentTransformer> transformers, long sourceSize, TransformationOptions options, java.lang.String calledFrom)
      Called once all available transformers have been identified.
      void blacklistTransform​(ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
      Called when a transformer has been ignored because of a blacklist entry.
      void debug​(java.lang.String message)
      Log a message prefixed with the current transformation reference.
      void debug​(java.lang.String message, java.lang.Throwable t)
      Log a message prefixed with the current transformation reference and include a exception, suppressing the stack trace if repeated as we return up the stack of transformers.
      java.lang.String fileSize​(long size)  
      java.lang.String getFileName​(TransformationOptions options, boolean firstLevel, long sourceSize)  
      java.util.Collection<java.lang.String> getSourceMimetypes​(java.lang.String sourceExtension)
      Returns a collection of mimetypes ordered by extension, but unlike the version in MimetypeService throws an exception if the sourceExtension is supplied but does not match a mimetype.
      java.lang.StringBuilder getStringBuilder()
      Returns the current StringBuilder (if any) being used to capture debug information for the current Thread.
      java.util.Collection<java.lang.String> getTargetMimetypes​(java.lang.String sourceExtension, java.lang.String targetExtension, java.util.Collection<java.lang.String> sourceMimetypes)
      Identical to getSourceMimetypes for the target, but avoids doing the look up if the sourceExtension is the same as the tragetExtension, so will have the same result.
      java.lang.String[] getTestFileExtensionsAndMimetypes()  
      void inactiveTransformer​(ContentTransformer transformer)  
      boolean isEnabled()
      Indicates if any logging is required.
      java.lang.String ms​(long time)  
      void popAvailable()
      Called after working out what transformers are available and any resulting transform has been called.
      void popIsTransformableSize()
      Called after returning from a nested isTransformable.
      void popMisc()
      Removes a frame from the stack.
      void popTransform()
      Called after performing a transform.
      void pushAvailable​(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
      Called prior to working out what transformers are available.
      void pushIsTransformableSize​(ContentTransformer transformer)
      Called prior to calling a nested isTransformable.
      void pushMisc()
      Adds a new level to the stack to get a new request number or nesting number.
      void pushTransform​(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, TransformationOptions options)
      Called prior to performing a transform.
      <T extends java.lang.Throwable>
      T
      setCause​(T t)
      Sets the cause of a transformation failure, so that only the message of the Throwable is reported later rather than the full stack trace over and over.
      void setContentService​(ContentService contentService)  
      static boolean setDebugOutput​(boolean debugOutput)
      Enable or disable debug log output.
      void setStringBuilder​(java.lang.StringBuilder sb)
      Sets the StringBuilder to be used to capture debug information for the current Thread.
      java.util.Collection<ContentTransformer> sortTransformersByName​(java.lang.String transformerName)
      Returns a sorted list of all transformers sorted by name.
      java.lang.String testTransform​(java.lang.String sourceExtension, java.lang.String targetExtension, java.lang.String use)  
      java.lang.String testTransform​(java.lang.String transformerName, java.lang.String sourceExtension, java.lang.String targetExtension, java.lang.String use)  
      java.lang.String transformationsByExtension​(java.lang.String sourceExtension, java.lang.String targetExtension, boolean toString, boolean format42, boolean onlyNonDeterministic, java.lang.String use)
      Returns a String and /or debug that provides a list of supported transformations sorted by source and target mimetype extension.
      java.lang.String transformationsByTransformer​(java.lang.String transformerName, boolean toString, boolean format42, java.lang.String use)
      Returns a String and /or debug that provides a list of supported transformations for each transformer.
      void unavailableTransformer​(ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes)
      Called to identify a transformer that cannot be used during working out available transformers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TransformerDebug

        public TransformerDebug​(org.alfresco.service.cmr.repository.NodeService nodeService,
                                org.alfresco.service.cmr.repository.MimetypeService mimetypeService,
                                ContentTransformerRegistry transformerRegistry,
                                TransformerConfig transformerConfig,
                                org.apache.commons.logging.Log transformerLog,
                                org.apache.commons.logging.Log transformerDebugLog)
        Constructor
    • Method Detail

      • setContentService

        public void setContentService​(ContentService contentService)
      • pushAvailable

        public void pushAvailable​(java.lang.String fromUrl,
                                  java.lang.String sourceMimetype,
                                  java.lang.String targetMimetype,
                                  TransformationOptions options)
        Called prior to working out what transformers are available.
      • blacklistTransform

        public void blacklistTransform​(ContentTransformer transformer,
                                       java.lang.String sourceMimetype,
                                       java.lang.String targetMimetype,
                                       TransformationOptions options)
        Called when a transformer has been ignored because of a blacklist entry.
      • pushTransform

        public void pushTransform​(ContentTransformer transformer,
                                  java.lang.String fromUrl,
                                  java.lang.String sourceMimetype,
                                  java.lang.String targetMimetype,
                                  long sourceSize,
                                  TransformationOptions options)
        Called prior to performing a transform.
      • pushMisc

        public void pushMisc()
        Adds a new level to the stack to get a new request number or nesting number. Called prior to working out what transformers are active and prior to listing the supported mimetypes for an active transformer.
      • pushIsTransformableSize

        public void pushIsTransformableSize​(ContentTransformer transformer)
        Called prior to calling a nested isTransformable.
      • unavailableTransformer

        public void unavailableTransformer​(ContentTransformer transformer,
                                           java.lang.String sourceMimetype,
                                           java.lang.String targetMimetype,
                                           long maxSourceSizeKBytes)
        Called to identify a transformer that cannot be used during working out available transformers.
      • availableTransformers

        public void availableTransformers​(java.util.List<ContentTransformer> transformers,
                                          long sourceSize,
                                          TransformationOptions options,
                                          java.lang.String calledFrom)
        Called once all available transformers have been identified.
      • inactiveTransformer

        public void inactiveTransformer​(ContentTransformer transformer)
      • activeTransformer

        public void activeTransformer​(int mimetypePairCount,
                                      ContentTransformer transformer,
                                      java.lang.String sourceMimetype,
                                      java.lang.String targetMimetype,
                                      long maxSourceSizeKBytes,
                                      boolean firstMimetypePair)
      • activeTransformer

        public void activeTransformer​(java.lang.String sourceMimetype,
                                      java.lang.String targetMimetype,
                                      int transformerCount,
                                      ContentTransformer transformer,
                                      long maxSourceSizeKBytes,
                                      boolean firstTransformer)
      • popAvailable

        public void popAvailable()
        Called after working out what transformers are available and any resulting transform has been called.
      • popTransform

        public void popTransform()
        Called after performing a transform.
      • popMisc

        public void popMisc()
        Removes a frame from the stack. Called prior to working out what transformers are active and prior to listing the supported mimetypes for an active transformer.
      • popIsTransformableSize

        public void popIsTransformableSize()
        Called after returning from a nested isTransformable.
      • isEnabled

        public boolean isEnabled()
        Indicates if any logging is required.
      • setDebugOutput

        public static boolean setDebugOutput​(boolean debugOutput)
        Enable or disable debug log output. Normally used to hide calls to getTransformer as trace rather than debug level log messages. There are lots of these and it makes it hard to see what is going on.
        Parameters:
        debugOutput - if true both debug and trace is generated. Otherwise all output is trace.
        Returns:
        the original value.
      • debug

        public void debug​(java.lang.String message)
        Log a message prefixed with the current transformation reference.
        Parameters:
        message -
      • debug

        public void debug​(java.lang.String message,
                          java.lang.Throwable t)
        Log a message prefixed with the current transformation reference and include a exception, suppressing the stack trace if repeated as we return up the stack of transformers.
        Parameters:
        message -
      • setCause

        public <T extends java.lang.Throwable> T setCause​(T t)
        Sets the cause of a transformation failure, so that only the message of the Throwable is reported later rather than the full stack trace over and over.
      • getStringBuilder

        public java.lang.StringBuilder getStringBuilder()
        Returns the current StringBuilder (if any) being used to capture debug information for the current Thread.
      • setStringBuilder

        public void setStringBuilder​(java.lang.StringBuilder sb)
        Sets the StringBuilder to be used to capture debug information for the current Thread.
      • transformationsByTransformer

        public java.lang.String transformationsByTransformer​(java.lang.String transformerName,
                                                             boolean toString,
                                                             boolean format42,
                                                             java.lang.String use)
        Returns a String and /or debug that provides a list of supported transformations for each transformer.
        Parameters:
        transformerName - restricts the list to one transformer. Unrestricted if null.
        toString - indicates that a String value should be returned in addition to any debug.
        format42 - indicates the old 4.1.4 format should be used which did not order the transformers and only included top level transformers.
        use - to which the transformation will be put (such as "Index", "Preview", null).
      • transformationsByExtension

        public java.lang.String transformationsByExtension​(java.lang.String sourceExtension,
                                                           java.lang.String targetExtension,
                                                           boolean toString,
                                                           boolean format42,
                                                           boolean onlyNonDeterministic,
                                                           java.lang.String use)
        Returns a String and /or debug that provides a list of supported transformations sorted by source and target mimetype extension.
        Parameters:
        sourceExtension - restricts the list to one source extension. Unrestricted if null.
        targetExtension - restricts the list to one target extension. Unrestricted if null.
        toString - indicates that a String value should be returned in addition to any debug.
        format42 - indicates the new 4.2 rather than older 4.1.4 format should be used. The 4.1.4 format did not order the transformers or mimetypes and only included top level transformers.
        onlyNonDeterministic - if true only report transformations where there is more than one transformer available with the same priority.
        use - to which the transformation will be put (such as "Index", "Preview", null).
      • getSourceMimetypes

        public java.util.Collection<java.lang.String> getSourceMimetypes​(java.lang.String sourceExtension)
        Returns a collection of mimetypes ordered by extension, but unlike the version in MimetypeService throws an exception if the sourceExtension is supplied but does not match a mimetype.
        Parameters:
        sourceExtension - to restrict the collection to one entry
        Throws:
        java.lang.IllegalArgumentException - if there is no match. The message indicates this.
      • getTargetMimetypes

        public java.util.Collection<java.lang.String> getTargetMimetypes​(java.lang.String sourceExtension,
                                                                         java.lang.String targetExtension,
                                                                         java.util.Collection<java.lang.String> sourceMimetypes)
        Identical to getSourceMimetypes for the target, but avoids doing the look up if the sourceExtension is the same as the tragetExtension, so will have the same result.
        Parameters:
        sourceExtension - used to restrict the sourceMimetypes
        targetExtension - to restrict the collection to one entry
        sourceMimetypes - that match the sourceExtension
        Throws:
        java.lang.IllegalArgumentException - if there is no match. The message indicates this.
      • getFileName

        public java.lang.String getFileName​(TransformationOptions options,
                                            boolean firstLevel,
                                            long sourceSize)
      • ms

        public java.lang.String ms​(long time)
      • fileSize

        public java.lang.String fileSize​(long size)
      • sortTransformersByName

        public java.util.Collection<ContentTransformer> sortTransformersByName​(java.lang.String transformerName)
        Returns a sorted list of all transformers sorted by name.
        Parameters:
        transformerName - to restrict the collection to one entry
        Returns:
        a new Collection of sorted transformers
        Throws:
        java.lang.IllegalArgumentException - if transformerName is not found.
      • testTransform

        public java.lang.String testTransform​(java.lang.String sourceExtension,
                                              java.lang.String targetExtension,
                                              java.lang.String use)
      • testTransform

        public java.lang.String testTransform​(java.lang.String transformerName,
                                              java.lang.String sourceExtension,
                                              java.lang.String targetExtension,
                                              java.lang.String use)
      • getTestFileExtensionsAndMimetypes

        public java.lang.String[] getTestFileExtensionsAndMimetypes()