org.alfresco.repo.content.transform
Class AbstractContentTransformer

java.lang.Object
  extended by org.alfresco.repo.content.transform.AbstractContentTransformer
All Implemented Interfaces:
ContentWorker, ContentTransformer
Direct Known Subclasses:
RemoteOpenOfficeContentTransformer

Deprecated. Deprecated since 3.0. The abstract base class org.alfresco.repo.content.transform.AbstractContentTransformer2 should now be used instead.

@Deprecated
public abstract class AbstractContentTransformer
extends java.lang.Object
implements ContentTransformer

Provides basic services for 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.


Constructor Summary
protected AbstractContentTransformer()
          Deprecated. All transformers start with an average transformation time of 0.0ms.
 
Method Summary
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
protected  java.util.List getExplicitTransformations()
          Deprecated.  
protected  java.lang.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.  
protected abstract  double getReliability(java.lang.String sourceMimetype, java.lang.String targetMimetype)
          Deprecated. Added for backward compatibility of existing content transformers
 long getTransformationTime()
          Deprecated. Provides an estimate, usually a worst case guess, of how long a transformation will take.
 boolean isExplicitTransformation(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          Deprecated. Indicates whether given the provided transformation parmaters this transformer can prvide an explict transformation.
 boolean isTransformable(java.lang.String sourceMimetype, 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.
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 setExplicitTransformations(java.util.List 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
 java.lang.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, java.util.Map options)
          Deprecated. Performs the following: Times the transformation Ensures that the transformation is allowed Calls the subclass implementation of #transformInternal(ContentReader, ContentWriter) 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, java.util.Map 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractContentTransformer

protected AbstractContentTransformer()
Deprecated. 
All transformers start with an average transformation time of 0.0ms.

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 -

getMimetypeService

protected org.alfresco.service.cmr.repository.MimetypeService getMimetypeService()
Deprecated. 
Returns:
Returns the mimetype helper

getExplicitTransformations

protected java.util.List getExplicitTransformations()
Deprecated. 
Returns:
Returns the explicit transformations that were enabled for this transformer

setExplicitTransformations

public void setExplicitTransformations(java.util.List 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:
toString in class java.lang.Object

register

public void register()
Deprecated. 
Registers this instance with the registry if 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 mimetype
targetMimetype - 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 -
writer -
Throws:
org.alfresco.error.AlfrescoRuntimeException - if the reliability isn't > 0

isTransformable

public boolean isTransformable(java.lang.String sourceMimetype,
                               java.lang.String targetMimetype,
                               TransformationOptions options)
Deprecated. 
Description copied from interface: ContentTransformer
Indicates whether the provided source mimetype can be transformed into the target mimetype with the options specified by this content transformer.

Specified by:
isTransformable in interface ContentTransformer
Parameters:
sourceMimetype - the source mimetype
options - the transformation options
Returns:
boolean true if this content transformer can satify the mimetypes and options specified, false otherwise
See Also:
ContentTransformer.isTransformable(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)

isExplicitTransformation

public boolean isExplicitTransformation(java.lang.String sourceMimetype,
                                        java.lang.String targetMimetype,
                                        TransformationOptions options)
Deprecated. 
Description copied from interface: ContentTransformer
Indicates whether given the provided transformation parmaters this transformer can prvide an explict transformation. An explict transformation indicates that the transformation happens directly and not as a result of another transformation process. Explict transformation always take presidence over normal transformations.

Specified by:
isExplicitTransformation in interface ContentTransformer
Parameters:
sourceMimetype - the source mimetype
targetMimetype - the target mimetype
options - the transformation options
Returns:
boolean true if it is an explicit transformation, flase 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 options)
                                   throws java.lang.Exception
Deprecated. 
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 transform
writer - the target to which to write the transformed content
options - 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.ContentIOException
Deprecated. 
Specified by:
transform in interface ContentTransformer
Throws:
org.alfresco.service.cmr.repository.ContentIOException
See Also:
AbstractContentTransformer.transform(ContentReader, ContentWriter, Map), AbstractContentTransformer.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.ContentIOException
Deprecated. 
Description copied from interface: ContentTransformer
Transforms 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:
transform in interface ContentTransformer
Parameters:
reader - the source of the content
writer - the destination of the transformed content
options - 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 options)
                     throws org.alfresco.service.cmr.repository.ContentIOException
Deprecated. 
Performs the following: Subclass need only be concerned with performing the transformation.

If the options provided are null, then an empty map will be created.

Specified by:
transform in interface ContentTransformer
Parameters:
reader - the source of the content
writer - the destination of the transformed content
options - 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. 
Description copied from interface: ContentTransformer
Provides an estimate, usually a worst case guess, of how long a transformation will take.

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:
getTransformationTime in interface ContentTransformer
Returns:
Returns the calculated running average of the current transformations

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.


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.