Sergey Shepelevich pushed to branch release/5.0 at cms-community /
hippo-repository
Commits:
f6924739 by Sergey Shepelevich at 2017-09-19T09:53:04+02:00
REPO-1746 Use JcrPath methods instead of String manipulation
Also do reordering for restored nodes as well
- - - - -
1 changed file:
-
engine/src/main/java/org/onehippo/cm/engine/autoexport/DefinitionMergeService.java
Changes:
=====================================
engine/src/main/java/org/onehippo/cm/engine/autoexport/DefinitionMergeService.java
=====================================
---
a/engine/src/main/java/org/onehippo/cm/engine/autoexport/DefinitionMergeService.java
+++
b/engine/src/main/java/org/onehippo/cm/engine/autoexport/DefinitionMergeService.java
@@ -45,10 +45,6 @@ import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
import org.apache.commons.collections4.trie.PatriciaTrie;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
@@ -91,9 +87,11 @@ import org.onehippo.cm.model.util.PatternSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
import static com.google.common.collect.ImmutableSet.toImmutableSet;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.singletonList;
import static java.util.function.Predicate.isEqual;
import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static
org.onehippo.cm.engine.autoexport.AutoExportConstants.DEFAULT_MAIN_CONFIG_FILE;
@@ -748,6 +746,8 @@ public class DefinitionMergeService {
restoreDeletedTree(topDeletedConfigNode);
}
+ reorderRegistry.add(incomingDefNode.getJcrPath().getParent());
+
// delete parent and child delete definitions if exists
removeDeleteDefinition(incomingDefNode.getJcrPath(),
isChildNodeDeleted);
@@ -819,14 +819,11 @@ public class DefinitionMergeService {
if (path.equals(definitionNode.getJcrPath())) {
return definitionNode;
} else if (path.startsWith(definitionNode.getJcrPath())) {
- // TODO: this should use JcrPath methods, not String
manipulation
- final String commonPrefix =
StringUtils.getCommonPrefix(path.toString(),
definitionNode.getJcrPath().toString());
- final int commonSegmentsCount = commonPrefix.split("/").length
- 1;
- final JcrPath subpath = path.subpath(commonSegmentsCount,
path.getSegmentCount());
-
+ final JcrPath pathDiff =
definitionNode.getJcrPath().relativize(path);
DefinitionNodeImpl currentNode = (DefinitionNodeImpl)
configDefinition.getNode();
- for (final JcrPathSegment jcrPathSegment : subpath) {
- currentNode =
currentNode.getNode(jcrPathSegment.toString());
+ for (final JcrPathSegment jcrPathSegment : pathDiff) {
+ currentNode =
currentNode.getModifiableNodes().getOrDefault(jcrPathSegment.toString(),
+
currentNode.getModifiableNodes().get(jcrPathSegment.forceIndex().toString()));
if (currentNode == null) {
break; //wrong path
} else if (currentNode.getJcrPath().equals(path)) {
View it on GitLab:
https://code.onehippo.org/cms-community/hippo-repository/commit/f6924739a37b50fc4096570459d6f6cc281e84c1
---
View it on GitLab:
https://code.onehippo.org/cms-community/hippo-repository/commit/f6924739a37b50fc4096570459d6f6cc281e84c1
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
[email protected]
https://lists.onehippo.org/mailman/listinfo/hippocms-svn