org.alfresco.repo.content.transform
Class AbstractContentTransformerLimits

java.lang.Object
  extended by org.alfresco.repo.content.transform.ContentTransformerHelper
      extended by org.alfresco.repo.content.transform.AbstractContentTransformerLimits
All Implemented Interfaces:
ContentWorker, ContentTransformer, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
AbstractContentTransformer2

public abstract class AbstractContentTransformerLimits
extends ContentTransformerHelper
implements ContentTransformer, org.springframework.beans.factory.BeanNameAware

Provides transformation limits for ContentTransformer implementations.

This class maintains the limits and provides methods that combine limits: a) for the transformer as a whole b) for specific combinations if source and target mimetypes c) for the TransformationOptions provided for a specific transform.


Field Summary
protected  TransformerDebug transformerDebug
          For debug
 
Constructor Summary
AbstractContentTransformerLimits()
           
 
Method Summary
 java.lang.String getBeanName()
          Returns the Spring bean name - only for use in debug.
protected  TransformationOptionLimits getLimits()
          Returns max and limit values for time, size and pages in a single operation.
protected  TransformationOptionLimits getLimits(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
          Returns max and limit values for time, size and pages for a specified source and target mimetypes, combined with this Transformer's general limits and optionally the supplied transformation option's limits.
protected  TransformationOptionLimits getLimits(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          Returns max and limit values for time, size and pages for a specified source and target mimetypes, combined with this Transformer's general limits and optionally the supplied transformation option's limits.
protected  int getMaxPages()
          Get the maximum number of pages read before an exception is thrown.
protected  long getMaxSourceSizeKBytes()
          Gets the maximum source content size, to skip transformations where the source is just too large to expect it to perform.
protected  java.util.Map getMimetypeLimits()
          Gets the max and limit values for time, size and pages per source and target mimetype combination.
protected  int getPageLimit()
          Get the page limit before returning EOF.
protected  long getReadLimitKBytes()
          Gets the limit in terms of the about of data read to limit transformations where only the start of the content is needed.
protected  long getReadLimitTimeMs()
          Gets the limit in terms of the amount of data read (by time) to limit transformations where only the start of the content is needed.
protected  long getTimeoutMs()
          Gets the timeout (ms) on the InputStream after which an IOExecption is thrown to terminate very slow transformations or a subprocess is terminated (killed).
protected  boolean isPageLimitSupported()
          Indicates if 'page' limits are supported.
 boolean isTransformable(java.lang.String sourceMimetype, long sourceSize, 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.
protected  boolean isTransformableSize(java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)
          Indicates if this transformer is able to transform the given sourceSize.
 void setBeanName(java.lang.String beanName)
          Sets the Spring bean name - only for use in debug.
 void setLimits(TransformationOptionLimits limits)
          Sets max and limit values for time, size and pages in a single operation.
 void setMaxPages(int maxPages)
          Set the number of pages read from the source before an exception is thrown.
 void setMaxSourceSizeKBytes(long maxSourceSizeKBytes)
          Sets a maximum source content size, to skip transformations where the source is just too large to expect it to perform.
 void setMimetypeLimits(java.util.Map mimetypeLimits)
          Sets the max and limit values for time, size and pages per source and target mimetype combination.
 void setPageLimit(int pageLimit)
          Set the number of pages read from the source before returning EOF.
 void setPageLimitsSuported(boolean pageLimitsSupported)
          Indicates if 'page' limits are supported.
protected  void setReaderLimits(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
          Pass on any limits to the reader.
 void setReadLimitKBytes(long readLimitKBytes)
          Sets a limit in terms of the about of data read to limit transformations where only the start of the content is needed.
 void setReadLimitTimeMs(long readLimitTimeMs)
          Sets a limit in terms of the amount of data read (by time) to limit transformations where only the start of the content is needed.
 void setTimeoutMs(long timeoutMs)
          Sets a timeout (ms) on the InputStream after which an IOExecption is thrown to terminate very slow transformations or to terminate (kill) a subprocess.
 void setTransformerDebug(TransformerDebug transformerDebug)
          Helper setter of the transformer debug.
 
Methods inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper
getMimetype, getMimetypeService, isExplicitTransformation, setExplicitTransformations, setMimetypeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformer
getTransformationTime, isExplicitTransformation, isTransformable, transform, transform, transform
 

Field Detail

transformerDebug

protected TransformerDebug transformerDebug
For debug

Constructor Detail

AbstractContentTransformerLimits

public AbstractContentTransformerLimits()
Method Detail

isPageLimitSupported

protected boolean isPageLimitSupported()
Indicates if 'page' limits are supported.

Returns:
false by default.

setPageLimitsSuported

public void setPageLimitsSuported(boolean pageLimitsSupported)
Indicates if 'page' limits are supported.


setTransformerDebug

public void setTransformerDebug(TransformerDebug transformerDebug)
Helper setter of the transformer debug.

Parameters:
transformerDebug -

isTransformable

public boolean isTransformable(java.lang.String sourceMimetype,
                               long sourceSize,
                               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.

Implementation calls the deprecated overloaded method without the sourceSize parameter and then AbstractContentTransformerLimits.isTransformableSize(String, long, String, TransformationOptions).

Specified by:
isTransformable in interface ContentTransformer
Parameters:
sourceMimetype - the source mimetype
sourceSize - the size (bytes) of the source. If negative it is unknown.
targetMimetype - the target mimetype
options - the transformation options
Returns:
boolean true if this content transformer can satify the mimetypes and options specified, false otherwise

isTransformableSize

protected boolean isTransformableSize(java.lang.String sourceMimetype,
                                      long sourceSize,
                                      java.lang.String targetMimetype,
                                      TransformationOptions options)
Indicates if this transformer is able to transform the given sourceSize. The maxSourceSizeKBytes property may indicate that only small source files may be transformed.

Parameters:
sourceSize - size in bytes of the source. If negative, the source size is unknown.
Returns:
true if the source is transformable.

getTimeoutMs

protected long getTimeoutMs()
Gets the timeout (ms) on the InputStream after which an IOExecption is thrown to terminate very slow transformations or a subprocess is terminated (killed).

Returns:
timeoutMs in milliseconds. If less than or equal to zero (the default) there is no timeout.

setTimeoutMs

public void setTimeoutMs(long timeoutMs)
Sets a timeout (ms) on the InputStream after which an IOExecption is thrown to terminate very slow transformations or to terminate (kill) a subprocess.

Parameters:
timeoutMs - in milliseconds. If less than or equal to zero (the default) there is no timeout. If greater than zero the readLimitTimeMs must not be set.

getReadLimitTimeMs

protected long getReadLimitTimeMs()
Gets the limit in terms of the amount of data read (by time) to limit transformations where only the start of the content is needed. After this limit is reached the InputStream reports end of file.

Returns:
readLimitBytes if less than or equal to zero (the default) there is no limit.

setReadLimitTimeMs

public void setReadLimitTimeMs(long readLimitTimeMs)
Sets a limit in terms of the amount of data read (by time) to limit transformations where only the start of the content is needed. After this limit is reached the InputStream reports end of file.

Parameters:
readLimitBytes - if less than or equal to zero (the default) there is no limit. If greater than zero the timeoutMs must not be set.

getMaxSourceSizeKBytes

protected long getMaxSourceSizeKBytes()
Gets the maximum source content size, to skip transformations where the source is just too large to expect it to perform. If the source is larger the transformer indicates it is not available.

Returns:
maxSourceSizeKBytes if less than or equal to zero (the default) there is no limit.

setMaxSourceSizeKBytes

public void setMaxSourceSizeKBytes(long maxSourceSizeKBytes)
Sets a maximum source content size, to skip transformations where the source is just too large to expect it to perform. If the source is larger the transformer indicates it is not available.

Parameters:
maxSourceSizeKBytes - if less than or equal to zero (the default) there is no limit. If greater than zero the readLimitKBytes must not be set.

getReadLimitKBytes

protected long getReadLimitKBytes()
Gets the limit in terms of the about of data read to limit transformations where only the start of the content is needed. After this limit is reached the InputStream reports end of file.

Returns:
readLimitKBytes if less than or equal to zero (the default) no limit should be applied.

setReadLimitKBytes

public void setReadLimitKBytes(long readLimitKBytes)
Sets a limit in terms of the about of data read to limit transformations where only the start of the content is needed. After this limit is reached the InputStream reports end of file.

Parameters:
readLimitKBytes - if less than or equal to zero (the default) there is no limit. If greater than zero the maxSourceSizeKBytes must not be set.

getMaxPages

protected int getMaxPages()
Get the maximum number of pages read before an exception is thrown.

Returns:
If less than or equal to zero (the default) no limit should be applied.

setMaxPages

public void setMaxPages(int maxPages)
Set the number of pages read from the source before an exception is thrown.

Parameters:
maxPages - the number of pages to be read from the source. If less than or equal to zero (the default) no limit is applied.

getPageLimit

protected int getPageLimit()
Get the page limit before returning EOF.

Returns:
If less than or equal to zero (the default) no limit should be applied.

setPageLimit

public void setPageLimit(int pageLimit)
Set the number of pages read from the source before returning EOF.

Parameters:
pageLimit - the number of pages to be read from the source. If less than or equal to zero (the default) no limit is applied.

getLimits

protected TransformationOptionLimits getLimits()
Returns max and limit values for time, size and pages in a single operation.


setLimits

public void setLimits(TransformationOptionLimits limits)
Sets max and limit values for time, size and pages in a single operation.


getMimetypeLimits

protected java.util.Map getMimetypeLimits()
Gets the max and limit values for time, size and pages per source and target mimetype combination.


setMimetypeLimits

public void setMimetypeLimits(java.util.Map mimetypeLimits)
Sets the max and limit values for time, size and pages per source and target mimetype combination.


getLimits

protected TransformationOptionLimits getLimits(org.alfresco.service.cmr.repository.ContentReader reader,
                                               org.alfresco.service.cmr.repository.ContentWriter writer,
                                               TransformationOptions options)
Returns max and limit values for time, size and pages for a specified source and target mimetypes, combined with this Transformer's general limits and optionally the supplied transformation option's limits.


getLimits

protected TransformationOptionLimits getLimits(java.lang.String sourceMimetype,
                                               java.lang.String targetMimetype,
                                               TransformationOptions options)
Returns max and limit values for time, size and pages for a specified source and target mimetypes, combined with this Transformer's general limits and optionally the supplied transformation option's limits.


setBeanName

public void setBeanName(java.lang.String beanName)
Sets the Spring bean name - only for use in debug.

Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

getBeanName

public java.lang.String getBeanName()
Returns the Spring bean name - only for use in debug.


setReaderLimits

protected void setReaderLimits(org.alfresco.service.cmr.repository.ContentReader reader,
                               org.alfresco.service.cmr.repository.ContentWriter writer,
                               TransformationOptions options)
Pass on any limits to the reader. Will only do so if the reader is an AbstractContentReader.

Parameters:
reader - passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions).
writer - passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions).
options - passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions).


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