Author: nscavell
Date: 2012-01-23 21:48:02 -0500 (Mon, 23 Jan 2012)
New Revision: 8307
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/Node.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationServiceSave.java
Log:
JBEPP-1440: Deleting created subnode populates NPE and parent node is not properly
deleted
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2012-01-23
20:36:44 UTC (rev 8306)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2012-01-24
02:48:02 UTC (rev 8307)
@@ -611,26 +611,37 @@
Navigation sourceNav = session.findObjectById(ObjectType.NAVIGATION,
target.data.id);
//
- String objectId = sourceNav.getObjectId();
-
- //
- toEvict.add(objectId);
toEvict.add(parentNav.getObjectId());
sourceNav.destroy();
//
parent.data = new NodeData(parentNav);
+ toUpdate.add(parent.handle);
//
- toUpdate.add(parent.handle);
+ destroy(target);
+ }
+ private void destroy(NodeContext<N> ctx)
+ {
+ toPersist.values().remove(ctx.handle);
+
//
- if (toPersist.values().contains(objectId))
+ toUpdate.remove(ctx.handle);
+
+ //
+ toEvict.add(ctx.handle);
+
+ // Recurse
+ if (ctx.isExpanded())
{
- toPersist.values().remove(objectId);
+ for (NodeContext<N> child = ctx.getFirst();child != null;child =
child.getNext())
+ {
+ destroy(child);
+ }
}
- toUpdate.remove(objectId);
}
+
@Override
public void onUpdate(NodeContext<N> source, NodeState state) throws
NavigationServiceException
{
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/Node.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/Node.java 2012-01-23
20:36:44 UTC (rev 8306)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/Node.java 2012-01-24
02:48:02 UTC (rev 8307)
@@ -63,6 +63,11 @@
return context.getId();
}
+ public String getHandle()
+ {
+ return context.handle;
+ }
+
public String getName()
{
return context.getName();
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationServiceSave.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationServiceSave.java 2012-01-23
20:36:44 UTC (rev 8306)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/navigation/TestNavigationServiceSave.java 2012-01-24
02:48:02 UTC (rev 8307)
@@ -1071,6 +1071,33 @@
assertEquals(0, root.getChildren().size());
}
+ public void testTransitiveRemoveTransient() throws Exception
+ {
+ MOPService mop = mgr.getPOMService();
+ Site portal = mop.getModel().getWorkspace().addSite(ObjectType.PORTAL_SITE,
"transitive_remove_transient");
+ portal.getRootNavigation().addChild("default");
+
+ //
+ sync(true);
+
+ //
+ NavigationContext navigation =
service.loadNavigation(SiteKey.portal("transitive_remove_transient"));
+ Node root = service.loadNode(Node.MODEL, navigation, Scope.GRANDCHILDREN,
null).getNode();
+ root.addChild("foo").addChild("bar");
+ root.removeChild("foo");
+ service.saveNode(root.context, null);
+
+ //
+ root.assertConsistent();
+
+ //
+ sync(true);
+
+ //
+ root = service.loadNode(Node.MODEL, navigation, Scope.GRANDCHILDREN,
null).getNode();
+ assertEquals(0, root.getChildren().size());
+ }
+
public void testRenameCreatedNode() throws Exception
{
MOPService mop = mgr.getPOMService();