Unlocking a page with system user | Community
Skip to main content
Level 2
Feb 8, 2019 7:30 PM UTC
Solved

Unlocking a page with system user

Hi,

While coding a WorkflowProcess implementation, I need to create a "system user" who can unlock pages.

Pages are locked through a WorkflowSession on a previous workflow step.

How can I give the "system user" the permissions to unlock pages?

Obviously I don't what to use an admin session, and I'm wondering how can I grant unlock permissions in AEM Security Permissions tab!

Thank you,

Lir

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
Feb 14, 2019 6:57 PM UTC

I'd read a thread somewhere which I'll try to find again & post here. It mentioned that 'page.canUnlock()' won't work but 'page.unlock()' will.

28 replies

smacdonald2008
Level 10
Feb 9, 2019 9:41 PM UTC

"Can't I use the unlock() method of com.day.cq.wcm.api.Page ?"

You should be able to use this method while getting a session of a system user that has read/write privileges of this part of the AEM JCR.

Keep in mind - you cannot use a SYstem User to manually perform tasks. A system user is used in code.

I will test this use case.

Translate
lirAuthor
Level 2
Feb 8, 2019 10:39 PM UTC

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.

Translate
Gaurav-Behl
Level 10
Feb 8, 2019 9:52 PM UTC

that's even a better approach!

I assume that you don't plan to create a system user on the fly and then assign permissions to it programmatically? Could you share your requirements/solution approach if you are plan to go down this path?

Translate
lirAuthor
Level 2
Feb 8, 2019 9:39 PM UTC

Thanks for the reply,

Can't I use the unlock() method of com.day.cq.wcm.api.Page ?

I already use Page's lock() method to lock it.

Translate
Gaurav-Behl
Level 10
Feb 8, 2019 8:28 PM UTC

The system user should be created as a read/write service user which means the user would have read/write access to that content path/ specific nodes.

For unlocking the pages, the service user would simply delete specific properties on that content node.

Properties for locking/unlocking:

cr:lockIsDeep

Boolean

true

jcr:lockOwner

String

<username>

jcr:mixinTypes

Name[]

mix:lockable

Translate