mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge from V3.3 to HEAD
20069 Fix for unreported issue where the Rendition Service's JavaScript API cannot be used to execute ad hoc rendition definitions. Rendition Definitions can be created and executed programmatically. This works fine via the Java Foundation API, but is broken in the JavaScript API. The rendition nodes are not correctly created for ad hoc rendition definitions created in JavaScript. Note that the built-in rendition definitions work fine in JavaScript. This fix: - ScriptRenditionDefinition now extends ScriptAction in order to reuse its parameter handling and execution code. - ScriptRenditionDefinition now mimics ScriptAction so you can call renditionDef.execute(testSourceNode); in JavaScript. - more test coverage in the test_renditionService.js to reproduce the issue. - adds debug logging in various places in the rendition service. - changes ScriptAction to be a non-final class so that it can be extended by ScriptRenditionDefinition. - fixes some fragile asserts in test code. - changes a few fields to protected visibility and provides an extension point so that the rendition service can execute its "actions" as renditions rather than simple actions. - trivial. tidied up some unused imports in ScriptNode. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20070 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,10 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.rendition.script;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.jscript.ScriptAction;
|
||||
import org.alfresco.repo.jscript.ScriptNode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.rendition.RenderingEngineDefinition;
|
||||
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
||||
@@ -35,23 +33,14 @@ import org.mozilla.javascript.Scriptable;
|
||||
* @author Neil McErlean
|
||||
* @see org.alfresco.service.cmr.rendition.RenditionDefinition
|
||||
*/
|
||||
public final class ScriptRenditionDefinition implements Serializable
|
||||
public final class ScriptRenditionDefinition extends ScriptAction
|
||||
{
|
||||
private static final long serialVersionUID = 8132935577891455490L;
|
||||
private final RenderingEngineDefinition engineDefinition;
|
||||
private final RenditionDefinition renditionDefinition;
|
||||
private final ServiceRegistry serviceRegistry;
|
||||
|
||||
private final ScriptAction scriptAction;
|
||||
|
||||
public ScriptRenditionDefinition(ServiceRegistry serviceRegistry, Scriptable scope,
|
||||
RenderingEngineDefinition engineDefinition, RenditionDefinition renditionDefinition)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.engineDefinition = engineDefinition;
|
||||
this.renditionDefinition = renditionDefinition;
|
||||
|
||||
this.scriptAction = new ScriptAction(serviceRegistry, renditionDefinition, engineDefinition);
|
||||
super(serviceRegistry, renditionDefinition, engineDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,18 +50,17 @@ public final class ScriptRenditionDefinition implements Serializable
|
||||
*/
|
||||
public String getRenditionName()
|
||||
{
|
||||
QName qname = this.renditionDefinition.getRenditionName();
|
||||
return qname.toPrefixString(serviceRegistry.getNamespaceService());
|
||||
QName qname = getRenditionDefinition().getRenditionName();
|
||||
return qname.toPrefixString(services.getNamespaceService());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the Rendering Engine used by this definition.
|
||||
* @return
|
||||
*/
|
||||
public String getRenderingEngineName()
|
||||
{
|
||||
return this.engineDefinition.getName();
|
||||
}
|
||||
|
||||
public Map<String, Serializable> getParameters()
|
||||
{
|
||||
return this.scriptAction.getParameters();
|
||||
return getRenderingEngineDefinition().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,6 +75,18 @@ public final class ScriptRenditionDefinition implements Serializable
|
||||
|
||||
RenditionDefinition getRenditionDefinition()
|
||||
{
|
||||
return this.renditionDefinition;
|
||||
return (RenditionDefinition)action;
|
||||
}
|
||||
|
||||
RenderingEngineDefinition getRenderingEngineDefinition()
|
||||
{
|
||||
return (RenderingEngineDefinition)actionDef;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeImpl(ScriptNode node)
|
||||
{
|
||||
RenditionDefinition renditionDefinition = getRenditionDefinition();
|
||||
this.services.getRenditionService().render(node.getNodeRef(), renditionDefinition);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user