Obsolete Pages{{Obsolete}}
The official documentation is at: http://docs.alfresco.com
Actions
When rules are applied, the conditions of the rules are all evaluated before any actions are executed. This means that the action on one rule cannot bring in another attribute that would trigger one of the other rules - managing that dependency is too complex and probably not the correct semantics.
So, when a given object has rules applied to it, a list of all the rules whose conditions are met is returned - this may be passed to the user to decide exclude some rules from being invoked. We should have the ability to define a rule as mandatory, so the user has no option to exclude it, but can still be informed of its effect. Initially, a naive implementation of testing conditions should be performant enough for normal situations (assuming object data is cached).
A list of rules whose actions need to be executed is then invoked against the object. The rules are assumed to be independent in the initial implementation, so the order in which they are executed should not matter. In the longer term will should aim to have a full rules engine with chaining being used.
Once a rule has been executed against an object, that information should be recorded so that the system does not reapply rules that have already been run, unless explicitly requested (e.g. by the user). This allows us to have rules defined in an ancestor Space that can apply to all its children recursively, but moving an object from one child space to another should not reinvoke the 'super' rule.
Executing Rule from JAVA
In case there is a need to execute the rule from the java class you can do that easily with the help of actionservice.It is specifically with the use of remote services it can be done with the help of other repository services.
ActionServiceSoapBindingStub actionService=WebServiceFactory.getActionService();
QueryResult parentQueryResult = WebServiceFactory.getRepositoryService().queryParents(doc);
ResultSet parentResultSet = parentQueryResult.getResultSet();
ResultSetRow[] parentRows = parentResultSet.getRows();
String firstParentId = parentRows[0].getNode().getId();
final Store STORE = new Store(Constants.WORKSPACE_STORE, 'SpacesStore');
Reference parentReference = new Reference(STORE, firstParentId, null);
Rule[] rules=actionService.getRules(parentReference, null);
Action action = rules[0].getAction();
Predicate predicate = new Predicate(new Reference[]{doc}, null, null);
actionService.executeActions(predicate, new Action[]{action});
in this case doc is the reference of document inside space on which rule is already exist.