Merged V2.1-A to HEAD

7693: Pass contentReader and contentWriter noderef options to content transformer (when invoked from transform action).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8667 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-04-03 10:28:12 +00:00
parent e5bfb7e8fa
commit a5b1a90a29
3 changed files with 20 additions and 24 deletions

View File

@@ -209,9 +209,6 @@
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="transformerRegistry">
<ref bean="contentTransformerRegistry" />
</property>
<property name="applicableTypes">
<list>
<value>{http://www.alfresco.org/model/content/1.0}content</value>

View File

@@ -28,8 +28,6 @@ import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.content.transform.ContentTransformer;
import org.alfresco.repo.content.transform.ContentTransformerRegistry;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -82,7 +80,6 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
private ContentService contentService;
private CopyService copyService;
private MimetypeService mimetypeService;
private ContentTransformerRegistry transformerRegistry;
/**
* Set the mime type service
@@ -134,16 +131,6 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
this.copyService = copyService;
}
/**
* Set the transformer registry
*
* @param transformerRegistry the transformer registry
*/
public void setTransformerRegistry(ContentTransformerRegistry transformerRegistry)
{
this.transformerRegistry = transformerRegistry;
}
/**
* Add parameter definitions
*/
@@ -298,15 +285,18 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
protected void doTransform( Action ruleAction,
NodeRef sourceNodeRef, ContentReader contentReader,
NodeRef destinationNodeRef, ContentWriter contentWriter)
{
// try to pre-empt the lack of a transformer
if (!this.contentService.isTransformable(contentReader, contentWriter))
// Transformation options
TransformationOptions options = new TransformationOptions(sourceNodeRef, ContentModel.PROP_NAME, destinationNodeRef, ContentModel.PROP_NAME);
// try to pre-empt the lack of a transformer
if (this.contentService.isTransformable(contentReader, contentWriter, options) == false)
{
throw new NoTransformerException(contentReader.getMimetype(), contentWriter.getMimetype());
}
// transform
TransformationOptions options = new TransformationOptions(sourceNodeRef, ContentModel.PROP_NAME, destinationNodeRef, ContentModel.PROP_NAME);
this.contentService.transform(contentReader, contentWriter, options);
}

View File

@@ -41,9 +41,9 @@ import org.alfresco.service.namespace.QName;
public class TransformationOptions
{
/** Option map names to preserve backward compatibility */
public static final String OPT_SOURCE_NODEREF = "sourceNodeRef";
public static final String OPT_SOURCE_NODEREF = "contentReaderNodeRef";
public static final String OPT_SOURCE_CONTENT_PROPERTY = "sourceContentProperty";
public static final String OPT_TARGET_NODEREF = "targetNodeRef";
public static final String OPT_TARGET_NODEREF = "contentWriterNodeRef";
public static final String OPT_TARGET_CONTENT_PROPERTY = "targetContentProperty";
/** The source node reference */
@@ -182,6 +182,11 @@ public class TransformationOptions
return new HashMap<String, Object>(10);
}
/**
* Places the values of the transformation options into a Map
*
* @param optionsMap the options map
*/
protected void toMapImpl(Map<String, Object> optionsMap)
{
optionsMap.put(OPT_SOURCE_NODEREF, getSourceNodeRef());
@@ -190,6 +195,11 @@ public class TransformationOptions
optionsMap.put(OPT_TARGET_CONTENT_PROPERTY, getTargetContentProperty());
}
/**
* Populates the transformation options from a given Map of value.
*
* @param optionsMap the options map
*/
protected void fromMapImpl(Map<String, Object> optionsMap)
{
this.sourceNodeRef = (NodeRef)optionsMap.get(OPT_SOURCE_NODEREF);
@@ -197,5 +207,4 @@ public class TransformationOptions
this.targetNodeRef = (NodeRef)optionsMap.get(OPT_TARGET_NODEREF);
this.targetContentProperty = (QName)optionsMap.get(OPT_TARGET_CONTENT_PROPERTY);
}
}