ALF-16201 TransformationOptions Should Be More Easily Extended

- protected clone() method added.
   - public deepCopy() method added.
   - ThumbnailRegistry now calls deepCopy().

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42450 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2012-10-08 20:10:20 +00:00
parent 41b1f42fde
commit 1e2a17611c
2 changed files with 24 additions and 2 deletions

View File

@@ -263,7 +263,7 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
public boolean isThumbnailDefinitionAvailable(String sourceUrl, String sourceMimetype, long sourceSize, NodeRef sourceNodeRef, ThumbnailDefinition thumbnailDefinition) public boolean isThumbnailDefinitionAvailable(String sourceUrl, String sourceMimetype, long sourceSize, NodeRef sourceNodeRef, ThumbnailDefinition thumbnailDefinition)
{ {
// Copy the thumbnail's TransformationOptions and set the sourceNodeRef, for use by transformers and debug. // Copy the thumbnail's TransformationOptions and set the sourceNodeRef, for use by transformers and debug.
TransformationOptions options = new TransformationOptions(thumbnailDefinition.getTransformationOptions()); TransformationOptions options = thumbnailDefinition.getTransformationOptions().deepCopy();
options.setSourceNodeRef(sourceNodeRef); options.setSourceNodeRef(sourceNodeRef);
// Log the following getTransform() as trace so we can see the wood for the trees // Log the following getTransform() as trace so we can see the wood for the trees

View File

@@ -35,7 +35,7 @@ import org.alfresco.service.namespace.QName;
* @author Roy Wetherall * @author Roy Wetherall
* @since 3.0.0 * @since 3.0.0
*/ */
public class TransformationOptions public class TransformationOptions implements Cloneable
{ {
/** Option map names to preserve backward compatibility */ /** Option map names to preserve backward compatibility */
public static final String OPT_SOURCE_NODEREF = "contentReaderNodeRef"; public static final String OPT_SOURCE_NODEREF = "contentReaderNodeRef";
@@ -106,6 +106,28 @@ public class TransformationOptions
set(optionsMap); set(optionsMap);
} }
@Override
protected TransformationOptions clone() throws CloneNotSupportedException
{
TransformationOptions clone = (TransformationOptions) super.clone();
clone.limits = new TransformationOptionLimits();
clone.set(toMap());
return clone;
}
public TransformationOptions deepCopy()
{
try
{
return clone();
}
catch (CloneNotSupportedException e)
{
// Not thrown
}
return null;
}
/** /**
* Sets options from the supplied map. * Sets options from the supplied map.
* @param optionsMap * @param optionsMap