Revision: 29357 Author: aschrijvers Date: 2011-08-05 14:54:35 +0200 (Fri, 05 Aug 2011) Log Message: ----------- HSTTWO-1716 in case of a move, reload the parent for all nodes below hst:configurations as the order is changed
Modified Paths: -------------- hippo-cms7/site-toolkit/trunk/components/core/src/main/java/org/hippoecm/hst/configuration/model/HstManagerImpl.java Modified: hippo-cms7/site-toolkit/trunk/components/core/src/main/java/org/hippoecm/hst/configuration/model/HstManagerImpl.java =================================================================== --- hippo-cms7/site-toolkit/trunk/components/core/src/main/java/org/hippoecm/hst/configuration/model/HstManagerImpl.java 2011-08-05 11:57:13 UTC (rev 29356) +++ hippo-cms7/site-toolkit/trunk/components/core/src/main/java/org/hippoecm/hst/configuration/model/HstManagerImpl.java 2011-08-05 12:54:35 UTC (rev 29357) @@ -15,8 +15,10 @@ */ package org.hippoecm.hst.configuration.model; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -189,7 +191,6 @@ } protected void buildSites() throws RepositoryNotAvailableException{ - if (clearAll) { configChangeEventMap = null; commonCatalog = null; @@ -315,6 +316,12 @@ hstComponentsConfigurationChanged = true; } + /* + * When a node is removed and added, we need to reload the parent because + * the ordering is most likely changed: Jackrabbit returns for a MOVE a 'remove' and an 'add' as event. + * we keep track of removals in removedPaths. When we also later encounter an add, we reload the parent + */ + Map<String, HstNode> removedPathsForParentNode = new HashMap<String, HstNode>(); for(HstEvent event : events) { if(event.eventType == HstEvent.EventType.NODE_EVENT) { @@ -322,6 +329,7 @@ HstNode node = getConfigurationNodeForPath(event.path); if(node != null) { if(node.getParent() != null) { + removedPathsForParentNode.put(node.getValueProvider().getPath(), node.getParent()); node.getParent().removeNode(node.getValueProvider().getName()); } else { // we are a root @@ -340,7 +348,25 @@ ((HstNodeImpl)node).markStale(); } } + } + + // check whether there were removes and adds for the same node (in other words, a MOVE) + List<String> extraNodesToLoad = new ArrayList<String>(); + for(String path : loadNodes) { + if(removedPathsForParentNode.containsKey(path)) { + // found a move and add. Remove the parent and reload the parent + HstNode node = removedPathsForParentNode.get(path); + if(node.getParent() != null) { + node.getParent().removeNode(node.getValueProvider().getName()); + extraNodesToLoad.add(node.getValueProvider().getPath()); + } else { + // we are a root + configurationRootNodes.remove(node.getValueProvider().getPath()); + } + } } + + loadNodes.addAll(extraNodesToLoad); } if( configurationRootNodes.isEmpty()) { _______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.hippocms.org http://lists.hippo.nl/mailman/listinfo/hippocms-svn