cancel
Showing results for 
Search instead for 
Did you mean: 

Executing code from the web client

peterm
Champ in-the-making
Champ in-the-making
Something I've found useful when developing with Alfresco is the ability to execute different sorts of code from the web client. Sometimes its nice to be able to run some code against the repository without having to set up complex test data in a unit test or run a remote client. So I created a simple action executor that (with a bit of configuration) can execute any class that implements a particular interface.

The executor looks like this…

public class GenericActionExecuter extends ActionExecuterAbstractBase {
    public static final String NAME = "action-generic";
    private ActionExecutable target;
    private List<Object> executionArgs;

    public void setExecutionArgs(List<Object> executionArgs) {
        this.executionArgs = executionArgs;
    }

    public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) {
        target.doExecute(ruleAction, actionedUponNodeRef, executionArgs);
    }

    protected void addParameterDefintions(List<ParameterDefinition> paramList) {
        target.doAddParameterDefintions(paramList);
    }

    public void setTarget(ActionExecutable target) {
        this.target = target;
    }
}
Any class that implements this interface…

public interface ActionExecutable {

    public void doExecute(Action ruleAction, NodeRef actionedUponNodeRef, List<Object> args);
    public void doAddParameterDefintions(List<ParameterDefinition> paramList);

}

…can be wired by Spring to be executed from the web client's run action interface. Not a replacement for a unit test, but a quick way to run some code against a repository and visually see the results.
1 REPLY 1

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Sounds good 🙂

Perhaps we should create a project on the forge where additional actions, such as this, can be easily contributed?

Cheers,
Roy