How to get all the changes in Workflow custom process? | Community
Skip to main content
Level 3
Jul 1, 2023 4:28 PM UTC
Solved

How to get all the changes in Workflow custom process?

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.
DPrakashRaj
DPrakashRajAccepted solution
New Participant
Jul 2, 2023 4:01 AM UTC

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

aanchal-sikka
New Participant
Jul 3, 2023 4:34 AM UTC

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 } } }
Translate
Aanchal Sikka
Shashi_Mulugu
New Participant
Jul 3, 2023 2:13 AM UTC

@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.

Translate
DPrakashRaj
DPrakashRajAccepted solution
New Participant
Jul 2, 2023 4:01 AM UTC

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... . 

Translate