Skip to content

Commit

Permalink
Also validate replication metadata in cq:Template nodes
Browse files Browse the repository at this point in the history
Newer AEM versions add references in
"com.day.cq.wcm.core.impl.reference.PageTemplateReferenceProvider" to
both the parent template resource and the child structure resource.

This closes #20
  • Loading branch information
kwin committed Jul 2, 2024
1 parent 3e20d82 commit b610c4f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
<localRepositoryPath>target/it-repo</localRepositoryPath> -->
<!-- enable to remote debug ITs
<mavenExecutable>${maven.home}/bin/mvnDebug</mavenExecutable> -->

</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<jcr:content
jcr:primaryType="cq:PageContent"
jcr:title="Page Template"
cq:lastReplicationAction="Activate"
status="enabled"/>
</jcr:root>
4 changes: 3 additions & 1 deletion src/it/project1/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replicat
assert buildLog.contains('[ERROR] Failed to execute goal org.apache.jackrabbit:filevault-package-maven-plugin:1.3.0:validate-package (default-validate-package) on project application-package: Found 2 violation(s) (with severity=ERROR). Check above errors for details -> [Help 1]') : 'Incorrect number of validation issues found'
// content package
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: The replication date 2019-10-22T20:34:50.533Z for agent publish is older than the last modification date 2020-07-09T15:11:09.069Z\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}wcm${File.separator}policies${File.separator}.content.xml, nodePath=/conf/example/settings/wcm/policies/wknd/components/container/content-default,") : 'policy violation not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: No replication date set for agent publish: Replication properties {http://www.day.com/jcr/cq/1.0}lastReplicated or {http://www.day.com/jcr/cq/1.0}lastPublished not found\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}wcm${File.separator}templates${File.separator}template1${File.separator}.content.xml, nodePath=/conf/example/settings/wcm/templates/template1/jcr:content, line=8, column=27") : 'template violation not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: The replication date 2021-12-31T23:00:00Z for agent publish is older than the last modification date 2022-01-01T23:00:00Z\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}wcm${File.separator}templates${File.separator}template1${File.separator}structure${File.separator}.content.xml, nodePath=/conf/example/settings/wcm/templates/template1/structure/jcr:content,") : 'template structure violation not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: Last replication action not allowed for this path but is ACTIVATE\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}wcm${File.separator}templates${File.separator}template1${File.separator}initial${File.separator}.content.xml, nodePath=/conf/example/settings/wcm/templates/template1/initial/jcr:content, line=12, column=19") : 'initial violation not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: Last replication date not allowed for this path but is 2021-12-31T23:00:00Z\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}wcm${File.separator}templates${File.separator}template1${File.separator}initial${File.separator}.content.xml, nodePath=/conf/example/settings/wcm/templates/template1/initial/jcr:content, line=12, column=19") : 'initial violation not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: No replication action set for agent publish: Replication property {http://www.day.com/jcr/cq/1.0}lastReplicationAction not found\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}my-segment${File.separator}.content.xml, nodePath=/conf/example/my-segment/jcr:content, line=19, column=19") : 'violation for segment page not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: No replication date set for agent publish: Replication properties {http://www.day.com/jcr/cq/1.0}lastReplicated or {http://www.day.com/jcr/cq/1.0}lastPublished not found\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}my-segment${File.separator}.content.xml, nodePath=/conf/example/my-segment/jcr:content, line=19, column=19") : 'violation for segment page not found'

// Content fragment models
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: No replication action set for agent publish: Replication property {http://www.day.com/jcr/cq/1.0}lastReplicationAction not found\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}dam${File.separator}cfm${File.separator}models${File.separator}speaker${File.separator}.content.xml, nodePath=/conf/example/settings/dam/cfm/models/speaker/jcr:content, line=105, column=19") : 'violation for content fragment model not found'
assert buildLog.contains("[ERROR] ValidationViolation: \"netcentric-aem-replication-metadata: No replication date set for agent publish: Replication properties {http://www.day.com/jcr/cq/1.0}lastReplicated or {http://www.day.com/jcr/cq/1.0}lastPublished not found\", filePath=jcr_root${File.separator}conf${File.separator}example${File.separator}settings${File.separator}dam${File.separator}cfm${File.separator}models${File.separator}speaker${File.separator}.content.xml, nodePath=/conf/example/settings/dam/cfm/models/speaker/jcr:content, line=105, column=19") : 'violation for content fragment model not found'


assert buildLog.contains('[ERROR] Failed to execute goal org.apache.jackrabbit:filevault-package-maven-plugin:1.3.0:validate-package (default-validate-package) on project content-package: Found 8 violation(s) (with severity=ERROR). Check above errors for details -> [Help 1]') : 'Incorrect number of validation issues found'
assert buildLog.contains('[ERROR] Failed to execute goal org.apache.jackrabbit:filevault-package-maven-plugin:1.3.0:validate-package (default-validate-package) on project content-package: Found 9 violation(s) (with severity=ERROR). Check above errors for details -> [Help 1]') : 'Incorrect number of validation issues found'
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@
<jcr:content
jcr:primaryType="cq:PageContent"
jcr:title="Page Template"
cq:lastReplicated="{Date}2022-01-01T00:00:00.000+01:00"
cq:lastReplicated_preview="{Date}2022-01-01T00:00:00.000+01:00"
cq:lastReplicated_publish="{Date}2022-01-01T00:00:00.000+01:00"
cq:lastReplicatedBy="Deployment"
cq:lastReplicatedBy_preview="Deployment"
cq:lastReplicatedBy_publish="Deployment"
cq:lastReplicationAction="Activate"
cq:lastReplicationAction_preview="Activate"
cq:lastReplicationAction_publish="Activate"
status="enabled"/>
</jcr:root>
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private Optional<NodeMetadata> getNodeMetadata(boolean isExclude, @NotNull Strin
if (!isNodeRelevant) {
return Optional.empty();
} else {
if (NameConstants.NT_PAGE.equals(patternAndType.getValue())) {
if (NameConstants.NT_PAGE.equals(patternAndType.getValue()) || NameConstants.NT_TEMPLATE.equals(patternAndType.getValue())) {
LOGGER.debug("Waiting for jcr:content below {}", nodePath);
currentMetadata = new NodeMetadata(isExclude, nodePath + "/" + NameConstants.NN_CONTENT, true);
relevantNodeMetadata.add(currentMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class AemReplicationMetadataValidatorFactory implements ValidatorFactory

private static Map<Pattern, String> createDefaultIncludeMap() {
Map<Pattern, String> map = new HashMap<>();
// by default: editable templates (as found by com.day.cq.wcm.core.impl.reference.PageTemplateReferenceProvider)
// by default: editable templates and their structure child (as found by com.day.cq.wcm.core.impl.reference.PageTemplateReferenceProvider)
map.put(Pattern.compile(".*/settings/wcm/templates/[^/]*"), NameConstants.NT_TEMPLATE);
map.put(Pattern.compile(".*/settings/wcm/templates/[^/]*/structure"), NameConstants.NT_PAGE);
// content policies mappings (as found by com.day.cq.wcm.core.impl.reference.ContentPolicyReferenceProvider)
map.put(Pattern.compile(".*/settings/wcm/templates/[^/]*/policies"), NameConstants.NT_PAGE);
Expand Down

0 comments on commit b610c4f

Please sign in to comment.