mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
TransformationOptions update - add a new flag for including embedded resources
Also fix ImageTransformationOptions to properly obey the TransformationOptions contract, by including the extra details in the toMap method git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22859 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.repo.content.transform.magick;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
|
||||
/**
|
||||
@@ -27,6 +30,10 @@ import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
*/
|
||||
public class ImageTransformationOptions extends TransformationOptions
|
||||
{
|
||||
public static final String OPT_COMMAND_OPTIONS = "commandOptions";
|
||||
public static final String OPT_IMAGE_RESIZE_OPTIONS = "imageResizeOptions";
|
||||
public static final String OPT_IMAGE_CROP_OPTIONS = "imageCropOptions";
|
||||
|
||||
/** Command string options, provided for backward compatibility */
|
||||
private String commandOptions = "";
|
||||
|
||||
@@ -88,6 +95,21 @@ public class ImageTransformationOptions extends TransformationOptions
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the base class implementation to add our options
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toMap()
|
||||
{
|
||||
Map<String, Object> baseProps = super.toMap();
|
||||
Map<String, Object> props = new HashMap<String, Object>(baseProps);
|
||||
props.put(OPT_COMMAND_OPTIONS, commandOptions);
|
||||
props.put(OPT_IMAGE_RESIZE_OPTIONS, resizeOptions);
|
||||
props.put(OPT_IMAGE_CROP_OPTIONS, cropOptions);
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param cropOptions the cropOptions to set
|
||||
*/
|
||||
|
@@ -41,6 +41,7 @@ public class TransformationOptions
|
||||
public static final String OPT_SOURCE_CONTENT_PROPERTY = "sourceContentProperty";
|
||||
public static final String OPT_TARGET_NODEREF = "contentWriterNodeRef";
|
||||
public static final String OPT_TARGET_CONTENT_PROPERTY = "targetContentProperty";
|
||||
public static final String OPT_INCLUDE_EMBEDDED = "includeEmbedded";
|
||||
|
||||
/** The source node reference */
|
||||
private NodeRef sourceNodeRef;
|
||||
@@ -54,6 +55,9 @@ public class TransformationOptions
|
||||
/** The target content property */
|
||||
private QName targetContentProperty;
|
||||
|
||||
/** The include embedded resources yes/no */
|
||||
private Boolean includeEmbedded;
|
||||
|
||||
/**
|
||||
* Default construtor
|
||||
*/
|
||||
@@ -76,10 +80,11 @@ public class TransformationOptions
|
||||
this.sourceContentProperty = sourceContentProperty;
|
||||
this.targetNodeRef = targetNodeRef;
|
||||
this.targetContentProperty = targetContentProperty;
|
||||
this.includeEmbedded = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constrcutor. Creates a transformation options object from a map.
|
||||
* Constructor. Creates a transformation options object from a map.
|
||||
* Provided for back ward compatibility.
|
||||
*
|
||||
* @param optionsMap options map
|
||||
@@ -90,6 +95,7 @@ public class TransformationOptions
|
||||
this.sourceContentProperty = (QName)optionsMap.get(OPT_SOURCE_CONTENT_PROPERTY);
|
||||
this.targetNodeRef = (NodeRef)optionsMap.get(OPT_TARGET_NODEREF);
|
||||
this.targetContentProperty = (QName)optionsMap.get(OPT_TARGET_CONTENT_PROPERTY);
|
||||
this.includeEmbedded = (Boolean)optionsMap.get(OPT_INCLUDE_EMBEDDED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,6 +179,34 @@ public class TransformationOptions
|
||||
}
|
||||
|
||||
/**
|
||||
* If the source content includes embedded resources,
|
||||
* should the transformer attempt to transform these
|
||||
* as well?
|
||||
* Not many transformers do support embedded resources,
|
||||
* so this option will only affect those that can.
|
||||
*
|
||||
* @param includeEmbedded the include embedded flag.
|
||||
*/
|
||||
public void setIncludeEmbedded(Boolean includeEmbedded)
|
||||
{
|
||||
this.includeEmbedded = includeEmbedded;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the source content includes embedded resources,
|
||||
* should the transformer attempt to transform these
|
||||
* as well?
|
||||
* Not many transformers do support embedded resources,
|
||||
* so this option will only affect those that can.
|
||||
*
|
||||
* @return true, false, or null for the default for the transformer
|
||||
*/
|
||||
public Boolean getIncludeEmbedded()
|
||||
{
|
||||
return includeEmbedded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the transformation options into a map.
|
||||
* <p>
|
||||
* Basic options (optional) are:
|
||||
@@ -181,6 +215,7 @@ public class TransformationOptions
|
||||
* <li>{@link #OPT_SOURCE_CONTENT_PROPERTY}</li>
|
||||
* <li>{@link #OPT_TARGET_NODEREF}</li>
|
||||
* <li>{@link #OPT_TARGET_CONTENT_PROPERTY}</li>
|
||||
* <li>{@link #OPT_INCLUDE_EMBEDDED}</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Override this method to append option values to the map. Derived classes should call
|
||||
@@ -193,6 +228,7 @@ public class TransformationOptions
|
||||
optionsMap.put(OPT_SOURCE_CONTENT_PROPERTY, sourceContentProperty);
|
||||
optionsMap.put(OPT_TARGET_NODEREF, targetNodeRef);
|
||||
optionsMap.put(OPT_TARGET_CONTENT_PROPERTY, targetContentProperty);
|
||||
optionsMap.put(OPT_INCLUDE_EMBEDDED, includeEmbedded);
|
||||
return optionsMap;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user