org.alfresco.repo.content.transform
Class FailoverContentTransformer

java.lang.Object
  extended by org.alfresco.repo.content.transform.ContentTransformerHelper
      extended by org.alfresco.repo.content.transform.AbstractContentTransformer2
          extended by org.alfresco.repo.content.transform.FailoverContentTransformer
All Implemented Interfaces:
ContentWorker, ContentTransformer, org.springframework.beans.factory.InitializingBean

public class FailoverContentTransformer
extends AbstractContentTransformer2
implements org.springframework.beans.factory.InitializingBean

This class is a transformer which contains a fixed sequence of delegate transformers. Requests to transform a document will be passed to the first transformer in the sequence. If that transformer successfully transforms the document then the process is complete. However should it fail, the transformation will be passed on to the next transformer in the sequence and so on.

Transformers are considered to have failed of they throw an exception.


Constructor Summary
FailoverContentTransformer()
           
 
Method Summary
 void afterPropertiesSet()
          Ensures that required properties have been set
 boolean isExplicitTransformation(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          Default implementation, override if need to extend logic
 boolean isTransformable(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          Indicates whether the provided source mimetype can be transformed into the target mimetype with the options specified by this content transformer.
 void setTransformers(java.util.List transformers)
          The list of transformers to use.
 void transformInternal(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
          Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.
 
Methods inherited from class org.alfresco.repo.content.transform.AbstractContentTransformer2
checkTransformable, getTransformationTime, recordTime, register, setRegistry, toString, transform, transform, transform
 
Methods inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper
getMimetype, getMimetypeService, setExplicitTransformations, setMimetypeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FailoverContentTransformer

public FailoverContentTransformer()
Method Detail

setTransformers

public void setTransformers(java.util.List transformers)
The list of transformers to use. There must be at least one, but for failover behaviour to work there should be at least two.

Parameters:
transformers - list of transformers.

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Ensures that required properties have been set

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

isTransformable

public boolean isTransformable(java.lang.String sourceMimetype,
                               java.lang.String targetMimetype,
                               TransformationOptions options)
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)
Description copied from class: ContentTransformerHelper
Default implementation, override if need to extend logic

Specified by:
isExplicitTransformation in interface ContentTransformer
Overrides:
isExplicitTransformation in class ContentTransformerHelper
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.isExplicitTransformation(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)

transformInternal

public void transformInternal(org.alfresco.service.cmr.repository.ContentReader reader,
                              org.alfresco.service.cmr.repository.ContentWriter writer,
                              TransformationOptions options)
                       throws java.lang.Exception
Description copied from class: AbstractContentTransformer2
Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.

Specified by:
transformInternal in class AbstractContentTransformer2
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
See Also:
AbstractContentTransformer2.transformInternal(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions)


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