Adobe-Consulting-Services / acs-aem-commons

http://adobe-consulting-services.github.io/acs-aem-commons/
Apache License 2.0
453 stars 598 forks source link

Versioning not created if runner is synthetic #2527

Open HardikCharadva opened 3 years ago

HardikCharadva commented 3 years ago

Required Information

Expected Behavior

In our publish workflow we have 2 custom step which is responsible for updating metadata fields like asset status and setting published date. In order to prevent conflict with xmp writeback we disable triggering it during the above custom step and added 2 process step in publish workflow. [1] set last modified date [2] xmp process XMP process step is having create revision flag true , so it will create revision and as it require user id to create revision we set that user id as below in 2nd custom step. // User ID is required to create version of the asset during xmp process workItem.getWorkflowData().getMetaDataMap().put("userId", "XXX");

So now when we run publish workflow on any asset it's properly perform all step and during xmp process version created successfully.

But in case of when we do bulk publish using bulk workflow manager with runner = synthetic multithreaded , it's giving null pointing exception in xmp process, because while creating revision it's unable to get user id.

Expected : Version should create of asset , as we have added user id in MetaDataMap so ideally it should exist while version creation, not sure why it's not picking up.

Even if you run OOTB DAM metadata writeback workflow using synthetic runner, you will see version is not created and because it's giving null pointer exception, it's unable to update last modified and binaries of asset too.

Actual Behavior

Actual is version not created because user id not able to get during xmp process. As a result null pointer exception throws and it failed to update last modified and binaries of asset.

Steps to Reproduce

[1] Set up AEM 6.5.5 [2] Go to /content/dam [3] Upload 5 asset. [4] Got to BWM -> create new page -> double click on page to configure. [5] Select Engine : synthetic workflow multithreaded / single threaded [6] I provided query builder query to fetch require payloads path=/content/dam type=dam:Asset p.limit=-1 [7] Workflow : above i mentioned custom publish workflow , but for simplification, you can select DAM metadata writeback. [8] In order to capture logs you can put DEBUG on below com.day.cq.dam.core.process.XMPWritebackProcess com.day.cq.dam.core.impl.handler.xmp [9] Now if you run workflow it will give null pointer exception. You will notice last modified/ binaries not updated.

I have run publish workflow where in custom step i set user id as mentioned above description, so you can try that one as well.

Links

Links to related assets, e.g. content packages containing test components

HardikCharadva commented 3 years ago

@davidjgonzalez Hi Sir, Can you please help here to resolve the issue? Any suggestion.

davidjgonzalez commented 3 years ago

@HardikCharadva sorry - didn't see this.

So the problem is the user id isn't in the metadata map for that specific workflow step?

"Version should create of asset , as we have added user id in MetaDataMap so ideally it should exist while version creation, not sure why it's not picking up."

IIUC, you actually tried adding the user id yourself to the metadata map and it still fails?

HardikCharadva commented 3 years ago

Hi @davidjgonzalez - Thank you for your response.

Yes we are setting user id in our custom step.

Workflow consist of below steps :

1] Custom step to update status of asset. 2] Custom step of setting publish date (On this step , I am adding user id into the metadata map as below)

// User ID is required to create version of the asset during xmp process workItem.getWorkflowData().getMetaDataMap().put("userId", "XXX");

3] OOTB step added to set last modified of asset. 4] OOTB step to update binaries via xmp process step = During this step, create revision is true and it's using id that we set to create the revision which is not picking up during synthetic workflow running bulk publish activity.

5] Activate page/asset step

If I run the publish workflow on asset directly , it's generating version of asset successfully. please advise why it's not working through synthetic way.

thanks Hardik

davidjgonzalez commented 3 years ago

@HardikCharadva are you calling workflowSession.updateWorkflowData(..) after you are setting your userId? If not, i dont think that will persist through and could be the cause of your issue.

        workItem.getWorkflowData().getMetaDataMap().put("userId", "XXX");
        workflowSession.updateWorkflowData(workItem.getWorkflow(), workItem.getWorkflowData());
HardikCharadva commented 3 years ago

@davidjgonzalez Hi David, Andrew Khoury suggested to the same, so I have added as below : workItem.getWorkflowData().getMetaDataMap().put("userId", "XXX"); workItem.getWorkflow().getMetaDataMap().put("userId", "XXX"); workItem.getMetaDataMap().put("userId", "XXX"); workflowSession.updateWorkflowData(workItem.getWorkflow(), workItem.getWorkflowData());

Still it doesn't pick the user id during revision creation in xmp binary process step.

Please advise. Thanks.

HardikCharadva commented 3 years ago

@davidjgonzalez - Any update sir?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.