Here are my rules:
rule "Authorize Resources"
salience 100
when
$r : Resource()
$g : Group(resources contains $r)
then
AuthorizedResource auth = new AuthorizedResource();
auth.resource = $r;
assert(auth);
end
rule "Create block rules for unauthorized resources in same network"
when
$r : Resource()
$pr : Principal()
not AuthorizedResource(resource == $r)
eval (!Collections.disjoint($r.networks, $pr.networks))
then
BlockRule block = new BlockRule();
block.resource = $r;
assert(block);
end
When AuthorizedResources are asserted by the first rule, I expect that activations
of the second should be cancelled, since it makes the "not" condition false.
But the cancellations don't occur. Here's the output:
[BeforeActivationFired: rule=Authorize Resources; tuple=[fid:16:16], [fid:2:2],
[fid:7:7], [fid:24:24], ]
[ObjectAsserted: handle=[fid:25:25]; [EMAIL PROTECTED]
[AfterActivationFired(24): rule=Authorize Resources]
[BeforeActivationFired: rule=Authorize Resources; tuple=[fid:12:12], [fid:2:2],
[fid:7:7], [fid:24:24], ]
[ObjectAsserted: handle=[fid:26:26]; [EMAIL PROTECTED]
[AfterActivationFired(24): rule=Authorize Resources]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:12:12], [fid:23:23], ]
[ObjectAsserted: handle=[fid:27:27]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:8:8], [fid:23:23], ]
[ObjectAsserted: handle=[fid:28:28]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:5:5], [fid:23:23], ]
[ObjectAsserted: handle=[fid:29:29]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:1:1], [fid:23:23], ]
[ObjectAsserted: handle=[fid:30:30]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
However, if I comment out the eval() line, the cancellations do occur. Like
this:
rule "Create block rules for unauthorized resources in same network"
when
$r : Resource()
$pr : Principal()
not AuthorizedResource(resource == $r)
#eval (!Collections.disjoint($r.networks, $pr.networks))
then
BlockRule block = new BlockRule();
block.resource = $r;
assert(block);
end
... I get:
[BeforeActivationFired: rule=Authorize Resources; tuple=[fid:16:16], [fid:2:2],
[fid:7:7], [fid:24:24], ]
<==[ActivationCancelled(23): rule=Create block rules for unauthorized resources
in same network; tuple=[fid:16:16], [fid:23:23], ]
[ObjectAsserted: handle=[fid:25:25]; [EMAIL PROTECTED]
[AfterActivationFired(24): rule=Authorize Resources]
[BeforeActivationFired: rule=Authorize Resources; tuple=[fid:12:12], [fid:2:2],
[fid:7:7], [fid:24:24], ]
<==[ActivationCancelled(23): rule=Create block rules for unauthorized resources
in same network; tuple=[fid:12:12], [fid:23:23], ]
[ObjectAsserted: handle=[fid:26:26]; [EMAIL PROTECTED]
[AfterActivationFired(24): rule=Authorize Resources]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:21:21], [fid:23:23], ]
[ObjectAsserted: handle=[fid:27:27]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:14:14], [fid:23:23], ]
[ObjectAsserted: handle=[fid:28:28]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:8:8], [fid:23:23], ]
[ObjectAsserted: handle=[fid:29:29]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:5:5], [fid:23:23], ]
[ObjectAsserted: handle=[fid:30:30]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:4:4], [fid:23:23], ]
[ObjectAsserted: handle=[fid:31:31]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
[BeforeActivationFired: rule=Create block rules for unauthorized resources
in same network; tuple=[fid:1:1], [fid:23:23], ]
[ObjectAsserted: handle=[fid:32:32]; [EMAIL PROTECTED]
[AfterActivationFired(23): rule=Create block rules for unauthorized resources
in same network]
Note how the assertion of the AuthorizedResource now triggers the activation
cancelled. Am I missing something?