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
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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.
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.
@vijays80591732 use pagemanager api page.lock() for locking the page.
Please see the below community post for reference
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.
Views
Replies
Total Likes
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
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.
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.
Views
Likes
Replies