Sergey Shepelevich pushed to branch master at cms-community / hippo-configuration-management
Commits: c021b152 by Sergey Shepelevich at 2017-09-19T09:48:23+02:00 HCM-198 Use JcrPath methods instead of String manipulation (cherry picked from commit 3511af963894ff334fae0505263ec705fc89f024) - - - - - 1 changed file: - model/src/main/java/org/onehippo/cm/model/impl/ConfigurationModelImpl.java Changes: ===================================== model/src/main/java/org/onehippo/cm/model/impl/ConfigurationModelImpl.java ===================================== --- a/model/src/main/java/org/onehippo/cm/model/impl/ConfigurationModelImpl.java +++ b/model/src/main/java/org/onehippo/cm/model/impl/ConfigurationModelImpl.java @@ -29,7 +29,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.stream.Stream; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.onehippo.cm.model.ConfigurationModel; import org.onehippo.cm.model.Group; @@ -265,12 +264,11 @@ public class ConfigurationModelImpl implements ConfigurationModel { final ConfigurationNodeImpl deletedRootNode = resolveDeletedSubNodeRoot(path); if (deletedRootNode != null) { - String commonPrefix = StringUtils.getCommonPrefix(path.toString(), deletedRootNode.getJcrPath().toString()); - int commonSegmentsCount = commonPrefix.split("/").length - 1; - final JcrPath subpath = path.subpath(commonSegmentsCount, path.getSegmentCount()); + final JcrPath pathDiff = deletedRootNode.getJcrPath().relativize(path); ConfigurationNodeImpl currentNode = deletedRootNode; - for (final JcrPathSegment jcrPathSegment : subpath) { - currentNode = currentNode.getNode(jcrPathSegment); + for (final JcrPathSegment jcrPathSegment : pathDiff) { + currentNode = currentNode.getNodes().getOrDefault(jcrPathSegment.toString(), + currentNode.getNodes().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-configuration-management/commit/c021b152395724b6a9f3c316380256170a6f43d1 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-configuration-management/commit/c021b152395724b6a9f3c316380256170a6f43d1 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn