So I'm trying to import some content from an Excel spreadsheet and save this to AEM.
After saving it to author, the data gets replicated to the publisher.
As part of the pre-import processes, I am deleting the destination folder and then recreate it.
The issue is that while the destination folder gets deleted in author, it doesn't get deleted in publisher.
Any ideas what I could be doing wrong? Thanks
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
try {
Session session = workflowSession.getSession();
ResourceResolver resourceResolver = getResourceResolver(session);
deleteNodes(session, resourceResolver);
} catch (Exception e) {
log.error("fish importer: Error in Fish Import Service", e);
}
}
private void deleteNodes(Session session, ResourceResolver resolver) throws RepositoryException, ReplicationException, PersistenceException {
Resource resource = resolver.getResource(rootPath); //rootPath = /content/data/fishes
if (resource != null){
Node node = resource.adaptTo(Node.class);
String name = node.getName();
Node parent = node.getParent();
node.remove();
replicate(rootPath, session, ReplicationActionType.DELETE);
resolver.commit();
}
}
protected void replicate(String path, Session jcrSession, ReplicationActionType activateType) throws ReplicationException {
if (activateType.equals(ReplicationActionType.ACTIVATE)) {
replicator.replicate(jcrSession, activateType, path);
} else {
ReplicationStatus status = replicator.getReplicationStatus(jcrSession, path);
if (status != null && status.isActivated()) {
replicator.replicate(jcrSession, activateType, path);
}
}
}