I am working on AEM 6.2 and have created a custom replication module. I have some properties in my page's child nodes under jcr:content,whose values are the path field to another pages in the same website. when I am activating a page, I need to activate the pages referenced in the properties too. For example, my page path is "/content/project/family/subfamily/TestPage" I need to activate a page path in the node property "pathVal" under "/content/project/family/subfamily/TestPage/abc123/jcr:content". How do I do this?
2 Answers
0
votes
I am not sure what you mean by
custom replication module
Writing a replication Preprocessor
(see docs) may be a way to go. The replication process collects all implementations of that interface using the whiteboard pattern and then cycles through them invoking each one of them.
@Component
@Service
public class ReferencedPagePreprocessor implements Preprocessor {
@Reference
private Replicator replicator;
@Reference
private ResourceResolverFactory resolverFactory;
public void preprocess(ReplicationAction action, ReplicationOptions options) {
// some extra filtering to avoid the calculation if it's not the expected page type
String resourcePath = action.getPath();
ResourceResolver resolver = getResolver();
Resource resource = resolver.resolve(resourcePath);
String referencedResourcePath = resource.adaptTo(ValueMap.class).get("pathVal", String.class);
replicator.replicate(resolver.adaptTo(Session.class), ReplicationActionType.ACTIVATE, referencedResourcePath);
}
private ResourceResolver getResolver() {
...
}
}
Take also a look into a sample implementation in ACS AEM Commons
0
votes
If I understand correctly either you have implemented your own workflow process that activates the page or you would have followed the approach of Preprocessor
as outlined by Mateusz Chromiński.
In case you have written your own workflow process that invokes Replicator
API you could effectively add logic to get referenced paths and call activate on them using Replicator
API