@Deprecated public abstract class AbstractContentTransformer extends Object implements ContentTransformer, org.springframework.beans.factory.BeanNameAware
ContentTransformer
implementations.
This class maintains the performance measures for the transformers as well, making sure that there is an extra penalty for transformers that fail regularly.
Modifier | Constructor and Description |
---|---|
protected |
AbstractContentTransformer()
Deprecated.
All transformers start with an average transformation time of 0.0ms.
|
Modifier and Type | Method and Description |
---|---|
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
|
boolean |
equals(Object obj)
Deprecated.
|
String |
getBeanName()
Deprecated.
Returns the Spring bean name.
|
protected List<ContentTransformerRegistry.TransformationKey> |
getExplicitTransformations()
Deprecated.
|
long |
getMaxSourceSizeKBytes(String sourceMimetype,
String targetMimetype,
TransformationOptions options)
Deprecated.
Always returns
-1 to indicate an unlimited size. |
protected String |
getMimetype(org.alfresco.service.cmr.repository.ContentAccessor content)
Deprecated.
Convenience to fetch and check the mimetype for the given content
|
protected org.alfresco.service.cmr.repository.MimetypeService |
getMimetypeService()
Deprecated.
|
String |
getName()
Deprecated.
Returns transformer name.
|
protected abstract double |
getReliability(String sourceMimetype,
String targetMimetype)
Deprecated.
Added for backward compatibility of existing content transformers
|
long |
getTransformationTime()
Deprecated.
|
long |
getTransformationTime(String sourceMimetype,
String targetMimetype)
Deprecated.
Provides an estimate, usually a worst case guess, of how long a transformation
will take.
|
int |
hashCode()
Deprecated.
|
boolean |
isExplicitTransformation(String sourceMimetype,
String targetMimetype,
TransformationOptions options)
Deprecated.
|
boolean |
isTransformable(String sourceMimetype,
long sourceSize,
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.
|
boolean |
isTransformable(String sourceMimetype,
String targetMimetype,
TransformationOptions options)
Deprecated.
use version with extra sourceSize parameter.
|
boolean |
isTransformableMimetype(String sourceMimetype,
String targetMimetype,
TransformationOptions options)
Deprecated.
Checks the supplied mimetypes are supported by calling the deprecated
isTransformable(String, String, TransformationOptions) method. |
boolean |
isTransformableSize(String sourceMimetype,
long sourceSize,
String targetMimetype,
TransformationOptions options)
Deprecated.
Always returns
true to indicate size is not an issue. |
protected void |
recordTime(long transformationTime)
Deprecated.
Records and updates the average transformation time for this transformer.
|
void |
register()
Deprecated.
Registers this instance with the
registry
if it is present. |
void |
setBeanName(String beanName)
Deprecated.
Sets the Spring bean name.
|
void |
setExplicitTransformations(List<ContentTransformerRegistry.TransformationKey> explicitTransformations)
Deprecated.
Set the transformations that this transformer can do regardless of what it returns
via the reliability check.
|
void |
setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
Deprecated.
Helper setter of the mimetype service.
|
void |
setRegistry(ContentTransformerRegistry registry)
Deprecated.
The registry to auto-register with
|
String |
toString()
Deprecated.
|
void |
transform(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.ContentWriter writer)
Deprecated.
|
void |
transform(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.ContentWriter writer,
Map<String,Object> options)
Deprecated.
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
Subclass need only be concerned with performing the transformation. |
void |
transform(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 void |
transformInternal(org.alfresco.service.cmr.repository.ContentReader reader,
org.alfresco.service.cmr.repository.ContentWriter writer,
Map<String,Object> options)
Deprecated.
Method to be implemented by subclasses wishing to make use of the common infrastructural code
provided by this class.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getComments
protected AbstractContentTransformer()
public void setRegistry(ContentTransformerRegistry registry)
registry
- the transformer registrypublic void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
mimetypeService
- MimetypeServiceprotected org.alfresco.service.cmr.repository.MimetypeService getMimetypeService()
protected List<ContentTransformerRegistry.TransformationKey> getExplicitTransformations()
public void setExplicitTransformations(List<ContentTransformerRegistry.TransformationKey> explicitTransformations)
explicitTransformations
- explicit key mappingspublic void register()
registry
if it is present.protected String getMimetype(org.alfresco.service.cmr.repository.ContentAccessor content)
content
- the reader/writer for the contentorg.alfresco.error.AlfrescoRuntimeException
- if the content doesn't have a mimetypeprotected abstract double getReliability(String sourceMimetype, String targetMimetype)
sourceMimetype
- the source mimetypetargetMimetype
- the target mimetypeprotected void checkReliability(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer)
reader
- ContentReaderwriter
- ContentWriterorg.alfresco.error.AlfrescoRuntimeException
- if the reliability isn't > 0public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options)
Implementation calls the deprecated overloaded method without the sourceSize parameter. Note: source size checked has not been added to this deprecated class.
isTransformable
in interface ContentTransformer
sourceMimetype
- the source mimetypesourceSize
- the size (bytes) of the source. If negative it is unknown.targetMimetype
- the target mimetypeoptions
- the transformation optionspublic boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
isTransformable
in interface ContentTransformer
public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options)
isTransformable(String, String, TransformationOptions)
method.isTransformableMimetype
in interface ContentTransformer
sourceMimetype
- the source mimetypetargetMimetype
- the target mimetypeoptions
- the transformation optionspublic boolean isTransformableSize(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options)
true
to indicate size is not an issue.isTransformableSize
in interface ContentTransformer
sourceMimetype
- the source mimetypesourceSize
- the size (bytes) of the source. If negative it is unknown.targetMimetype
- the target mimetypeoptions
- the transformation optionspublic long getMaxSourceSizeKBytes(String sourceMimetype, String targetMimetype, TransformationOptions options)
-1
to indicate an unlimited size.getMaxSourceSizeKBytes
in interface ContentTransformer
public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options)
isExplicitTransformation
in interface ContentTransformer
sourceMimetype
- the source mimetypetargetMimetype
- the target mimetypeoptions
- the transformation optionsContentTransformer.isTransformable(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)
protected abstract void transformInternal(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, Map<String,Object> options) throws Exception
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.Exception
- exceptions will be handled by this class - subclasses can throw anythingpublic final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer) throws org.alfresco.service.cmr.repository.ContentIOException
transform
in interface ContentTransformer
org.alfresco.service.cmr.repository.ContentIOException
transform(ContentReader, ContentWriter, Map)
,
transformInternal(ContentReader, ContentWriter, Map)
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.ContentIOException
ContentTransformer
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.
transform
in interface ContentTransformer
reader
- the source of the contentwriter
- the destination of the transformed contentoptions
- transformation options, these can be nullorg.alfresco.service.cmr.repository.ContentIOException
- if an IO exception occursContentTransformer.transform(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions)
public final void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, Map<String,Object> options) throws org.alfresco.service.cmr.repository.ContentIOException
transformInternal(ContentReader, ContentWriter, Map)
If the options provided are null, then an empty map will be created.
transform
in interface ContentTransformer
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.org.alfresco.service.cmr.repository.ContentIOException
- if an IO exception occurspublic long getTransformationTime()
getTransformationTime
in interface ContentTransformer
public long getTransformationTime(String sourceMimetype, String targetMimetype)
ContentTransformer
This method is used to determine, up front, which of a set of equally reliant transformers will be used for a specific transformation.
getTransformationTime
in interface ContentTransformer
sourceMimetype
- the source mimetypetargetMimetype
- the target mimetypeprotected final void recordTime(long transformationTime)
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.
transformationTime
- the time it took to perform the transformation.
The value may be 0.public void setBeanName(String beanName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public String getBeanName()
public String getName()
getName
in interface ContentTransformer
Copyright © 2005–2017 Alfresco Software. All rights reserved.