Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Unable to unlock a page with system user using workflow in AEM 6.5

nandini559
Level 2
Level 2

Hello,

Is there a way to unlock a page using workflow ?

Steps followed:

1) Content editor will lock the page manually.

2) Start the workflow and before ending the workflow, there is unlock process step to unlock the page.

3) Page unlock would be done by system user.

4) I see error at page.unlock() . The error is 

com.day.cq.wcm.api.WCMException: Unable to unlock page. msg:::Unable to unlock page

Tried giving permissions like jcr:lockmanagement, jcr:all to that specific page from crx but no use.

Please suggest a way to make this possible.

1 Accepted Solution
berliant
Correct answer by
Employee
Employee
5 Replies
berliant
Correct answer by
Employee
Employee
Nupur_Jain
Community Advisor
Community Advisor

Hi @nandini559 

 

Please take reference from post https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/unlocking-a-page-with-syst.... This post had the similar issues as yours.

 

I went through the solutions and at the end it was concluded that "confirmed that a "system user" cannot unlock a page unless he owns the lock, no matter the permissions I give to him". At the end developer ended up chanding his flow to achive the same which is 

 

1- an AEM user initiates my custom workflow on a page

2- my WorkflowProcess implementation code, locks the page under the initiator session. This means that the initiator owns the lock of that page.

3- on a further down workflow step, my code needs to unlock the page, but the AEM user completing the step is not the same user as the one who owns the lock.

 

Therefore I have to manually (not programmatically) already have created a system user with permissions to unlock ANY page, AND have my code unlock the page under his session.

 

Go through the post and it should lead you to the solution. 

 

Hope it helps,

Nupur

nandini559
Level 2
Level 2
Thanks for your replies. The only solution i found to unlock the pages using system user is, he should own the lock.
AnjaliBiddanda
Level 2
Level 2
Hi @nandini559, did you have any luck with this? We have custom 'lock payload' and 'unlock payload' steps in our workflow. But the unlock step fails with "LockException: Not an owner of the lock". I've tried both LockManager API and Page API (LockManager.lock(), Page.lock()). And i've tried both wfSession (wfSession.adaptTo(Session.class)) and a serviceUser session (serviceResolver.adaptTo(Session.class)). And the user has jcr:all on the content path and on /home/groups. @Nupur_Jain i've followed that post, but had no luck. Any tips?
AnjaliBiddanda
Level 2
Level 2
Fixed: I was using session.getWorkspace().getLockManager() where session here was serviceUser session instead of wfSession. i.e. final LockManager lockManager = session.getWorkspace().getLockManager(); Here the session should ofcourse be wfSession.