Class AbstractContentTransformer
- java.lang.Object
-
- org.alfresco.repo.content.transform.AbstractContentTransformer
-
- All Implemented Interfaces:
ContentWorker,ContentTransformer,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware
@Deprecated public abstract class AbstractContentTransformer extends java.lang.Object implements ContentTransformer, org.springframework.beans.factory.BeanNameAware
Deprecated.Deprecated since 3.0. The abstract base class org.alfresco.repo.content.transform.AbstractContentTransformer2 should now be used instead.Provides basic services forContentTransformerimplementations.This class maintains the performance measures for the transformers as well, making sure that there is an extra penalty for transformers that fail regularly.
- Author:
- Derek Hulley
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractContentTransformer()Deprecated.All transformers start with an average transformation time of 0.0ms.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckReliability(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer)Deprecated.Convenience method to check the reliability of a transformationbooleanequals(java.lang.Object obj)Deprecated.java.lang.StringgetBeanName()Deprecated.Returns the Spring bean name.protected java.util.List<ContentTransformerRegistry.TransformationKey>getExplicitTransformations()Deprecated.longgetMaxSourceSizeKBytes(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Always returns-1to indicate an unlimited size.protected java.lang.StringgetMimetype(org.alfresco.service.cmr.repository.ContentAccessor content)Deprecated.Convenience to fetch and check the mimetype for the given contentprotected org.alfresco.service.cmr.repository.MimetypeServicegetMimetypeService()Deprecated.java.lang.StringgetName()Deprecated.Returns transformer name.protected abstract doublegetReliability(java.lang.String sourceMimetype, java.lang.String targetMimetype)Deprecated.Added for backward compatibility of existing content transformerslonggetTransformationTime()Deprecated.longgetTransformationTime(java.lang.String sourceMimetype, java.lang.String targetMimetype)Deprecated.Provides an estimate, usually a worst case guess, of how long a transformation will take.inthashCode()Deprecated.booleanisExplicitTransformation(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.booleanisTransformable(java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Indicates whether the provided source mimetype can be transformed into the target mimetype with the options specified by this content transformer.booleanisTransformable(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.use version with extra sourceSize parameter.booleanisTransformableMimetype(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Checks the supplied mimetypes are supported by calling the deprecatedisTransformable(String, String, TransformationOptions)method.booleanisTransformableSize(java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Always returnstrueto indicate size is not an issue.protected voidrecordTime(long transformationTime)Deprecated.Records and updates the average transformation time for this transformer.voidregister()Deprecated.Registers this instance with theregistryif it is present.voidsetBeanName(java.lang.String beanName)Deprecated.Sets the Spring bean name.voidsetExplicitTransformations(java.util.List<ContentTransformerRegistry.TransformationKey> explicitTransformations)Deprecated.Set the transformations that this transformer can do regardless of what it returns via the reliability check.voidsetMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)Deprecated.Helper setter of the mimetype service.voidsetRegistry(ContentTransformerRegistry registry)Deprecated.The registry to auto-register withjava.lang.StringtoString()Deprecated.voidtransform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer)Deprecated.voidtransform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, java.util.Map<java.lang.String,java.lang.Object> options)Deprecated.Performs the following: Times the transformation Ensures that the transformation is allowed Calls the subclass implementation oftransformInternal(ContentReader, ContentWriter, Map)Transforms any exceptions generated Logs a successful transformation Subclass need only be concerned with performing the transformation.voidtransform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)Deprecated.Transforms the content provided by the reader and source mimetype to the writer and target mimetype with the provided transformation options.protected abstract voidtransformInternal(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, java.util.Map<java.lang.String,java.lang.Object> options)Deprecated.Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformer
getComments
-
-
-
-
Method Detail
-
setRegistry
public void setRegistry(ContentTransformerRegistry registry)
Deprecated.The registry to auto-register with- Parameters:
registry- the transformer registry
-
setMimetypeService
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
Deprecated.Helper setter of the mimetype service. This is not always required.- Parameters:
mimetypeService- MimetypeService
-
getMimetypeService
protected org.alfresco.service.cmr.repository.MimetypeService getMimetypeService()
Deprecated.- Returns:
- Returns the mimetype helper
-
getExplicitTransformations
protected java.util.List<ContentTransformerRegistry.TransformationKey> getExplicitTransformations()
Deprecated.- Returns:
- Returns the explicit transformations that were enabled for this transformer
-
setExplicitTransformations
public void setExplicitTransformations(java.util.List<ContentTransformerRegistry.TransformationKey> explicitTransformations)
Deprecated.Set the transformations that this transformer can do regardless of what it returns via the reliability check.- Parameters:
explicitTransformations- explicit key mappings
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toStringin classjava.lang.Object
-
register
public void register()
Deprecated.Registers this instance with theregistryif it is present.
-
getMimetype
protected java.lang.String getMimetype(org.alfresco.service.cmr.repository.ContentAccessor content)
Deprecated.Convenience to fetch and check the mimetype for the given content- Parameters:
content- the reader/writer for the content- Returns:
- Returns the mimetype for the content
- Throws:
org.alfresco.error.AlfrescoRuntimeException- if the content doesn't have a mimetype
-
getReliability
protected abstract double getReliability(java.lang.String sourceMimetype, java.lang.String targetMimetype)Deprecated.Added for backward compatibility of existing content transformers- Parameters:
sourceMimetype- the source mimetypetargetMimetype- the target mimetype- Returns:
- double the reliability value of the content transformer ranging from 0 to 1
-
checkReliability
protected void checkReliability(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer)Deprecated.Convenience method to check the reliability of a transformation- Parameters:
reader- ContentReaderwriter- ContentWriter- Throws:
org.alfresco.error.AlfrescoRuntimeException- if the reliability isn't > 0
-
isTransformable
public boolean isTransformable(java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Indicates whether the provided source mimetype can be transformed into the target mimetype with the options specified by this content transformer.Implementation calls the deprecated overloaded method without the sourceSize parameter. Note: source size checked has not been added to this deprecated class.
- Specified by:
isTransformablein interfaceContentTransformer- Parameters:
sourceMimetype- the source mimetypesourceSize- the size (bytes) of the source. If negative it is unknown.targetMimetype- the target mimetypeoptions- the transformation options- Returns:
- boolean true if this content transformer can satify the mimetypes and options specified, false otherwise
-
isTransformable
public boolean isTransformable(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.use version with extra sourceSize parameter.- Specified by:
isTransformablein interfaceContentTransformer
-
isTransformableMimetype
public boolean isTransformableMimetype(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Checks the supplied mimetypes are supported by calling the deprecatedisTransformable(String, String, TransformationOptions)method.- Specified by:
isTransformableMimetypein interfaceContentTransformer- Parameters:
sourceMimetype- the source mimetypetargetMimetype- the target mimetypeoptions- the transformation options- Returns:
- boolean true if this content transformer can satify the mimetypes, false otherwise
-
isTransformableSize
public boolean isTransformableSize(java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Always returnstrueto indicate size is not an issue.- Specified by:
isTransformableSizein interfaceContentTransformer- Parameters:
sourceMimetype- the source mimetypesourceSize- the size (bytes) of the source. If negative it is unknown.targetMimetype- the target mimetypeoptions- the transformation options- Returns:
- boolean true if this content transformer can satify the mimetypes, false otherwise
-
getMaxSourceSizeKBytes
public long getMaxSourceSizeKBytes(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.Always returns-1to indicate an unlimited size.- Specified by:
getMaxSourceSizeKBytesin interfaceContentTransformer- Returns:
- 0 if the the transformation is disabled, -1 if there is no limit, otherwise the size in KBytes.
-
isExplicitTransformation
public boolean isExplicitTransformation(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)Deprecated.- Specified by:
isExplicitTransformationin interfaceContentTransformer- Parameters:
sourceMimetype- the source mimetypetargetMimetype- the target mimetypeoptions- the transformation options- Returns:
- boolean true if it is an explicit transformation, false otherwise
- See Also:
ContentTransformer.isTransformable(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)
-
transformInternal
protected abstract void transformInternal(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, java.util.Map<java.lang.String,java.lang.Object> options) throws java.lang.ExceptionDeprecated.Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.- Parameters:
reader- the source of the content to transformwriter- the target to which to write the transformed contentoptions- a map of options to use when performing the transformation. The map will never be null.- Throws:
java.lang.Exception- exceptions will be handled by this class - subclasses can throw anything
-
transform
public final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer) throws org.alfresco.service.cmr.repository.ContentIOExceptionDeprecated.- Specified by:
transformin interfaceContentTransformer- Throws:
org.alfresco.service.cmr.repository.ContentIOException- See Also:
transform(ContentReader, ContentWriter, Map),transformInternal(ContentReader, ContentWriter, Map)
-
transform
public final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options) throws org.alfresco.service.cmr.repository.ContentIOExceptionDeprecated.Description copied from interface:ContentTransformerTransforms the content provided by the reader and source mimetype to the writer and target mimetype with the provided transformation options.The transformation viability can be determined by an up front call to
ContentTransformer.isTransformable(String, String, TransformationOptions).The source and target mimetypes must be available on the
ContentAccessor.getMimetype()methods of both the reader and the writer.Both reader and writer will be closed after the transformation completes.
The provided options can be null.
- Specified by:
transformin interfaceContentTransformer- Parameters:
reader- the source of the contentwriter- the destination of the transformed contentoptions- transformation options, these can be null- Throws:
org.alfresco.service.cmr.repository.ContentIOException- if an IO exception occurs- See Also:
ContentTransformer.transform(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions)
-
transform
public final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, java.util.Map<java.lang.String,java.lang.Object> options) throws org.alfresco.service.cmr.repository.ContentIOExceptionDeprecated.Performs the following:- Times the transformation
- Ensures that the transformation is allowed
- Calls the subclass implementation of
transformInternal(ContentReader, ContentWriter, Map) - Transforms any exceptions generated
- Logs a successful transformation
If the options provided are null, then an empty map will be created.
- Specified by:
transformin interfaceContentTransformer- Parameters:
reader- the source of the contentwriter- the destination of the transformed contentoptions- options to pass to the transformer. These are transformer dependent and may be null.- Throws:
org.alfresco.service.cmr.repository.ContentIOException- if an IO exception occurs
-
getTransformationTime
public long getTransformationTime()
Deprecated.- Specified by:
getTransformationTimein interfaceContentTransformer- Returns:
- Returns the calculated running average of the current transformations
-
getTransformationTime
public long getTransformationTime(java.lang.String sourceMimetype, java.lang.String targetMimetype)Deprecated.Description copied from interface:ContentTransformerProvides an estimate, usually a worst case guess, of how long a transformation will take. Null mimetype values provide the overall value for the transformer.This method is used to determine, up front, which of a set of equally reliant transformers will be used for a specific transformation.
- Specified by:
getTransformationTimein interfaceContentTransformer- Parameters:
sourceMimetype- the source mimetypetargetMimetype- the target mimetype- Returns:
- Returns the approximate number of milliseconds per transformation
-
recordTime
protected final void recordTime(long transformationTime)
Deprecated.Records and updates the average transformation time for this transformer.Subclasses should call this after every transformation in order to keep the running average of the transformation times up to date.
This method is thread-safe. The time spent in this method is negligible so the impact will be minor.
- Parameters:
transformationTime- the time it took to perform the transformation. The value may be 0.
-
setBeanName
public void setBeanName(java.lang.String beanName)
Deprecated.Sets the Spring bean name.- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
getBeanName
public java.lang.String getBeanName()
Deprecated.Returns the Spring bean name.
-
getName
public java.lang.String getName()
Deprecated.Returns transformer name. Uses the Spring bean name, but if null uses the class name.- Specified by:
getNamein interfaceContentTransformer
-
hashCode
public int hashCode()
Deprecated.- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Deprecated.- Overrides:
equalsin classjava.lang.Object
-
-