Class TransformerDebug
- java.lang.Object
-
- org.alfresco.repo.content.transform.TransformerDebug
-
- Direct Known Subclasses:
AdminUiTransformerDebug
public class TransformerDebug extends Object
Debugs 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).- Author:
- Alan Davis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classTransformerDebug.Callstatic interfaceTransformerDebug.ExtensionLookupprotected static classTransformerDebug.Frameprotected static classTransformerDebug.ThreadInfo
-
Field Summary
Fields Modifier and Type Field Description protected TransformerDebug.ExtensionLookupextensionLookupprotected static StringFINISHED_INstatic StringMIMETYPE_METADATA_EMBEDstatic StringMIMETYPE_METADATA_EXTRACTprotected MimetypeServicemimetypeServiceprotected org.apache.commons.logging.LogmultiLineLogprotected static StringNO_TRANSFORMERSprotected NodeServicenodeServicestatic StringSOURCE_ENCODINGstatic StringSOURCE_NODE_REFstatic StringTARGET_ENCODINGstatic StringTIMEOUTstatic StringTRANSFORM_NAMESPACEprotected static StringTRANSFORM_SERVICE_NAME
-
Constructor Summary
Constructors Constructor Description TransformerDebug()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voiddebug(String message)Log a message prefixed with the current transformation reference.voiddebug(String message, 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(String sourceMimetype, long sourceSize, NodeRef sourceNodeRef, int contentHashcode, String filename, String targetMimetype, Map<String,String> options, String renditionName)Debugs a request to the Transform ServicevoiddebugTransformServiceResponse(long requested, int id, String msg, Collection<String> debugLines)Debugs a response to the Transform ServicevoiddebugTransformServiceResponsePostConsume(boolean suppressFinish)Debugs a response to the Transform ServicebooleandebugTransformServiceResponsePreConsume(long requested, int id, String msg, Collection<String> debugLines)Debugs a response to the Transform ServicevoiddebugUsingPreviousReference(String message)Log a message prefixed with the previous transformation reference, used by this Thread.StringfileSize(long size)StringgetFilename(NodeRef sourceNodeRef, boolean firstLevel)protected StringgetMimetypeExt(String mimetype)StringgetRenditionName(String renditionName)protected StringgetSourceAndTargetExt(String sourceMimetype, String targetMimetype)StringBuildergetStringBuilder()Returns the current StringBuilder (if any) being used to capture debug information for the current Thread.booleanisEnabled()Indicates if any logging is required.static booleanisMetadataEmbedMimetype(String targetMimetype)static booleanisMetadataExtractMimetype(String targetMimetype)protected voidlog(String message)protected voidlog(String message, boolean debug)protected voidlogBasicDetails(TransformerDebug.Frame frame, long sourceSize, Map<String,String> options, String renditionName, String message, boolean firstLevel)Stringms(long time)protected intpop(TransformerDebug.Call callType, boolean suppressFinish, boolean suppressChecking)voidpopMisc()Removes a frame from the stack.voidpopTransform()Called after performing a transform.voidpushMisc()Adds a new level to the stack to get a new request number or nesting number.voidpushTransform(String transformerName, String fromUrl, String sourceMimetype, String targetMimetype, long sourceSize, Map<String,String> options, String renditionName, NodeRef sourceNodeRef)static StringreplaceWithMetadataExtensionIfEmbedOrExtract(String targetMimetype, String sourceExtension, String targetExtension)<T extends 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.static booleansetDebugOutput(boolean debugOutput)Enable or disable debug log output.voidsetExtensionLookup(TransformerDebug.ExtensionLookup extensionLookup)voidsetMimetypeService(MimetypeService mimetypeService)voidsetNodeService(NodeService nodeService)voidsetPreviousTransformId(int id)voidsetStringBuilder(StringBuilder sb)Sets the StringBuilder to be used to capture debug information for the current Thread.voidsetTransformerDebugLog(org.apache.commons.logging.Log transformerDebugLog)voidsetTransformerLog(org.apache.commons.logging.Log transformerLog)protected Stringspaces(int i)static StringtoString(Map<String,String> options)Obtains a String for log messages.
-
-
-
Field Detail
-
TIMEOUT
public static final String TIMEOUT
- See Also:
- Constant Field Values
-
SOURCE_ENCODING
public static final String SOURCE_ENCODING
- See Also:
- Constant Field Values
-
SOURCE_NODE_REF
public static final String SOURCE_NODE_REF
- See Also:
- Constant Field Values
-
TARGET_ENCODING
public static final String TARGET_ENCODING
- See Also:
- Constant Field Values
-
TRANSFORM_NAMESPACE
public static final String TRANSFORM_NAMESPACE
- See Also:
- Constant Field Values
-
MIMETYPE_METADATA_EXTRACT
public static final String MIMETYPE_METADATA_EXTRACT
- See Also:
- Constant Field Values
-
MIMETYPE_METADATA_EMBED
public static final String MIMETYPE_METADATA_EMBED
- See Also:
- Constant Field Values
-
FINISHED_IN
protected static final String FINISHED_IN
- See Also:
- Constant Field Values
-
NO_TRANSFORMERS
protected static final String NO_TRANSFORMERS
- See Also:
- Constant Field Values
-
TRANSFORM_SERVICE_NAME
protected static final String TRANSFORM_SERVICE_NAME
- See Also:
- Constant Field Values
-
extensionLookup
protected TransformerDebug.ExtensionLookup extensionLookup
-
multiLineLog
protected org.apache.commons.logging.Log multiLineLog
-
nodeService
protected NodeService nodeService
-
mimetypeService
protected MimetypeService mimetypeService
-
-
Method Detail
-
setExtensionLookup
public void setExtensionLookup(TransformerDebug.ExtensionLookup extensionLookup)
-
setTransformerLog
public void setTransformerLog(org.apache.commons.logging.Log transformerLog)
-
setTransformerDebugLog
public void setTransformerDebugLog(org.apache.commons.logging.Log transformerDebugLog)
-
setNodeService
public void setNodeService(NodeService nodeService)
-
setMimetypeService
public void setMimetypeService(MimetypeService mimetypeService)
-
setPreviousTransformId
public void setPreviousTransformId(int id)
-
pushTransform
public void pushTransform(String transformerName, String fromUrl, String sourceMimetype, String targetMimetype, long sourceSize, Map<String,String> options, String renditionName, 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.
-
logBasicDetails
protected void logBasicDetails(TransformerDebug.Frame frame, long sourceSize, Map<String,String> options, String renditionName, String message, boolean firstLevel)
-
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.
-
pop
protected int pop(TransformerDebug.Call callType, boolean suppressFinish, boolean suppressChecking)
-
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(String message)
Log a message prefixed with the current transformation reference.- Parameters:
message-
-
debugUsingPreviousReference
public void debugUsingPreviousReference(String message)
Log a message prefixed with the previous transformation reference, used by this Thread.- Parameters:
message-
-
debug
public void debug(String message, 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-
-
log
protected void log(String message)
-
log
protected void log(String message, boolean debug)
-
setCause
public <T extends 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 StringBuilder getStringBuilder()
Returns the current StringBuilder (if any) being used to capture debug information for the current Thread.
-
setStringBuilder
public void setStringBuilder(StringBuilder sb)
Sets the StringBuilder to be used to capture debug information for the current Thread.
-
getSourceAndTargetExt
protected String getSourceAndTargetExt(String sourceMimetype, String targetMimetype)
-
replaceWithMetadataExtensionIfEmbedOrExtract
public static String replaceWithMetadataExtensionIfEmbedOrExtract(String targetMimetype, String sourceExtension, String targetExtension)
-
spaces
protected String spaces(int i)
-
ms
public String ms(long time)
-
fileSize
public String fileSize(long size)
-
debugTransformServiceRequest
public int debugTransformServiceRequest(String sourceMimetype, long sourceSize, NodeRef sourceNodeRef, int contentHashcode, String filename, String targetMimetype, Map<String,String> options, String renditionName)
Debugs a request to the Transform Service
-
isMetadataExtractMimetype
public static boolean isMetadataExtractMimetype(String targetMimetype)
-
isMetadataEmbedMimetype
public static boolean isMetadataEmbedMimetype(String targetMimetype)
-
debugTransformServiceResponse
public void debugTransformServiceResponse(long requested, int id, String msg, Collection<String> debugLines)Debugs a response to the Transform Service
-
debugTransformServiceResponsePreConsume
public boolean debugTransformServiceResponsePreConsume(long requested, int id, String msg, Collection<String> debugLines)Debugs a response to the Transform Service
-
debugTransformServiceResponsePostConsume
public void debugTransformServiceResponsePostConsume(boolean suppressFinish)
Debugs a response to the Transform Service
-
-