Merged V1.4 to HEAD

svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4227 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4228 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4242 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4243 .
   Records management changes


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4250 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-10-30 11:43:37 +00:00
parent 4645415989
commit 71d2442632
10 changed files with 146 additions and 16 deletions

View File

@@ -2,9 +2,38 @@
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="scriptService" class="org.alfresco.repo.jscript.RhinoScriptService">
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
<bean id="baseScriptImplementation" abstract="true" init-method="register">
<property name="scriptService">
<ref bean="scriptService"/>
</property>
</bean>
<bean id="loggerScript" parent="baseScriptImplementation" class="org.alfresco.repo.jscript.ScriptLogger">
<property name="scriptName">
<value>logger</value>
</property>
</bean>
<bean id="utilsScript" parent="baseScriptImplementation" class="org.alfresco.repo.jscript.ScriptUtils">
<property name="scriptName">
<value>utils</value>
</property>
</bean>
<bean id="actionsScript" parent="baseScriptImplementation" class="org.alfresco.repo.jscript.Actions">
<property name="scriptName">
<value>actions</value>
</property>
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
</beans>

View File

@@ -35,7 +35,7 @@ import org.mozilla.javascript.Wrapper;
*
* @author davidc
*/
public final class Actions implements Scopeable
public final class Actions extends BaseScriptImplementation implements Scopeable
{
/** Repository Service Registry */
private ServiceRegistry services;
@@ -44,14 +44,13 @@ public final class Actions implements Scopeable
private Scriptable scope;
/**
* Constructor
* Set the service registry
*
* @param services
* repository service registry
* @param serviceRegistry the service registry
*/
public Actions(ServiceRegistry services)
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.services = services;
this.services = serviceRegistry;
}
/**
@@ -61,7 +60,7 @@ public final class Actions implements Scopeable
{
this.scope = scope;
}
/**
* Gets the list of registered action names
*
@@ -216,6 +215,9 @@ public final class Actions implements Scopeable
}
}
services.getActionService().executeAction(action, node.getNodeRef());
// Reset the actioned upon node
node.reset();
}
/**

View File

@@ -0,0 +1,57 @@
/**
*
*/
package org.alfresco.repo.jscript;
import org.alfresco.service.cmr.repository.ScriptImplementation;
import org.alfresco.service.cmr.repository.ScriptService;
/**
* Abstract base class for a script implementation
*
* @author Roy Wetherall
*/
public abstract class BaseScriptImplementation implements ScriptImplementation
{
/** The script service */
private ScriptService scriptService;
/** The name of the script */
private String scriptName;
/**
* Sets the script service
*
* @param scriptService the script service
*/
public void setScriptService(ScriptService scriptService)
{
this.scriptService = scriptService;
}
/**
* Registers this script with the script service
*/
public void register()
{
this.scriptService.registerScript(this);
}
/**
* Sets the script name
*
* @param scriptName the script name
*/
public void setScriptName(String scriptName)
{
this.scriptName = scriptName;
}
/**
* @see org.alfresco.service.cmr.repository.ScriptImplementation#getScriptName()
*/
public String getScriptName()
{
return this.scriptName;
}
}

View File

@@ -1738,7 +1738,7 @@ public class Node implements Serializable, Scopeable
/**
* Reset the Node cached state
*/
private void reset()
public void reset()
{
this.name = null;
this.type = null;

View File

@@ -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,10 +230,11 @@ 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());
model.put("utils", new ScriptUtils());
// 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())

View File

@@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
/**
* @author Kevin Roast
*/
public final class ScriptLogger
public final class ScriptLogger extends BaseScriptImplementation
{
private static final Logger logger = Logger.getLogger(ScriptLogger.class);

View File

@@ -23,7 +23,7 @@ import org.mozilla.javascript.Scriptable;
*
* @author Kevin Roast
*/
public final class ScriptUtils implements Scopeable
public final class ScriptUtils extends BaseScriptImplementation implements Scopeable
{
/** Root scope for this object */
private Scriptable scope;

View File

@@ -202,7 +202,7 @@ public interface ActionService
* @param nodeRef the node reference
* @param action the action
*/
@Auditable(key = Auditable.Key.ARG_1, parameters = {"nodeRef", "action" })
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "action" })
void saveAction(NodeRef nodeRef, Action action);
/**
@@ -211,7 +211,7 @@ public interface ActionService
* @param nodeRef the node reference
* @return the list of actions
*/
@Auditable(key = Auditable.Key.ARG_1, parameters = {"nodeRef"})
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
List<Action> getActions(NodeRef nodeRef);
/**

View File

@@ -0,0 +1,20 @@
/**
*
*/
package org.alfresco.service.cmr.repository;
/**
* Interface to represent a server side script implementation
*
* @author Roy Wetherall
*
*/
public interface ScriptImplementation
{
/**
* Returns the name of the script
*
* @return the name of the script
*/
String getScriptName();
}

View File

@@ -83,4 +83,12 @@ public interface ScriptService
@Auditable(parameters = {"script", "model"})
public Object executeScriptString(String script, Map<String, Object> model)
throws ScriptException;
/**
* Registers a script implementation with the script service
*
* @param script the script implementation
*/
@Auditable(parameters = {"script"})
public void registerScript(ScriptImplementation script);
}