mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Humongous merge. It is incomplete, however; faces-config-navigation.xml and ClientConfigElement
were both beyond me, and are just the raw conflict merge data. If Kev can't figure out how they should go together by tomorrow AM (for me) I'll dig back in. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4306 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,7 +21,9 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -30,6 +32,7 @@ import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.ScriptException;
|
||||
import org.alfresco.service.cmr.repository.ScriptImplementation;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -51,6 +54,8 @@ public class RhinoScriptService implements ScriptService
|
||||
/** Repository Service Registry */
|
||||
private ServiceRegistry services;
|
||||
|
||||
/** List of global scripts */
|
||||
private List<ScriptImplementation> globalScripts = new ArrayList<ScriptImplementation>(5);
|
||||
|
||||
/**
|
||||
* Set the Service Registry
|
||||
@@ -62,6 +67,14 @@ public class RhinoScriptService implements ScriptService
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.repository.ScriptService#registerScript(java.lang.Object)
|
||||
*/
|
||||
public void registerScript(ScriptImplementation script)
|
||||
{
|
||||
this.globalScripts.add(script);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.repository.ScriptService#executeScript(java.lang.String, java.util.Map)
|
||||
*/
|
||||
@@ -217,28 +230,28 @@ public class RhinoScriptService implements ScriptService
|
||||
model = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
// add useful util objects
|
||||
model.put("actions", new Actions(services));
|
||||
model.put("logger", new ScriptLogger());
|
||||
// add the global scripts
|
||||
for (ScriptImplementation script : this.globalScripts)
|
||||
{
|
||||
model.put(script.getScriptName(), script);
|
||||
}
|
||||
|
||||
// insert supplied object model into root of the default scope
|
||||
for (String key : model.keySet())
|
||||
{
|
||||
for (String key : model.keySet())
|
||||
// set the root scope on appropriate objects
|
||||
// this is used to allow native JS object creation etc.
|
||||
Object obj = model.get(key);
|
||||
if (obj instanceof Scopeable)
|
||||
{
|
||||
// set the root scope on appropriate objects
|
||||
// this is used to allow native JS object creation etc.
|
||||
Object obj = model.get(key);
|
||||
if (obj instanceof Scopeable)
|
||||
{
|
||||
((Scopeable)obj).setScope(scope);
|
||||
}
|
||||
|
||||
// convert/wrap each object to JavaScript compatible
|
||||
Object jsObject = Context.javaToJS(obj, scope);
|
||||
|
||||
// insert into the root scope ready for access by the script
|
||||
ScriptableObject.putProperty(scope, key, jsObject);
|
||||
((Scopeable)obj).setScope(scope);
|
||||
}
|
||||
|
||||
// convert/wrap each object to JavaScript compatible
|
||||
Object jsObject = Context.javaToJS(obj, scope);
|
||||
|
||||
// insert into the root scope ready for access by the script
|
||||
ScriptableObject.putProperty(scope, key, jsObject);
|
||||
}
|
||||
|
||||
// execute the script
|
||||
@@ -343,6 +356,10 @@ public class RhinoScriptService implements ScriptService
|
||||
|
||||
model.put("search", new Search(services, companyHome.getStoreRef(), resolver));
|
||||
|
||||
model.put("session", new Session(services, resolver));
|
||||
|
||||
model.put("classification", new Classification(services, companyHome.getStoreRef(), resolver));
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user