Advertisement
Guest User

Untitled

a guest
May 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1.  
  2.   Rule rule = new Rule();
  3.   rule.setRuleType(RuleType.INBOUND);
  4.   rule.setTitle("Your Rule Title");
  5.   rule.applyToChildren(false); // set this to true if you want to cascade to sub folders
  6.      
  7.   CompositeAction compositeAction = actionService.createCompositeAction();
  8.   rule.setAction(compositeAction);
  9.      
  10.   ActionCondition actionCondition = actionService.createActionCondition(IsSubTypeEvaluator.NAME);
  11.      
  12.   Map<String, Serializable> conditionParameters = new HashMap<String, Serializable>(1);
  13.   conditionParameters.put(IsSubTypeEvaluator.PARAM_TYPE, ContentModel.TYPE_CONTENT); // setting subtypes to CONTENT
  14.   actionCondition.setParameterValues(conditionParameters);
  15.            
  16.   compositeAction.addActionCondition(actionCondition);
  17.      
  18.   Action action = actionService.createAction(AddFeaturesActionExecuter.NAME);        // The Add Aspect Action            
  19.   action.setTitle("Your action title");
  20.   action.setExecuteAsynchronously(false);
  21.      
  22.   Map<String, Serializable> ruleParameters = new HashMap<String, Serializable>(1);
  23.   ruleParameters.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE); // The Aspect to add      
  24.   action.setParameterValues(ruleParameters);
  25.      
  26.   compositeAction.addAction(action);
  27.            
  28.   ruleService.saveRule(nodeRef, rule); // Save the rule to your nodeRe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement