Class TransformerDebug
- java.lang.Object
-
- org.alfresco.repo.content.transform.TransformerDebug
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class TransformerDebug extends java.lang.Object implements org.springframework.context.ApplicationContextAwareDebugs transformers selection and activity.As transformations are frequently composed of lower level transformations, log messages include a prefix to identify the transformation. A numeric dot notation is used (such as
123.1.2indicating the second third level transformation of the 123rd top level transformation).In order to track of the nesting of transforms, this class has a stack to represent the Transformers. Each Transformer calls
pushTransform(org.alfresco.repo.content.transform.ContentTransformer, java.lang.String, java.lang.String, java.lang.String, long, org.alfresco.service.cmr.repository.TransformationOptions)at the start of a transform andpopTransform()at the end. However the top level transform may be selected from a list of available transformers. To record this activity,pushAvailable(java.lang.String, java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions),unavailableTransformer(org.alfresco.repo.content.transform.ContentTransformer, java.lang.String, java.lang.String, long)(to record the reason a transformer is rejected),availableTransformers(java.util.List<org.alfresco.repo.content.transform.ContentTransformer>, long, org.alfresco.service.cmr.repository.TransformationOptions, java.lang.String)(to record the available transformers) andpopAvailable()are called.- Author:
- Alan Davis
-
-
Constructor Summary
Constructors Constructor Description TransformerDebug()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidactiveTransformer(int mimetypePairCount, ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes, boolean firstMimetypePair)Deprecated.voidactiveTransformer(java.lang.String sourceMimetype, java.lang.String targetMimetype, int transformerCount, ContentTransformer transformer, long maxSourceSizeKBytes, boolean firstTransformer)Deprecated.voidafterPropertiesSet()voidavailableTransformers(java.util.List<ContentTransformer> transformers, long sourceSize, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, java.lang.String calledFrom)Deprecated.voidavailableTransformers(java.util.List<ContentTransformer> transformers, long sourceSize, TransformationOptions options, java.lang.String calledFrom)Deprecated.voidblacklistTransform(ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.voiddebug(java.lang.String message)Log a message prefixed with the current transformation reference.voiddebug(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.intdebugTransformServiceRequest(java.lang.String sourceMimetype, long sourceSize, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, int contentHashcode, java.lang.String fileName, java.lang.String targetMimetype, java.lang.String renditionName)Debugs a request to the Transform ServicevoiddebugTransformServiceResponse(org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, int contentHashcode, long requested, int seq, java.lang.String sourceExt, java.lang.String targetExt, java.lang.String msg)Debugs a response to the Transform Servicejava.lang.StringfileSize(long size)java.lang.StringgetFileName(org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, boolean firstLevel, long sourceSize)java.lang.StringgetFileName(TransformationOptions options, boolean firstLevel, long sourceSize)Deprecated.RenditionDefinitionRegistry2ImplgetRenditionDefinitionRegistry2Impl()RepositorygetRepositoryHelper()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.StringBuildergetStringBuilder()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()TransactionServicegetTransactionService()voidinactiveTransformer(ContentTransformer transformer)Deprecated.booleanisEnabled()Indicates if any logging is required.java.lang.Stringms(long time)voidpopAvailable()Called after working out what transformers are available and any resulting transform has been called.voidpopIsTransformableSize()Called after returning from a nested isTransformable.voidpopMisc()Removes a frame from the stack.voidpopTransform()Called after performing a transform.voidpushAvailable(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef)Deprecated.voidpushAvailable(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.voidpushIsTransformableSize(ContentTransformer transformer)Deprecated.voidpushMisc()Adds a new level to the stack to get a new request number or nesting number.voidpushTransform(java.lang.String transformerName, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef)voidpushTransform(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef)Deprecated.voidpushTransform(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, TransformationOptions options)Deprecated.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)<T extends java.lang.Throwable>
TsetCause(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.voidsetContentService(ContentService contentService)static booleansetDebugOutput(boolean debugOutput)Enable or disable debug log output.voidsetMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)voidsetNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)voidsetRenditionDefinitionRegistry2(RenditionDefinitionRegistry2Impl renditionDefinitionRegistry2)voidsetRepositoryHelper(Repository repositoryHelper)voidsetStringBuilder(java.lang.StringBuilder sb)Sets the StringBuilder to be used to capture debug information for the current Thread.voidsetTransactionService(TransactionService transactionService)voidsetTransformClient(TransformClient transformClient)voidsetTransformerConfig(TransformerConfig transformerConfig)voidsetTransformerDebugLog(org.apache.commons.logging.Log transformerDebugLog)voidsetTransformerLog(org.apache.commons.logging.Log transformerLog)voidsetTransformerRegistry(ContentTransformerRegistry transformerRegistry)java.util.Collection<ContentTransformer>sortTransformersByName(java.lang.String transformerName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.java.lang.StringtestTransform(java.lang.String sourceExtension, java.lang.String targetExtension, java.lang.String renditionName)java.lang.StringtestTransform(java.lang.String transformerName, java.lang.String sourceExtension, java.lang.String targetExtension, java.lang.String renditionName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.java.lang.StringtransformationsByExtension(java.lang.String sourceExtension, java.lang.String targetExtension, boolean toString, boolean format42, boolean onlyNonDeterministic, java.lang.String renditionName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.java.lang.StringtransformationsByTransformer(java.lang.String transformerName, boolean toString, boolean format42, java.lang.String renditionName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.voidunavailableTransformer(ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes)Deprecated.
-
-
-
Method Detail
-
setTransformerLog
public void setTransformerLog(org.apache.commons.logging.Log transformerLog)
-
setTransformerDebugLog
public void setTransformerDebugLog(org.apache.commons.logging.Log transformerDebugLog)
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
-
setMimetypeService
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
-
setTransformerRegistry
public void setTransformerRegistry(ContentTransformerRegistry transformerRegistry)
-
setTransformerConfig
public void setTransformerConfig(TransformerConfig transformerConfig)
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
setContentService
public void setContentService(ContentService contentService)
-
setTransformClient
public void setTransformClient(TransformClient transformClient)
-
getRepositoryHelper
public Repository getRepositoryHelper()
-
setRepositoryHelper
public void setRepositoryHelper(Repository repositoryHelper)
-
getTransactionService
public TransactionService getTransactionService()
-
setTransactionService
public void setTransactionService(TransactionService transactionService)
-
getRenditionDefinitionRegistry2Impl
public RenditionDefinitionRegistry2Impl getRenditionDefinitionRegistry2Impl()
-
setRenditionDefinitionRegistry2
public void setRenditionDefinitionRegistry2(RenditionDefinitionRegistry2Impl renditionDefinitionRegistry2)
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Throws:
java.lang.Exception
-
pushAvailable
@Deprecated public void pushAvailable(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.
-
pushAvailable
@Deprecated public void pushAvailable(java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef)Deprecated.Called prior to working out what transformers are available.
-
blacklistTransform
@Deprecated public void blacklistTransform(ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
Deprecated.Called when a transformer has been ignored because of a blacklist entry.
-
pushTransform
@Deprecated public void pushTransform(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, TransformationOptions options)
Deprecated.
-
pushTransform
@Deprecated public void pushTransform(ContentTransformer transformer, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef)
Deprecated.Called prior to performing a transform.
-
pushTransform
public void pushTransform(java.lang.String transformerName, java.lang.String fromUrl, java.lang.String sourceMimetype, java.lang.String targetMimetype, long sourceSize, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef)
-
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
@Deprecated public void pushIsTransformableSize(ContentTransformer transformer)
Deprecated.Called prior to calling a nested isTransformable.
-
unavailableTransformer
@Deprecated public void unavailableTransformer(ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes)
Deprecated.Called to identify a transformer that cannot be used during working out available transformers.
-
availableTransformers
@Deprecated public void availableTransformers(java.util.List<ContentTransformer> transformers, long sourceSize, TransformationOptions options, java.lang.String calledFrom)
Deprecated.
-
availableTransformers
@Deprecated public void availableTransformers(java.util.List<ContentTransformer> transformers, long sourceSize, java.lang.String renditionName, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, java.lang.String calledFrom)
Deprecated.Called once all available transformers have been identified.
-
inactiveTransformer
@Deprecated public void inactiveTransformer(ContentTransformer transformer)
Deprecated.
-
activeTransformer
@Deprecated public void activeTransformer(int mimetypePairCount, ContentTransformer transformer, java.lang.String sourceMimetype, java.lang.String targetMimetype, long maxSourceSizeKBytes, boolean firstMimetypePair)Deprecated.
-
activeTransformer
@Deprecated public void activeTransformer(java.lang.String sourceMimetype, java.lang.String targetMimetype, int transformerCount, ContentTransformer transformer, long maxSourceSizeKBytes, boolean firstTransformer)Deprecated.
-
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- iftrueboth 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
@Deprecated public java.lang.String transformationsByTransformer(java.lang.String transformerName, boolean toString, boolean format42, java.lang.String renditionName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.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.renditionName- to which the transformation will be put (such as "Index", "Preview", null).
-
transformationsByExtension
@Deprecated public java.lang.String transformationsByExtension(java.lang.String sourceExtension, java.lang.String targetExtension, boolean toString, boolean format42, boolean onlyNonDeterministic, java.lang.String renditionName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.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.renditionName- 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 sourceMimetypestargetExtension- to restrict the collection to one entrysourceMimetypes- that match the sourceExtension- Throws:
java.lang.IllegalArgumentException- if there is no match. The message indicates this.
-
getFileName
@Deprecated public java.lang.String getFileName(TransformationOptions options, boolean firstLevel, long sourceSize)
Deprecated.
-
getFileName
public java.lang.String getFileName(org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, boolean firstLevel, long sourceSize)
-
ms
public java.lang.String ms(long time)
-
fileSize
public java.lang.String fileSize(long size)
-
sortTransformersByName
@Deprecated public java.util.Collection<ContentTransformer> sortTransformersByName(java.lang.String transformerName)
Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.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.
-
debugTransformServiceRequest
public int debugTransformServiceRequest(java.lang.String sourceMimetype, long sourceSize, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, int contentHashcode, java.lang.String fileName, java.lang.String targetMimetype, java.lang.String renditionName)Debugs a request to the Transform Service
-
debugTransformServiceResponse
public void debugTransformServiceResponse(org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, int contentHashcode, long requested, int seq, java.lang.String sourceExt, java.lang.String targetExt, java.lang.String msg)Debugs a response to the Transform Service
-
testTransform
public java.lang.String testTransform(java.lang.String sourceExtension, java.lang.String targetExtension, java.lang.String renditionName)
-
testTransform
@Deprecated public java.lang.String testTransform(java.lang.String transformerName, java.lang.String sourceExtension, java.lang.String targetExtension, java.lang.String renditionName)Deprecated.The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
-
getTestFileExtensionsAndMimetypes
public java.lang.String[] getTestFileExtensionsAndMimetypes()
-
-