org.alfresco.repo.processor
Class ScriptServiceImpl

java.lang.Object
  extended by org.alfresco.repo.processor.ScriptServiceImpl
All Implemented Interfaces:
ScriptService

public class ScriptServiceImpl
extends java.lang.Object
implements ScriptService

Script service implementation


Constructor Summary
ScriptServiceImpl()
           
 
Method Summary
 void buildCoreModel(java.util.Map inputMap)
          Add core data-model to provided Map
 java.util.Map buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef person, org.alfresco.service.cmr.repository.NodeRef companyHome, org.alfresco.service.cmr.repository.NodeRef userHome, org.alfresco.service.cmr.repository.NodeRef script, org.alfresco.service.cmr.repository.NodeRef document, org.alfresco.service.cmr.repository.NodeRef space)
          Create the default data-model available to scripts as global scope level objects:
 java.lang.Object executeScript(org.alfresco.service.cmr.repository.NodeRef scriptRef, org.alfresco.service.namespace.QName contentProp, java.util.Map model)
          Process a script against the supplied data model.
 java.lang.Object executeScript(ScriptLocation location, java.util.Map model)
          Process a script against the supplied data model Uses the most approparite script engine or the default if none found.
 java.lang.Object executeScript(java.lang.String scriptClasspath, java.util.Map model)
          Process a script against the supplied data model.
 java.lang.Object executeScript(java.lang.String engine, org.alfresco.service.cmr.repository.NodeRef scriptRef, org.alfresco.service.namespace.QName contentProp, java.util.Map model)
          Process a script against the supplied data model.
 java.lang.Object executeScript(java.lang.String engine, ScriptLocation location, java.util.Map model)
          Process a script against the supplied data model.
 java.lang.Object executeScript(java.lang.String engine, java.lang.String scriptClasspath, java.util.Map model)
          Process a script against the supplied data model.
 java.lang.Object executeScriptString(java.lang.String script, java.util.Map model)
          Process a script against the supplied data model.
 java.lang.Object executeScriptString(java.lang.String engine, java.lang.String script, java.util.Map model)
          Process a script against the supplied data model.
protected  ScriptProcessor getScriptProcessor(org.alfresco.service.cmr.repository.NodeRef scriptNode)
          Gets a scipt processor based on the node reference of a script
protected  ScriptProcessor getScriptProcessor(java.lang.String scriptLocation)
          Gets a script processor based on the script location string
protected  ScriptProcessor getScriptProcessorImpl(java.lang.String scriptFileName)
          Gets a script processor based on the scripts file name
protected  ScriptProcessor lookupScriptProcessor(java.lang.String name)
          Helper method to lookup the script proecessor based on a name
 void registerScriptProcessor(ScriptProcessor scriptProcessor)
          Register a script processor
 void resetScriptProcessors()
          Reset all registered script processors
 void setDefaultScriptProcessor(java.lang.String defaultScriptProcessor)
          Sets the name of the default script processor
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
          Set the node service
 void setSysAdminParams(SysAdminParams sysAdminParams)
          Set the sysAdminParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptServiceImpl

public ScriptServiceImpl()
Method Detail

setDefaultScriptProcessor

public void setDefaultScriptProcessor(java.lang.String defaultScriptProcessor)
Sets the name of the default script processor

Parameters:
defaultScriptProcessor - the name of the default script processor

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Set the node service

Parameters:
nodeService - the node service

setSysAdminParams

public void setSysAdminParams(SysAdminParams sysAdminParams)
Set the sysAdminParams

Parameters:
sysAdminParams - the sysAdminParams

registerScriptProcessor

public void registerScriptProcessor(ScriptProcessor scriptProcessor)
Register a script processor

Specified by:
registerScriptProcessor in interface ScriptService
Parameters:
scriptProcessor - the script processor to register with the script service

resetScriptProcessors

public void resetScriptProcessors()
Reset all registered script processors

Specified by:
resetScriptProcessors in interface ScriptService

executeScript

public java.lang.Object executeScript(java.lang.String scriptClasspath,
                                      java.util.Map model)
                               throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model. Uses the most approparite script engine or the default if none found.

Specified by:
executeScript in interface ScriptService
Parameters:
scriptClasspath - Script location as qualified classpath name
model - Object model to process script against
Returns:
output of the script (may be null or any valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScript(java.lang.String, java.util.Map)

executeScript

public java.lang.Object executeScript(java.lang.String engine,
                                      java.lang.String scriptClasspath,
                                      java.util.Map model)
                               throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model. Use the

Specified by:
executeScript in interface ScriptService
Parameters:
engine - the script engine to use
scriptClasspath - Script location as qualified classpath name
model - Object model to process script against
Returns:
output of the script (may be null or any valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScript(java.lang.String, java.lang.String, java.util.Map)

executeScript

public java.lang.Object executeScript(org.alfresco.service.cmr.repository.NodeRef scriptRef,
                                      org.alfresco.service.namespace.QName contentProp,
                                      java.util.Map model)
                               throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model. Uses the most approparite script engine or the default if none found.

Specified by:
executeScript in interface ScriptService
Parameters:
scriptRef - Script NodeRef location
contentProp - QName of the property on the node that contains the content, null can be passed to indicate the default property of 'cm:content'
model - Object model to process script against
Returns:
output of the script (may be null or any valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScript(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Map)

executeScript

public java.lang.Object executeScript(java.lang.String engine,
                                      org.alfresco.service.cmr.repository.NodeRef scriptRef,
                                      org.alfresco.service.namespace.QName contentProp,
                                      java.util.Map model)
                               throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model.

Specified by:
executeScript in interface ScriptService
Parameters:
engine - the script engine to use
scriptRef - Script NodeRef location
contentProp - QName of the property on the node that contains the content, null can be passed to indicate the default property of 'cm:content'
model - Object model to process script against
Returns:
output of the script (may be null or any valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScript(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Map)

executeScript

public java.lang.Object executeScript(ScriptLocation location,
                                      java.util.Map model)
                               throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model Uses the most approparite script engine or the default if none found.

Specified by:
executeScript in interface ScriptService
Parameters:
location - object representing the script location
model - Object model to process script against
Returns:
output of the script (may be null or any other valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScript(org.alfresco.service.cmr.repository.ScriptLocation, java.util.Map)

executeScript

public java.lang.Object executeScript(java.lang.String engine,
                                      ScriptLocation location,
                                      java.util.Map model)
                               throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model.

Specified by:
executeScript in interface ScriptService
Parameters:
engine - the script engine to use
location - object representing the script location
model - Object model to process script against
Returns:
output of the script (may be null or any other valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScript(java.lang.String, org.alfresco.service.cmr.repository.ScriptLocation, java.util.Map)

executeScriptString

public java.lang.Object executeScriptString(java.lang.String script,
                                            java.util.Map model)
                                     throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model. Uses the default script engine.

Specified by:
executeScriptString in interface ScriptService
Parameters:
script - Script content as a String.
model - Object model to process script against
Returns:
output of the script (may be null or any valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScriptString(java.lang.String, java.util.Map)

executeScriptString

public java.lang.Object executeScriptString(java.lang.String engine,
                                            java.lang.String script,
                                            java.util.Map model)
                                     throws org.alfresco.scripts.ScriptException
Description copied from interface: ScriptService
Process a script against the supplied data model.

Specified by:
executeScriptString in interface ScriptService
Parameters:
engine - the script engine to use
script - Script content as a String.
model - Object model to process script against
Returns:
output of the script (may be null or any valid wrapped JavaScript object)
Throws:
org.alfresco.scripts.ScriptException
See Also:
ScriptService.executeScriptString(java.lang.String, java.util.Map)

lookupScriptProcessor

protected ScriptProcessor lookupScriptProcessor(java.lang.String name)
Helper method to lookup the script proecessor based on a name

Parameters:
name - the name of the script processor
Returns:
ScriptProcessor the script processor, default processor if no match found

getScriptProcessor

protected ScriptProcessor getScriptProcessor(org.alfresco.service.cmr.repository.NodeRef scriptNode)
Gets a scipt processor based on the node reference of a script

Parameters:
scriptNode - the node reference of the script
Returns:
ScriptProcessor the script processor

getScriptProcessor

protected ScriptProcessor getScriptProcessor(java.lang.String scriptLocation)
Gets a script processor based on the script location string

Parameters:
scriptLocation - the script location
Returns:
ScriptProcessor the script processor

getScriptProcessorImpl

protected ScriptProcessor getScriptProcessorImpl(java.lang.String scriptFileName)
Gets a script processor based on the scripts file name

Parameters:
scriptFileName - the scripts file name
Returns:
ScriptProcessor the matching script processor

buildCoreModel

public void buildCoreModel(java.util.Map inputMap)
Description copied from interface: ScriptService
Add core data-model to provided Map

Specified by:
buildCoreModel in interface ScriptService
Parameters:
inputMap - initial Map of global scope scriptable Node objects
See Also:
ScriptService.buildCoreModel(java.util.Map)

buildDefaultModel

public java.util.Map buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef person,
                                       org.alfresco.service.cmr.repository.NodeRef companyHome,
                                       org.alfresco.service.cmr.repository.NodeRef userHome,
                                       org.alfresco.service.cmr.repository.NodeRef script,
                                       org.alfresco.service.cmr.repository.NodeRef document,
                                       org.alfresco.service.cmr.repository.NodeRef space)
Description copied from interface: ScriptService
Create the default data-model available to scripts as global scope level objects:

'companyhome' - the Company Home node
'userhome' - the current user home space node
'person' - the node representing the current user Person
'script' - the node representing the script itself (may not be available)
'document' - document context node (may not be available)
'space' - space context node (may not be available)

Specified by:
buildDefaultModel in interface ScriptService
Parameters:
person - The current user Person Node
companyHome - The CompanyHome ref
userHome - The User home space ref
script - Optional ref to the script itself
document - Optional ref to a document Node
space - Optional ref to a space Node
Returns:
A Map of global scope scriptable Node objects
See Also:
ScriptService.buildDefaultModel(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.