mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
. Rhino JavaScript integration checkpoint:
- Added a new action to the repository for executing JavaScript files - Added script action UI to rule framework, means we can execute a JavaScript file as part of a rule - Lucene search and Saved Search functionality added to default data-model for scripts - Added Scripts folder to Data Dictionary (created during bootstrap) - Created patch to add the Scripts folder to existing schemas - Added ScriptService to ServiceRegistry bean git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2740 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,10 +21,12 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -221,4 +223,46 @@ public class RhinoScriptService implements ScriptService
|
||||
cx.exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the default data-model available to scripts as global scope level objects:
|
||||
* <p>
|
||||
* 'companyhome' - the Company Home node<br>
|
||||
* 'userhome' - the current user home space node<br>
|
||||
* 'person' - the node representing the current user Person<br>
|
||||
* 'document' - document context node (may not be available)<br>
|
||||
* 'space' - space context node (may not be available)
|
||||
*
|
||||
* @param services ServiceRegistry
|
||||
* @param person The current user Person Node
|
||||
* @param companyHome The CompanyHome ref
|
||||
* @param userHome The User home space ref
|
||||
* @param document Optional ref to a document Node
|
||||
* @param space Optional ref to a space Node
|
||||
*
|
||||
* @return A Map of global scope scriptable Node objects
|
||||
*/
|
||||
public static Map<String, Object> buildDefaultModel(ServiceRegistry services,
|
||||
NodeRef person, NodeRef companyHome, NodeRef userHome, NodeRef document, NodeRef space)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
// add the well known node wrapper objects
|
||||
model.put("companyhome", new Node(companyHome, services, null));
|
||||
model.put("userhome", new Node(userHome, services, null));
|
||||
model.put("person", new Node(person, services, null));
|
||||
if (document != null)
|
||||
{
|
||||
model.put("document", new Node(document, services, null));
|
||||
}
|
||||
if (space != null)
|
||||
{
|
||||
model.put("space", new Node(space, services, null));
|
||||
}
|
||||
|
||||
// add other useful util objects
|
||||
model.put("search", new Search(services, companyHome.getStoreRef(), null));
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user