@AlfrescoPublicApi public class TransformerDebug extends Object
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.2
indicating 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 and popTransform()
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) and popAvailable()
are called.
Constructor and 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
|
Modifier and Type | Method and Description |
---|---|
void |
activeTransformer(int mimetypePairCount,
ContentTransformer transformer,
String sourceMimetype,
String targetMimetype,
long maxSourceSizeKBytes,
boolean firstMimetypePair) |
void |
activeTransformer(String sourceMimetype,
String targetMimetype,
int transformerCount,
ContentTransformer transformer,
long maxSourceSizeKBytes,
boolean firstTransformer) |
void |
availableTransformers(List<ContentTransformer> transformers,
long sourceSize,
TransformationOptions options,
String calledFrom)
Called once all available transformers have been identified.
|
void |
blacklistTransform(ContentTransformer transformer,
String sourceMimetype,
String targetMimetype,
TransformationOptions options)
Called when a transformer has been ignored because of a blacklist entry.
|
void |
debug(String message)
Log a message prefixed with the current transformation reference.
|
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.
|
String |
fileSize(long size) |
String |
getFileName(TransformationOptions options,
boolean firstLevel,
long sourceSize) |
Collection<String> |
getSourceMimetypes(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.
|
StringBuilder |
getStringBuilder()
Returns the current StringBuilder (if any) being used to capture debug
information for the current Thread.
|
Collection<String> |
getTargetMimetypes(String sourceExtension,
String targetExtension,
Collection<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.
|
String[] |
getTestFileExtensionsAndMimetypes() |
void |
inactiveTransformer(ContentTransformer transformer) |
boolean |
isEnabled()
Indicates if any logging is required.
|
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(String fromUrl,
String sourceMimetype,
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,
String fromUrl,
String sourceMimetype,
String targetMimetype,
long sourceSize,
TransformationOptions options)
Called prior to performing a transform.
|
<T extends Throwable> |
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(StringBuilder sb)
Sets the StringBuilder to be used to capture debug information for the
current Thread.
|
Collection<ContentTransformer> |
sortTransformersByName(String transformerName)
Returns a sorted list of all transformers sorted by name.
|
String |
testTransform(String sourceExtension,
String targetExtension,
String use) |
String |
testTransform(String transformerName,
String sourceExtension,
String targetExtension,
String use) |
String |
transformationsByExtension(String sourceExtension,
String targetExtension,
boolean toString,
boolean format42,
boolean onlyNonDeterministic,
String use)
Returns a String and /or debug that provides a list of supported transformations
sorted by source and target mimetype extension.
|
String |
transformationsByTransformer(String transformerName,
boolean toString,
boolean format42,
String use)
Returns a String and /or debug that provides a list of supported transformations for each
transformer.
|
void |
unavailableTransformer(ContentTransformer transformer,
String sourceMimetype,
String targetMimetype,
long maxSourceSizeKBytes)
Called to identify a transformer that cannot be used during working out
available transformers.
|
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)
public void setContentService(ContentService contentService)
public void pushAvailable(String fromUrl, String sourceMimetype, String targetMimetype, TransformationOptions options)
public void blacklistTransform(ContentTransformer transformer, String sourceMimetype, String targetMimetype, TransformationOptions options)
public void pushTransform(ContentTransformer transformer, String fromUrl, String sourceMimetype, String targetMimetype, long sourceSize, TransformationOptions options)
public void pushMisc()
public void pushIsTransformableSize(ContentTransformer transformer)
public void unavailableTransformer(ContentTransformer transformer, String sourceMimetype, String targetMimetype, long maxSourceSizeKBytes)
public void availableTransformers(List<ContentTransformer> transformers, long sourceSize, TransformationOptions options, String calledFrom)
public void inactiveTransformer(ContentTransformer transformer)
public void activeTransformer(int mimetypePairCount, ContentTransformer transformer, String sourceMimetype, String targetMimetype, long maxSourceSizeKBytes, boolean firstMimetypePair)
public void activeTransformer(String sourceMimetype, String targetMimetype, int transformerCount, ContentTransformer transformer, long maxSourceSizeKBytes, boolean firstTransformer)
public void popAvailable()
public void popTransform()
public void popMisc()
public void popIsTransformableSize()
public boolean isEnabled()
public static boolean setDebugOutput(boolean debugOutput)
debugOutput
- if true
both debug and trace is generated. Otherwise all output is trace.public void debug(String message)
message
- public void debug(String message, Throwable t)
message
- public <T extends Throwable> T setCause(T t)
public StringBuilder getStringBuilder()
public void setStringBuilder(StringBuilder sb)
public String transformationsByTransformer(String transformerName, boolean toString, boolean format42, String use)
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).public String transformationsByExtension(String sourceExtension, String targetExtension, boolean toString, boolean format42, boolean onlyNonDeterministic, String use)
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).public Collection<String> getSourceMimetypes(String sourceExtension)
sourceExtension
- to restrict the collection to one entryIllegalArgumentException
- if there is no match. The message indicates this.public Collection<String> getTargetMimetypes(String sourceExtension, String targetExtension, Collection<String> sourceMimetypes)
sourceExtension
- used to restrict the sourceMimetypestargetExtension
- to restrict the collection to one entrysourceMimetypes
- that match the sourceExtensionIllegalArgumentException
- if there is no match. The message indicates this.public String getFileName(TransformationOptions options, boolean firstLevel, long sourceSize)
public String ms(long time)
public String fileSize(long size)
public Collection<ContentTransformer> sortTransformersByName(String transformerName)
transformerName
- to restrict the collection to one entryIllegalArgumentException
- if transformerName is not found.public String testTransform(String sourceExtension, String targetExtension, String use)
public String testTransform(String transformerName, String sourceExtension, String targetExtension, String use)
public String[] getTestFileExtensionsAndMimetypes()
Copyright © 2005–2017 Alfresco Software. All rights reserved.