cancel
Showing results for 
Search instead for 
Did you mean: 

Creating rules with isAppliedToChildren is not supported??

umututkan
Champ in-the-making
Champ in-the-making
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.
2 REPLIES 2

msj4u
Champ in-the-making
Champ in-the-making
yes i also need this to skip the code modifications

kaynezhang
World-Class Innovator
World-Class Innovator
Afresco native webservice is not recommended.You can use webscript api to create a rule applied to children.
If you really want to use webservice ,you can only modify it by your self.