I ran into an issue when attempting to lock nodes using public users session, see sample code snippet bellow:
[code]Session session = MgnlContext.getJCRSession(CommonConstants.Repositories.DAM); Node root = session.getRootNode(); Node test = JcrUtils.getOrAddNode(root, "test1", CommonConstants.NodeTypes.FOLDER); test.addMixin("mix:lockable"); session.save(); LockManager lock = session.getWorkspace().getLockManager(); lock.lock(test.getPath(), false, true, 5000, MgnlContext.getUser().getIdentifier()); Node test2 = JcrUtils.getOrAddNode(root, "test2", CommonConstants.NodeTypes.FOLDER); session.save(); session.getWorkspace().getLockManager().unlock(test.getPath());[/code] Running this snippet will blow up with this error: [code] javax.jcr.lock.LockException: Node locked. at org.apache.jackrabbit.core.lock.LockManagerImpl.checkLock(LockManagerImpl.java:694) at org.apache.jackrabbit.core.lock.LockManagerImpl.checkLock(LockManagerImpl.java:670) at org.apache.jackrabbit.core.lock.LockManagerImpl.checkLock(LockManagerImpl.java:655) at org.apache.jackrabbit.core.lock.XALockManager.checkLock(XALockManager.java:174) at org.apache.jackrabbit.core.ItemValidator.checkLock(ItemValidator.java:367) at org.apache.jackrabbit.core.ItemValidator.checkCondition(ItemValidator.java:288) at org.apache.jackrabbit.core.ItemValidator.checkModify(ItemValidator.java:248) at org.apache.jackrabbit.core.NodeImpl.checkSetProperty(NodeImpl.java:984) at org.apache.jackrabbit.core.NodeImpl$SetPropertyOperation.perform(NodeImpl.java:2047) at org.apache.jackrabbit.core.NodeImpl$SetPropertyOperation.perform(NodeImpl.java:2002) at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216) at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1924) at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1966) at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:427) at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:229) at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:427) at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:229) at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:427) at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:229) at info.magnolia.audit.MgnlAuditLoggingContentDecoratorNodeWrapper.setProperty(MgnlAuditLoggingContentDecoratorNodeWrapper.java:190) at info.magnolia.jcr.util.NodeTypes$LastModified.update(NodeTypes.java:125) at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator$MgnlPropertySettingSessionWrapper.applyPendingChanges(MgnlPropertySettingContentDecorator.java:512) at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator$MgnlPropertySettingSessionWrapper.save(MgnlPropertySettingContentDecorator.java:502) at info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionWrapper.java:297) at info.magnolia.audit.MgnlAuditLoggingContentDecoratorSessionWrapper.save(MgnlAuditLoggingContentDecoratorSessionWrapper.java:82) at com.flavoryt.places.services.impl.AbstractAddPlaceService.addImage(AbstractAddPlaceService.java:202) at com.flavoryt.places.services.impl.DefaultAddPlaceService.addImage(DefaultAddPlaceService.java:206) at com.flavoryt.frontend.facades.impl.DefaultAddPlaceFacade.addImageForPlace(DefaultAddPlaceFacade.java:103) at com.flavoryt.frontend.controllers.PlacesController.addImageForPlace(PlacesController.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at info.magnolia.cms.filters.ServletDispatchingFilter.doFilter(ServletDispatchingFilter.java:148) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.filters.CompositeFilter.doFilter(CompositeFilter.java:65) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.VirtualUriFilter.doFilter(VirtualUriFilter.java:69) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.module.cache.executor.Bypass.processCacheRequest(Bypass.java:58) at info.magnolia.module.cache.executor.CompositeExecutor.processCacheRequest(CompositeExecutor.java:67) at info.magnolia.module.cache.filter.CacheFilter.doFilter(CacheFilter.java:174) at info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.i18n.I18nContentSupportFilter.doFilter(I18nContentSupportFilter.java:74) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.RangeSupportFilter.doFilter(RangeSupportFilter.java:84) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.security.BaseSecurityFilter.doFilter(BaseSecurityFilter.java:57) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.security.SecurityCallbackFilter.doFilter(SecurityCallbackFilter.java:80) at info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.security.LogoutFilter.doFilter(LogoutFilter.java:94) at info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.MultiChannelFilter.doFilter(MultiChannelFilter.java:83) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.module.cache.filter.GZipFilter.doFilter(GZipFilter.java:73) at info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81) at info.magnolia.cms.security.auth.login.LoginFilter.doFilter(LoginFilter.java:127) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.UnicodeNormalizationFilter.doFilter(UnicodeNormalizationFilter.java:88) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.CosMultipartRequestFilter.doFilter(CosMultipartRequestFilter.java:87) at info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.ContentTypeFilter.doFilter(ContentTypeFilter.java:148) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.ContextFilter.doFilter(ContextFilter.java:128) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79) at info.magnolia.cms.filters.CompositeFilter.doFilter(CompositeFilter.java:65) at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85) at info.magnolia.cms.filters.SafeDestroyMgnlFilterWrapper.doFilter(SafeDestroyMgnlFilterWrapper.java:107) at info.magnolia.cms.filters.MgnlFilterDispatcher.doDispatch(MgnlFilterDispatcher.java:67) at info.magnolia.cms.filters.MgnlMainFilter.doFilter(MgnlMainFilter.java:108) at info.magnolia.cms.filters.MgnlMainFilter.doFilter(MgnlMainFilter.java:94) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)[/code] However if i execute same code as a superuser: [code]return MgnlContext.doInSystemContext(new JCRSessionOp<Node>(CommonConstants.Repositories.DAM) { @Override public Node exec(Session session) throws RepositoryException { //Session session = MgnlContext.getJCRSession(CommonConstants.Repositories.DAM); Node root = session.getRootNode(); Node test = JcrUtils.getOrAddNode(root, "test1", CommonConstants.NodeTypes.FOLDER); test.addMixin("mix:lockable"); session.save(); LockManager lock = session.getWorkspace().getLockManager(); lock.lock(test.getPath(), false, true, 5000, MgnlContext.getUser().getIdentifier()); Node test2 = JcrUtils.getOrAddNode(root, "test2", CommonConstants.NodeTypes.FOLDER); session.save(); session.getWorkspace().getLockManager().unlock(test.getPath()); return test2; } });[/code] It works perfectly, however this is not ideal as this approach ignores the access permissions per user... Do you have to be superuser to perform node locks ? -- Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=a3f1e0a0-8331-4a95-a4e8-e591880db620 ---------------------------------------------------------------- For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <dev-list-unsubscr...@magnolia-cms.com> ----------------------------------------------------------------