Hi All,
Since our migration from on-prem to cloud aem we've been finding missmatches in the publish status of several pages.
In the author the page will show as unpublished but will be active in the published instance.
I would like to somehow grab a report of all the pages in a particular path in the publisher and compare it to a report i've run in the author but so far I have not been able to find a way to grab a report of the pages sitting in the publisher..
Does anyone know a way I can generate such a report? I can of course view the publisher version of the pages in the developer console but have not been able to get a report that I can use to help bring our environment back into sync.
Kindest Regards,
Solved! Go to Solution.
Views
Replies
Total Likes
@RooRue You can write a servlet similar to this and hit it on the publish instance. This will query all the pages residing under "/content" and print it in logs. You can customize to make it a report based on the requirement. You can also change "/content" to any other path and it will bring all the pages residing under that.
@Component(service= Servlet.class,
property={
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths="+ "/bin/getAllPages"
})
public class GetAllPages extends SlingSafeMethodsServlet {
private static final Logger LOG = LoggerFactory.getLogger(GetAllPages.class);
@Reference
private transient QueryBuilder queryBuilder;
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
Map<String, String> searchCriteria = new HashMap<>();
searchCriteria.put("path", "/content");
searchCriteria.put("type", "cq:Page");
searchCriteria.put("p.limit", "-1");
ResourceResolver resourceResolver = request.getResource().getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
PredicateGroup predicateGroup = PredicateGroup.create(searchCriteria);
Query query = queryBuilder.createQuery(predicateGroup, session);
SearchResult result = query.getResult();
for (Hit hit : result.getHits()) {
try {
LOG.info("pages: {}", hit.getPath());
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
}
}
Regards,
Ayush
@RooRue You can write a simple scheduler/servlet to run it in "publish" run mode and make a query of all the pages in a particular path. Then you can compare it with author.
Hi Saravanan,
Thanks for the reply, would there be a guide I could follow for this? I am quite new to everything in this space and benefit greatly from a little hand holding haha.
@RooRue You can write a servlet similar to this and hit it on the publish instance. This will query all the pages residing under "/content" and print it in logs. You can customize to make it a report based on the requirement. You can also change "/content" to any other path and it will bring all the pages residing under that.
@Component(service= Servlet.class,
property={
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths="+ "/bin/getAllPages"
})
public class GetAllPages extends SlingSafeMethodsServlet {
private static final Logger LOG = LoggerFactory.getLogger(GetAllPages.class);
@Reference
private transient QueryBuilder queryBuilder;
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
Map<String, String> searchCriteria = new HashMap<>();
searchCriteria.put("path", "/content");
searchCriteria.put("type", "cq:Page");
searchCriteria.put("p.limit", "-1");
ResourceResolver resourceResolver = request.getResource().getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
PredicateGroup predicateGroup = PredicateGroup.create(searchCriteria);
Query query = queryBuilder.createQuery(predicateGroup, session);
SearchResult result = query.getResult();
for (Hit hit : result.getHits()) {
try {
LOG.info("pages: {}", hit.getPath());
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
}
}
Regards,
Ayush
Hello @RooRue
We can write a Groovy Script or a Servlet to validate the same.
- If you want to run the script on local, take a package from Author and install locally (Please check is the publishing data is retained, else you can run the script on server. The publishing status will help you categorize if page has been published at all)
- Drill through the hierarchy in AEM author.
- Validate the page for existence on AEM publish (If all pages on publish are public, you can just append the publish dispatcher URL and validate)
- If you find any discrepancy, write it to an excel.
- The excel can then be shared with the business, to review pages before publishing. Please note this is important, because there might be edits, which are not present on publish yet.
@RooRue ,
Have you tried Report builder from ACS Commons? https://adobe-consulting-services.github.io/acs-aem-commons/features/report-builder/index.html
You may need to login onto publish servers to run the report.
Views
Likes
Replies
Views
Like
Replies