org.alfresco.repo.content.transform
Class RuntimeExecutableContentTransformer

java.lang.Object
  extended by org.alfresco.repo.content.transform.AbstractContentTransformer2
      extended by org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer
All Implemented Interfaces:
ContentWorker, ContentTransformer

public class RuntimeExecutableContentTransformer
extends AbstractContentTransformer2

This configurable wrapper is able to execute any command line transformation that accepts an input and an output file on the command line.

The following parameters are use:

Provided that the command executed ultimately transforms the source file and leaves the result in the target file, the transformation should be successful.

NOTE: It is only the contents of the files that can be transformed. Any attempt to modify the source or target file metadata will, at best, have no effect, but may ultimately lead to the transformation failing. This is because the files provided are both temporary files that reside in a location outside the system's content store.

This transformer requires the setting of the explicitTransformations property.

Since:
1.1
See Also:
RuntimeExec

Field Summary
static java.lang.String VAR_SOURCE
           
static java.lang.String VAR_TARGET
           
 
Constructor Summary
RuntimeExecutableContentTransformer()
           
 
Method Summary
 boolean isTransformable(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          If the initialization failed, then it returns 0.0.
 void register()
          Executes the check command, if present.
 void setCheckCommand(org.alfresco.util.exec.RuntimeExec checkCommand)
          Set the runtime executer that will be called as part of the initialisation to determine if the transformer is able to function.
 void setErrorCodes(java.lang.String errCodesStr)
          A comma or space separated list of values that, if returned by the executed command, indicate an error value.
 void setTransformCommand(org.alfresco.util.exec.RuntimeExec transformCommand)
          Set the runtime executer that will called to perform the actual transformation.
 java.lang.String toString()
           
protected  void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options)
          Converts the source and target content to temporary files with the correct extensions for the mimetype that they map to.
 
Methods inherited from class org.alfresco.repo.content.transform.AbstractContentTransformer2
checkTransformable, getMimetype, getMimetypeService, getTransformationTime, isExplicitTransformation, recordTime, setExplicitTransformations, setMimetypeService, setRegistry, transform, transform, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VAR_SOURCE

public static final java.lang.String VAR_SOURCE
See Also:
Constant Field Values

VAR_TARGET

public static final java.lang.String VAR_TARGET
See Also:
Constant Field Values
Constructor Detail

RuntimeExecutableContentTransformer

public RuntimeExecutableContentTransformer()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class AbstractContentTransformer2

setCheckCommand

public void setCheckCommand(org.alfresco.util.exec.RuntimeExec checkCommand)
Set the runtime executer that will be called as part of the initialisation to determine if the transformer is able to function. This is optional, but allows the transformer registry to detect and avoid using this instance if it is not working.

The command will be considered to have failed if the

Parameters:
checkCommand - the initialisation check command

setTransformCommand

public void setTransformCommand(org.alfresco.util.exec.RuntimeExec transformCommand)
Set the runtime executer that will called to perform the actual transformation.

Parameters:
transformCommand - the runtime transform command

setErrorCodes

public void setErrorCodes(java.lang.String errCodesStr)
A comma or space separated list of values that, if returned by the executed command, indicate an error value. This defaults to "1, 2".

Parameters:
erroCodesStr -

register

public void register()
Executes the check command, if present. Any errors will result in this component being rendered unusable within the transformer registry, but may still be called directly.

Overrides:
register in class AbstractContentTransformer2

isTransformable

public boolean isTransformable(java.lang.String sourceMimetype,
                               java.lang.String targetMimetype,
                               TransformationOptions options)
If the initialization failed, then it returns 0.0. Otherwise the explicit transformations are checked for the reliability.

Parameters:
sourceMimetype - the source mimetype
options - the transformation options
Returns:
Returns 1.0 if initialization succeeded, otherwise 0.0.
See Also:
AbstractContentTransformer.setExplicitTransformations(List)

transformInternal

protected final void transformInternal(ContentReader reader,
                                       ContentWriter writer,
                                       TransformationOptions options)
                                throws java.lang.Exception
Converts the source and target content to temporary files with the correct extensions for the mimetype that they map to.

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:
#transformInternal(File, File)


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