. Fix to Script command processor

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2815 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-05-10 16:24:03 +00:00
parent 0c9e0c91ec
commit b9da374553

View File

@@ -71,18 +71,23 @@ public final class ExecuteScriptCommand implements Command
"Unable to execute ExecuteScriptCommand - mandatory parameter not supplied: " + PROP_USERPERSON); "Unable to execute ExecuteScriptCommand - mandatory parameter not supplied: " + PROP_USERPERSON);
} }
// get the optional document context ref // get the optional document and space context ref
NodeService nodeService = serviceRegistry.getNodeService();
NodeRef docRef = (NodeRef)properties.get(PROP_DOCUMENT); NodeRef docRef = (NodeRef)properties.get(PROP_DOCUMENT);
NodeRef spaceRef = null;
if (docRef != null)
{
spaceRef = nodeService.getPrimaryParent(docRef).getParentRef();
}
// build the model needed to execute the script // build the model needed to execute the script
NodeService nodeService = serviceRegistry.getNodeService();
Map<String, Object> model = RhinoScriptService.buildDefaultModel( Map<String, Object> model = RhinoScriptService.buildDefaultModel(
serviceRegistry, serviceRegistry,
personRef, personRef,
new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()), new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()),
(NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER), (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER),
docRef, docRef,
nodeService.getPrimaryParent(docRef).getParentRef(), spaceRef,
DefaultModelHelper.imageResolver); DefaultModelHelper.imageResolver);
// execute the script and return the result // execute the script and return the result