From 2c64a653e5fcc2793049be550d05aaeaba900ca8 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 4 Oct 2010 20:32:49 +0000 Subject: [PATCH] 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 --- .../magick/ImageTransformationOptions.java | 22 +++++++++++ .../cmr/repository/TransformationOptions.java | 38 ++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/repo/content/transform/magick/ImageTransformationOptions.java b/source/java/org/alfresco/repo/content/transform/magick/ImageTransformationOptions.java index 85d7d6d65c..539affc26e 100644 --- a/source/java/org/alfresco/repo/content/transform/magick/ImageTransformationOptions.java +++ b/source/java/org/alfresco/repo/content/transform/magick/ImageTransformationOptions.java @@ -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 toMap() + { + Map baseProps = super.toMap(); + Map props = new HashMap(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 */ diff --git a/source/java/org/alfresco/service/cmr/repository/TransformationOptions.java b/source/java/org/alfresco/service/cmr/repository/TransformationOptions.java index 869246541d..ea31d2d5c5 100644 --- a/source/java/org/alfresco/service/cmr/repository/TransformationOptions.java +++ b/source/java/org/alfresco/service/cmr/repository/TransformationOptions.java @@ -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; @@ -53,6 +54,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); } /** @@ -171,8 +177,36 @@ public class TransformationOptions { return targetContentProperty; } + + /** + * 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. *

* Basic options (optional) are: @@ -181,6 +215,7 @@ public class TransformationOptions *

  • {@link #OPT_SOURCE_CONTENT_PROPERTY}
  • *
  • {@link #OPT_TARGET_NODEREF}
  • *
  • {@link #OPT_TARGET_CONTENT_PROPERTY}
  • + *
  • {@link #OPT_INCLUDE_EMBEDDED}
  • * *

    * 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; } }