Fix for links management.

Honoré David <[email protected]>
Newsgroups gmane.comp.jakarta.slide.devel
Message-ID <[email protected]>
There is a patch for org.apache.slide.structure.ObjectNode .Without it, 
links are lost when cloning an object, and when deleting an object which 
has more than one link only one link/2 is deleted and then 
ServiceException occur because Integrity of database is not good.

by the way the cache management is wrong. the object in global cache are 
modified while in a transaction. ... then if transaction is rolled back, 
Object in cache are invalid and does not match database anymore, but are 
always used. (patch for those bugs are comming)



Index: src/share/org/apache/slide/structure/ObjectNode.java
===================================================================
--- src/share/org/apache/slide/structure/ObjectNode.java    (revision 
382350)
+++ src/share/org/apache/slide/structure/ObjectNode.java    (working copy)
@@ -71,13 +71,12 @@
      */
     private Vector links = null;
    
-    /*
+    /**
      * If true then the {@link #links} vector is shared between multiple
      * ObjectNode-instances and thus must not be modified.
      *
-     *FIXME Never read! Do we need to implement linkSharing
      */
-    //private boolean linksShared;
+    private boolean linksShared;
    
     /**
      * Vector of bindings. Before modifying this vector you must check
@@ -369,7 +368,7 @@
         if (this.links == null) {
             return EmptyEnumeration.INSTANCE;
         } else {
-            return links.elements();
+            return ((Vector)links.clone()).elements();
         }
     }
    
@@ -409,7 +408,7 @@
        
         try {
             // init the shared fields to let clone() copy them
-            //this.linksShared=true;
+            this.linksShared=true;
             this.bindingsShared=true;
             result = (ObjectNode) super.clone();
         } catch(CloneNotSupportedException e) {
@@ -481,6 +480,10 @@
      */
     public void addLink( LinkNode link ) {
         if (this.links == null) this.links = new Vector();
+        if (linksShared) {
+            links = (Vector) links.clone();
+            linksShared = false;
+        }
         links.add(link.getUri());
     }
    
@@ -540,6 +543,10 @@
      * @param link
      */
     public void removeLink(LinkNode link) {
+        if (linksShared) {
+            links = (Vector) links.clone();
+            linksShared = false;
+        }
         if (this.links != null) {
             links.remove(link.getUri());
         }

Note, I do not post the patch in bugzilla because there is no more 
commiter working on slide. Warning of compilation error, spam on mailing 
list ... etc ... I think Slide was a good project, but is dead. If I am 
wrong tell me.

Have a nice day everybody.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.