Andr� van Toly wrote:
> At 23:44 +0200 23-05-2005, Michiel Meeuwissen wrote:
> >+        // I think we should not use 
> >core-functionality in taglib implemenation
> 
> I agree but i could not find another way to check 
> whether a relation is allowed honnering the 
> source -> destination direction.
> 
> >         org.mmbase.module.core.MMBase mmb = 
> >org.mmbase.module.core.MMBase.getMMBase();
> >         int snumber = sourceNode.getNodeManager().getNumber();
> >         int dnumber = destinationNode.getNodeManager().getNumber();
> >         int rnumber = rm.getNumber();
> >         if (log.isDebugEnabled()) 
> >log.debug("snumber: " +  snumber + " dnumber: " 
> >+ dnumber + " rnumber: " + rnumber);
> >
> >-        if (rm.mayCreateRelation(sourceNode, destinationNode) != 
> >getInverse()
> >-            && mmb.getTypeRel().contains(snumber, dnumber, rnumber) ) {
> >+        if ((rm.mayCreateRelation(sourceNode, 
> >destinationNode) && 
> >mmb.getTypeRel().contains(snumber, dnumber, 
> >rnumber)) != getInverse()) {
> >+            // perhaps this mmb.getTypeRel must 
> >simply be moved to implementation of 
> >mayCreateRelation?
> 
> The implementation in 
> org.mmbase.bridge.BasicRelationManager#mayCreateRelation 
> only checks against security. 

So why not change that? You showed how to do it!

> Next when a 
> relation is created in 
> BasicRelationManager#createRelation it checks if 
> the relation is valid in 
> BasicRelation#checkValid() which 'looks' at both 
> sides of the relation: it first checks whether 
> source -> destination is present in TypeRel and 
> then reverses it and checks destination -> source 
> ;-) IIRC a relation with either direction is 
> valid on the bridge.
> 
> In taglib the createrelation tag throws an 
> exception when you try to create a relation with 
> the wrong directionality. So in a way this code 
> is now in the right spot.

I think it is weird that the tag throws an exception and the bridge does
not, while the tag does nothing more than calling a bridge function:
 RelationManager rm = getCloudVar().getRelationManager(role.getString(this));
 Node sourceNode      = getNode(source.getString(this));
 Node destinationNode = getNode(destination.getString(this));

 Relation r = rm.createRelation(sourceNode, destinationNode);
 r.commit();

So, that means that RelationManager#createRelation throws an excpetion
when you turn source and destination around. 

That would make perfect sense to me, though the 'turn-around'
functionality about which you speaks sounds familiar too.

I think there must be symmetry in the bridge in the first place. You
cannot have checked 'mayCreateRelation' and then to find that the relation
you make with excactly the same arguments in 'createRelation' gives an
excpetion informing that you are not allowed.

Allthough I would not be be against working around such issues in the
taglib if necessary, I don't quite understand yet what is going on in
bridge here, and I have the feeling that the problem which you try to
solve here, would occur in bridge-only code too, because the
tag-implementations were so very straight-forward.


michiel


-- 
Michiel Meeuwissen                  mihxil'
Mediacentrum 140 H'sum                [] ()
+31 (0)35 6772979         nl_NL eo_XX en_US



_______________________________________________
Developers mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/developers

Reply via email to