* Macrohelper.deleteobject should drop the associated links when an ObjectNode is deleted otherwise integrity error occurs into the DB store.
* When adding a LinkNode via the ExtendedStore, the "linked" object in the cache is not refresh. in fact, its vector "link" doesn't contain the new link.
* When deleting a LinkNode via the ExtendedStore, the "linked" object in the cache is not refresh. In fact, the LinkNode is not deleted from its vector "link".
I think similar patch has to be apply into the StandardStore.
Regards, Christophe
Index: org/apache/slide/macro/MacroImpl.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v
retrieving revision 1.34
diff -u -r1.34 MacroImpl.java
--- org/apache/slide/macro/MacroImpl.java 7 Sep 2003 15:49:47 -0000 1.34
+++ org/apache/slide/macro/MacroImpl.java 16 Dec 2003 22:21:53 -0000
@@ -794,6 +794,16 @@
deleteObject(token, childUri, e, deleteRedirector,
deleteListener);
}
}
+
+ // Removing links objects
+ if (currentObject.hasLinks()) {
+ Enumeration links =
currentObject.enumerateLinks();
+ while (links.hasMoreElements()) {
+ String linkUri =
(String)links.nextElement();
+ deleteObject(token, linkUri, e,
deleteRedirector, deleteListener);
+ }
+ }
+
// now let the client redirect
if (deleteRedirector != null) {
@@ -808,7 +818,7 @@
NodeRevisionDescriptors revisionDescriptors =
contentHelper.retrieve(token, currentObject.getUri());
-
+
// remove the associated locks
Enumeration locks = lockHelper.enumerateLocks
(token, currentObject.getUri(), false);
Index: org/apache/slide/store/ExtendedStore.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/share/org/apache/slide/store/ExtendedStore.java,v
retrieving revision 1.1
diff -u -r1.1 ExtendedStore.java
--- org/apache/slide/store/ExtendedStore.java 14 Nov 2003 12:52:52 -0000 1.1
+++ org/apache/slide/store/ExtendedStore.java 16 Dec 2003 22:21:57 -0000
@@ -81,6 +81,7 @@
import org.apache.slide.lock.LockTokenNotFoundException;
import org.apache.slide.lock.NodeLock;
import org.apache.slide.security.NodePermission;
+import org.apache.slide.structure.LinkNode;
import org.apache.slide.structure.ObjectAlreadyExistsException;
import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.ObjectNotFoundException;
@@ -476,6 +477,15 @@
if (nodeStore.cacheResults()) {
enlist(this);
try {
+
+ if (object instanceof LinkNode) {
+ // add the link into the "linked" object if it is in the cache
+ String linkedUri = ((LinkNode) object).getLinkedUri();
+ ObjectNode linkedObject = (ObjectNode) objectsCache.get(linkedUri);
+ if (linkedObject != null) {
+ linkedObject.addLink((LinkNode)object);
+ }
+ }
objectsCache.put(uri.toString(), object.cloneObject());
} finally {
delist(this);
@@ -488,6 +498,13 @@
if (nodeStore.cacheResults()) {
enlist(this);
try {
+ if (object instanceof LinkNode) {
+ // check if the linked object is in the cache, and remove the
linknode fromits link vector
+ ObjectNode linkedObject = (ObjectNode)
objectsCache.get(((LinkNode)object).getLinkedUri());
+ if (linkedObject !=null) {
+ linkedObject.removeLink((LinkNode) object);
+ }
+ }
objectsCache.remove(uri.toString());
} finally {
delist(this);
Index: org/apache/slide/structure/ObjectNode.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/share/org/apache/slide/structure/ObjectNode.java,v
retrieving revision 1.21
diff -u -r1.21 ObjectNode.java
--- org/apache/slide/structure/ObjectNode.java 14 Nov 2003 09:11:47 -0000 1.21
+++ org/apache/slide/structure/ObjectNode.java 16 Dec 2003 22:21:59 -0000
@@ -358,7 +358,16 @@
public boolean hasChildren() {
return !(getChildren().isEmpty());
}
+
+ /**
+ * Test if object has links.
+ *
+ * @return boolean true if this object has links, false otherwise
+ */
+ public boolean hasLinks() {
+ return !( links.isEmpty());
+ }
/**
* Return this object's inbound links
*
@@ -470,7 +479,16 @@
public void addChild( ObjectNode child ) {
addBinding( child.getPath().lastSegment(), child );
}
+
+ /**
+ * Add a link.
+ * @param link an LinkNode
+ */
+ public void addLink( LinkNode link ) {
+ links.add(link.getUri());
+ }
+
/**
* Add a new binding.
* @param bindingName a String
@@ -514,7 +532,16 @@
childrenCache = null;
child.removeParentBinding(bindingName, this);
}
-
+
+ /**
+ * Remove link.
+ *
+ * @param link
+ */
+ public void removeLink(LinkNode link) {
+ links.remove(link.getUri());
+ }
+
/**
* Get the path of this object node.
*--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
