Page lock property not working | Community
Skip to main content
vijays80591732
Level 3
July 6, 2020
Solved

Page lock property not working

  • July 6, 2020
  • 6 replies
  • 2236 views

Hello All,

 

I'm trying to add the below property via java code to lock the page, after performing some operation.  But, it's throwing ConstraintViolationException. 

 

Property I'm trying to add:

pageNode.setProperty("jcr:lockIsDeep", true);

 

Exception: 

javax.jcr.nodetype.ConstraintViolationException: Property is protected: jcr:lockIsDeep = true
	at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.setProperty(NodeDelegate.java:525) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1378) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1365) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:208) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1365) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:483) [org.apache.jackrabbit.oak-jcr:1.8.9]
	at com.sample.core.workflows.contentactivation.PublishContentToPreviewPublisher.lockPage(PublishContentToPreviewPublisher.java:116) [com.sample:2.0.0.SNAPSHOT]
	at com.sample.core.workflows.contentactivation.PublishContentToPreviewPublisher.execute(PublishContentToPreviewPublisher.java:75) [com.sample:2.0.0.SNAPSHOT]
	at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:198) [com.adobe.granite.workflow.core:2.0.168.CQ640-B0006]
	at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:261) [com.adobe.granite.workflow.core:2.0.168.CQ640-B0006]
	at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:502) [org.apache.sling.event:4.2.12]
	at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:293) [org.apache.sling.event:4.2.12]
	at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:60) [org.apache.sling.event:4.2.12]
	at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:229) [org.apache.sling.event:4.2.12]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Any Idea on how to set lock property to the node?

@smacdonald2008 @arunpatidar26 @Ratna_Kumar @kautuk_sahni @wimsymons @cqsapientu69896 @vanegi @Veena_Vikram @varuns7990 @Theo_Pendle

Regards,
Vijay
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 vijays80591732

Since I have used workflow, Using workflow session I'm able to lock and unlock the page. (page.lock() && page.unlock()). Thanks all for your valuable inputs.

6 replies

Varun_Shakya
Community Advisor
Community Advisor
July 6, 2020

Are you setting this property anonymously? May be anonymous user cant lock or unlock page. I think you need to create the admin session or system user session before setting this property and user should have access over that content. its just an assumption it  could be another issue.

Shashi_Mulugu
Community Advisor
Community Advisor
July 6, 2020

@vijays80591732 use pagemanager api page.lock() for locking the page.

 

Please see the below community post for reference 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/lock-unlock-using-page-api/qaq-p/308186

 

arunpatidar
Community Advisor
Community Advisor
July 6, 2020

Are you using workflow? If yes then check https://helpx.adobe.com/experience-manager/kb/workflow-lock-unlock-not-working-aem63.html

Otherwise check the properties, just adding property may not work. Use APIs.

Arun Patidar
vijays80591732
Level 3
July 9, 2020
Hi Arun, I'm using workflow package. Inside the worlfow package I have my page url's. So, in the workflow model, I will get the workflow package URL as a payload path. This link https://helpx.adobe.com/experience-manager/kb/workflow-lock-unlock-not-working-aem63.html is to lock and unlock the payload process/path. I'm unable to use this 😞
vanegi
Adobe Employee
Adobe Employee
July 6, 2020

Hello Vijay,

It seems that the page where you see the problem is checked in and it is unable to offload. This seems to be causing the problem. Please try to remove the check-in property by checking out.

 

Steps to checkout property:

 

- Go to /crx/explorer/index.jsp and log in as admin user.

- Open Content Explorer. Browse to the jcr: content subnode of the broken page. For example: /content/we-retail/en/services/jcr:content

- Go to Versions => CheckOut.

- Go to /sites.html UI and browse to the page and open it for editing. Unlock the page by clicking the lock icon on the top left.

 

Thanks,

Vaishali

Level 2
July 7, 2020

Hi @vijays80591732 ,

 

Probably the type of the node is inappropriate (type mix:lockable) 

Also,Prior locking the page add a condition check if its already locked (isDeep) if not checked would throw lock exception.

vijays80591732
vijays80591732AuthorAccepted solution
Level 3
July 14, 2020

Since I have used workflow, Using workflow session I'm able to lock and unlock the page. (page.lock() && page.unlock()). Thanks all for your valuable inputs.