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:
Neil McErlean
2010-05-04 15:31:23 +00:00
parent f827a88a31
commit 30084dde24
8 changed files with 137 additions and 50 deletions

View File

@@ -41,7 +41,7 @@ import org.mozilla.javascript.Wrapper;
*
* @author davidc
*/
public final class ScriptAction implements Serializable, Scopeable
public class ScriptAction implements Serializable, Scopeable
{
private static final long serialVersionUID = 5794161358406531996L;
@@ -52,11 +52,11 @@ public final class ScriptAction implements Serializable, Scopeable
private ActionValueConverter converter;
/** Action state */
private Action action;
protected Action action;
private ActionDefinition actionDef;
protected ActionDefinition actionDef;
private ServiceRegistry services;
protected ServiceRegistry services;
private ActionService actionService;
private NamespaceService namespaceService;
private TransactionService transactionService;
@@ -145,7 +145,7 @@ public final class ScriptAction implements Serializable, Scopeable
actionParams.put(name, value);
}
}
actionService.executeAction(action, node.getNodeRef());
executeImpl(node);
// Parameters may have been updated by action execution, so reset cache
this.parameters = null;
@@ -153,6 +153,11 @@ public final class ScriptAction implements Serializable, Scopeable
// Reset the actioned upon node
node.reset();
}
protected void executeImpl(ScriptNode node)
{
actionService.executeAction(action, node.getNodeRef());
}
/**
* Execute action, optionally starting a new, potentially read-only transaction.
@@ -184,7 +189,7 @@ public final class ScriptAction implements Serializable, Scopeable
{
public Object execute() throws Throwable
{
actionService.executeAction(action, node.getNodeRef());
executeImpl(node);
return null;
}
};

View File

@@ -28,7 +28,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -54,10 +53,8 @@ import org.alfresco.repo.workflow.jscript.JscriptWorkflowInstance;
import org.alfresco.scripts.ScriptException;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.lock.LockStatus;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
@@ -86,10 +83,7 @@ import org.alfresco.service.namespace.NamespacePrefixResolverProvider;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.springframework.extensions.surf.util.Content;
import org.alfresco.util.GUID;
import org.springframework.extensions.surf.util.ParameterCheck;
import org.springframework.extensions.surf.util.URLEncoder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
@@ -99,6 +93,9 @@ import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.UniqueTag;
import org.mozilla.javascript.Wrapper;
import org.springframework.extensions.surf.util.Content;
import org.springframework.extensions.surf.util.ParameterCheck;
import org.springframework.extensions.surf.util.URLEncoder;
/**
* Script Node class implementation, specific for use by ScriptService as part of the object model.