Search in sources :

Example 1 with ScriptableHashMap

use of org.alfresco.repo.jscript.ScriptableHashMap in project acs-community-packaging by Alfresco.

the class ScriptCommandProcessor method process.

/**
 * @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
 */
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command) {
    Map<String, Object> properties = new HashMap<String, Object>(4, 1.0f);
    properties.put(ExecuteScriptCommand.PROP_SCRIPT, this.scriptRef);
    properties.put(ExecuteScriptCommand.PROP_DOCUMENT, this.docRef);
    User user = Application.getCurrentUser(request.getSession());
    properties.put(ExecuteScriptCommand.PROP_USERPERSON, user.getPerson());
    // add URL arguments as a special Scriptable Map property called 'args'
    Map<String, String> args = new ScriptableHashMap<String, String>();
    Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        args.put(name, request.getParameter(name));
    }
    properties.put(ExecuteScriptCommand.PROP_ARGS, args);
    Command cmd = CommandFactory.getInstance().createCommand(command);
    if (cmd == null) {
        throw new AlfrescoRuntimeException("Unregistered script command specified: " + command);
    }
    this.result = cmd.execute(serviceRegistry, properties);
}
Also used : User(org.alfresco.web.bean.repository.User) Enumeration(java.util.Enumeration) HashMap(java.util.HashMap) ScriptableHashMap(org.alfresco.repo.jscript.ScriptableHashMap) ScriptableHashMap(org.alfresco.repo.jscript.ScriptableHashMap) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Aggregations

Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 ScriptableHashMap (org.alfresco.repo.jscript.ScriptableHashMap)1 User (org.alfresco.web.bean.repository.User)1