How to get all the changes in Workflow custom process? | Community
Skip to main content
Level 3
July 1, 2023
Solved

How to get all the changes in Workflow custom process?

  • July 1, 2023
  • 3 replies
  • 761 views

Scenario:

Authors adding a new image or modifying an existing image in a page and create workflow for publishing the page. I use a Custom Workflow process step to publish the content and also construct & migrate the package to another AEM instance via curl. The problem I'm facing is, in the custom workflow process class, I get only the page (which the Author is trying to publish) in the payload and not the image added/modified. 

Is there a way to get the image as well so that I can add the same in filter and migrate the package. Please help.

Thanks,

Rakesh

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by DPrakashRaj

You can write aem query to find all images in aem pages or think an easy option is to use AssetSearchReferenceAPI, this will return a list of all the assets associated with a page, 

Here you have a full code sample of how to use it: https://github.com/Adobe-Marketing-Cloud/aem-samples/blob/master/tutorial-referenced-assets/bundle/s... . 

3 replies

DPrakashRaj
Community Advisor
DPrakashRajCommunity AdvisorAccepted solution
Community Advisor
July 2, 2023

You can write aem query to find all images in aem pages or think an easy option is to use AssetSearchReferenceAPI, this will return a list of all the assets associated with a page, 

Here you have a full code sample of how to use it: https://github.com/Adobe-Marketing-Cloud/aem-samples/blob/master/tutorial-referenced-assets/bundle/s... . 

Shashi_Mulugu
Community Advisor
Community Advisor
July 3, 2023

@rakesh_h2 instead of this custom workflow process, did you guys evaluated replication agent (AEM On-Prem or AMS) or Sling Distribution (AEM Cloud)? It will internally take care of References publish as well. Also Adobe has many scripts and Now a Cloud manager option to sync content abd images across AEM environments. Please reevaluate your usecase.

aanchal-sikka
Community Advisor
Community Advisor
July 3, 2023

Hello @rakesh_h2 

 

As @dprakashraj  mentioned, we can use the AssetReferenceSearch API to be the list of Assets used in a Page.

 

Once you get the list of Assets, publish only the ones that need to be:

- Never published assets

- Unpublished assets

- Modified after publish.

 

If we publish more than what is needed it can cause performance issues, because of following reasons:

- assets take more resources

- Unnecessary cache flush

 

String Pagepath = "/content/geometrixx/en"; //This would be your page path Resource r = resourceResolver.getResource(Pagepath + "/" + JcrConstants.JCR_CONTENT); Node n = r.adaptTo(Node.class); AssetReferenceSearch ref = new AssetReferenceSearch(n, DamConstants.MOUNTPOINT_ASSETS, resourceResolver); Map<String, Asset> allref = new HashMap<String, Asset>(); allref.putAll(ref.search()); for (Map.Entry<String, Asset> entry : allref.entrySet()) { Asset asset = entry.getValue(); final ReplicationStatus replStatus = asset.adaptTo(ReplicationStatus.class); if (replStatus != null) { //will give you activation status ... if (replStatus.isActivated()) { //do not publish } } }
Aanchal Sikka