AnsweredAssumed Answered

Creating rules with isAppliedToChildren is not supported??

Question asked by umututkan on Dec 25, 2010
Latest reply on Mar 21, 2014 by kaynezhang
Hi,

I have to create a rule to apply an action to company home for my functional test and this rule should also be applied to children. It is possible to create a rule by hand with isAppliedToChildren=true option. However I have to do this via web-services-client and I just noticed that you don't have this option in org.alfresco.webservice.action.Rule. The option is available in org.alfresco.service.cmr.rule.Rule but not in both org.alfresco.webservice.action.Rule and org.alfresco.repo.webservice.action.Rule. Anyway long story short it is not possible to create a rule that can also apply to children nodes simply is not possible with web-services-client. I just want to know why? Is there a specific reason why the feature is not supported.

You can also check the method that converts web service rule to repository rule, there is anything regarding isAppliedToChildren option.

    private Rule convertToRule(org.alfresco.repo.webservice.action.Rule webServiceRule)
    {       
        NodeRef ruleNodeRef = null;
        if (webServiceRule.getRuleReference() != null)
        {
            ruleNodeRef = Utils.convertToNodeRef(
                    webServiceRule.getRuleReference(),
                    this.nodeService,
                    this.searchService,
                    this.namespaceService);
        }
       
        // Get the rule type name
        String[] ruleTypes = webServiceRule.getRuleTypes();
       
        // Create the rule
        Rule rule = new Rule();
        List<String> ruleTypesList = new ArrayList<String>(ruleTypes.length);
        for (String ruleType : ruleTypes)
        {
            ruleTypesList.add(ruleType);
        }
        rule.setRuleTypes(ruleTypesList);
        rule.setNodeRef(ruleNodeRef);   
       
        // Set some of the rules details
        rule.setTitle(webServiceRule.getTitle());
        rule.setDescription(webServiceRule.getDescription());
        rule.setExecuteAsynchronously(webServiceRule.isExecuteAsynchronously());
        rule.applyToChildren(webServiceRule.get);

        // Set the action
        Action action = convertToAction(webServiceRule.getAction());
        rule.setAction(action);
       
        return rule;
    }

I don't want to modify the source code, is there a workaround?

Thanks.

Outcomes