[rules-users] Verify if an objects attribute exists

Leonardo Gomes leonardo.f.gomes at gmail.com
Mon Sep 13 08:09:51 EDT 2010


You could try to explain a bit more how the User class and the
isUserMatching method look like.

Leo.


On Fri, Sep 10, 2010 at 11:30 PM, lnguyen <mzspdrcr at gmail.com> wrote:

>
> I'm having difficulty writing this rule.
>
> Background information:
> A User can have a supervisor but it's not required.
>
> When viewing User information I want to verify that the logged in user is
> either the current user or the currentUser's supervisor but I throw an
> exception when the supervisor object is null on the currentUser.
>
> The target is the User being viewed and I have a global object that is the
> current user. How can I check to see if the supervisor exists before
> evaluating if the currentUser and the supervisor are equal?
>
> rule 'CanViewUserData'
> dialect 'mvel'
> when
>    $user : User()
>    $supervisor : User( ) from $user.userProfile.supervisor
>    $check: PermissionCheck(target == $user, action == "viewUserData")
>    eval(isUserMatching($user)) || eval (isUserMatching($supervisor))
> then
>    System.out.println("The currentUser CanViewUserData");
>    $check.grant();
> end
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Verify-if-an-objects-attribute-exists-tp1455073p1455073.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100913/514fb2bf/attachment.html 


More information about the rules-users mailing list