Sergey Shepelevich pushed to branch release/5.0 at cms-community / hippo-repository
Commits: 0e78486f by Sergey Shepelevich at 2018-02-23T16:31:21+01:00 REPO-1952 [Backport 5.0.7] Autoexport infinite exception loop when moving and replacing a content node (cherry picked from commit 755371bfb5cf318fdd47ba03bba1588453775b1b) - - - - - 3 changed files: - engine/src/main/java/org/onehippo/cm/engine/autoexport/AutoExportConfigExporter.java - engine/src/main/java/org/onehippo/cm/engine/autoexport/EventChanges.java - engine/src/main/java/org/onehippo/cm/engine/autoexport/EventJournalProcessor.java Changes: ===================================== engine/src/main/java/org/onehippo/cm/engine/autoexport/AutoExportConfigExporter.java ===================================== --- a/engine/src/main/java/org/onehippo/cm/engine/autoexport/AutoExportConfigExporter.java +++ b/engine/src/main/java/org/onehippo/cm/engine/autoexport/AutoExportConfigExporter.java @@ -35,8 +35,6 @@ import org.onehippo.cm.engine.JcrContentExporter; import org.onehippo.cm.engine.ValueProcessor; import org.onehippo.cm.model.Group; import org.onehippo.cm.model.impl.ConfigurationModelImpl; -import org.onehippo.cm.model.impl.definition.ContentDefinitionImpl; -import org.onehippo.cm.model.path.JcrPath; import org.onehippo.cm.model.impl.source.ConfigSourceImpl; import org.onehippo.cm.model.impl.tree.ConfigurationNodeImpl; import org.onehippo.cm.model.impl.tree.ConfigurationPropertyImpl; @@ -71,15 +69,13 @@ public class AutoExportConfigExporter extends JcrContentExporter { private ConfigurationModelImpl configurationModel; private PathsMap addedContent; - private PathsMap deletedContent; AutoExportConfigExporter(final ConfigurationModelImpl configurationModel, final AutoExportConfig exportConfig, - final PathsMap addedContent, final PathsMap deletedContent) { + final PathsMap addedContent) { super(exportConfig); this.exportConfig = exportConfig; this.configurationModel = configurationModel; this.addedContent = addedContent; - this.deletedContent = deletedContent; } protected boolean shouldExcludeProperty(Property property) throws RepositoryException { @@ -463,7 +459,6 @@ public class AutoExportConfigExporter extends JcrContentExporter { new IllegalStateException()); } else { - checkDeletedContentChildren(childNode.getJcrPath()); childNode.delete(); } } @@ -474,22 +469,6 @@ public class AutoExportConfigExporter extends JcrContentExporter { } } - /* - * When a config node is deleted (in jcr), check if there were child nodes which mapped to *content* definitions, - * and if so record these as 'to be deleted' content paths for the DefinitionMergeService to handle later. - */ - protected void checkDeletedContentChildren(final JcrPath deletedConfig) throws RepositoryException { - for (final ContentDefinitionImpl contentDefinition : configurationModel.getContentDefinitions()) { - final JcrPath contentRootPath = contentDefinition.getNode().getJcrPath(); - final String contentRoot = contentRootPath.toMinimallyIndexedPath().toString(); - if (contentRootPath.startsWith(deletedConfig) && !deletedContent.matches(contentRoot)) { - // content root found as child of a deleted config path, which itself, or a parent path, hasn't been recorded as deleted yet - deletedContent.removeChildren(contentRoot); - deletedContent.add(contentRoot); - } - } - } - /** * Because we've processed jcrNode's children in order, all new definitions (add node) are already in the correct * order. To fix the ordering of inserted and reordered nodes, we walk over jcrNode's children again, comparing ===================================== engine/src/main/java/org/onehippo/cm/engine/autoexport/EventChanges.java ===================================== --- a/engine/src/main/java/org/onehippo/cm/engine/autoexport/EventChanges.java +++ b/engine/src/main/java/org/onehippo/cm/engine/autoexport/EventChanges.java @@ -22,6 +22,9 @@ import javax.jcr.RepositoryException; import org.hippoecm.repository.api.RevisionEvent; import org.onehippo.cm.model.impl.ConfigurationModelImpl; +import org.onehippo.cm.model.impl.definition.ContentDefinitionImpl; +import org.onehippo.cm.model.path.JcrPath; +import org.onehippo.cm.model.path.JcrPaths; import org.onehippo.cm.model.tree.ConfigurationItemCategory; /** @@ -106,9 +109,11 @@ class EventChanges { recordAddedNode(paths, eventPath); } else if (deletedNode) { recordDeletedNode(paths, eventPath); - // Note: if a *config* path is deleted, it also may have *content* children, but we don't need to consider those here - // as the AutoExportConfigExporter (handling the config delete) will also *then* check and register such deleted content subpaths + // Note: if a *config* path is deleted, it also may have *content* children, so we need to check and register such deleted content subpaths // to be thereafter processed by the DefinitionMergeService + if (category == ConfigurationItemCategory.CONFIG) { + checkDeletedContentChildren(JcrPaths.getPath(eventPath)); + } } final String parentPath = eventPath.substring(0, eventPath.lastIndexOf('/') == 0 ? 1 : eventPath.lastIndexOf('/')); if (category == ConfigurationItemCategory.CONFIG) { @@ -123,6 +128,22 @@ class EventChanges { } } + /* + * When a config node is deleted (in jcr), check if there were child nodes which mapped to *content* definitions, + * and if so record these as 'to be deleted' content paths for the DefinitionMergeService to handle later. + */ + protected void checkDeletedContentChildren(final JcrPath deletedConfig) throws RepositoryException { + for (final ContentDefinitionImpl contentDefinition : model.getContentDefinitions()) { + final JcrPath contentRootPath = contentDefinition.getNode().getJcrPath(); + final String contentRoot = contentRootPath.toMinimallyIndexedPath().toString(); + if (contentRootPath.startsWith(deletedConfig) && !contentPaths.deleted.matches(contentRoot)) { + // content root found as child of a deleted config path, which itself, or a parent path, hasn't been recorded as deleted yet + contentPaths.deleted.removeChildren(contentRoot); + contentPaths.deleted.add(contentRoot); + } + } + } + /* Merge new (current) changes onto pending changes */ public void mergeCurrentChanges(EventChanges currentChanges) { changedNsPrefixes.addAll(currentChanges.getChangedNsPrefixes()); ===================================== engine/src/main/java/org/onehippo/cm/engine/autoexport/EventJournalProcessor.java ===================================== --- a/engine/src/main/java/org/onehippo/cm/engine/autoexport/EventJournalProcessor.java +++ b/engine/src/main/java/org/onehippo/cm/engine/autoexport/EventJournalProcessor.java @@ -539,7 +539,7 @@ public class EventJournalProcessor { } final AutoExportConfigExporter autoExportConfigExporter = - new AutoExportConfigExporter(currentModel, autoExportConfig, addedContent, deletedContent); + new AutoExportConfigExporter(currentModel, autoExportConfig, addedContent); for (String path : pendingChanges.getChangedConfig()) { log.info("Computing diff for path: \n\t{}", path); autoExportConfigExporter.exportConfigNode(eventProcessorSession, path, configSource); View it on GitLab: https://code.onehippo.org/cms-community/hippo-repository/commit/0e78486f64b39698382bc87785fd6ab31ec6a5b9 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-repository/commit/0e78486f64b39698382bc87785fd6ab31ec6a5b9 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