2 Replies Latest reply on Feb 8, 2010 3:09 PM by vestnik

    Multiple drl files for rule based permission resolver

    vestnik

      Hello


      Till today I was writing all my security rules into a single drl file generated by seam-gen but finally it become to big and not easy to maintain. I've decided to split security roles for each role into a single drl file. So I've created several drl files in resources directory and modified my components.xml in the following way:


      ...
      <drools:rule-base name="securityRules">
            <drools:rule-files>
               <value>/security.drl</value>
               <value>/ConfigAdminSecurity.drl</value>
               <value>/SchoolAdminSecurity.drl</value>
               <value>/CourseOrganizerSecurity.drl</value>
            </drools:rule-files>
         </drools:rule-base>
      ...
      



      After that the only working rules are the rules from the second file in the list: ConfigAdminSecurity.drl. I've added the following rule to every file:


      rule Debug
      when
        person: Person()
      then
        System.out.println("------------------> file name here");
        System.out.println("------------------> Person.id = " + person.getId());
        System.out.println("------------------> Person.email = " + person.getEmail());
      end
      



      And this rule is fired only in ConfigAdminSecurity.drl but not in the other files.


      There are no errors or exceptions caused by incorrect DRL syntax or multiple rules with the same name (each file defines rules in different packages). The only exception I can see is org.jboss.seam.security.AuthorizationException in situation which should be allowed by one of my rules.


      Does anybody know how can I investigate this problem and solve it? Having all rules in a single file is definitely not the best solution.