[ 
http://issues.apache.org/jira/browse/JCR-533?page=comments#action_12427271 ] 
            
Paco Avila commented on JCR-533:
--------------------------------

Yes, I know there is no need to call save. My attached program 
DummyLockAccessDenied.java doesn't call save() after the lock(). But in your 
added code:

+ try  {
+                // add properties to content
+                internalSetProperty(QName.JCR_LOCKOWNER,
+                        InternalValue.create(getSession().getUserID()));
+                internalSetProperty(QName.JCR_LOCKISDEEP,
+                        InternalValue.create(isDeep));
+                save();
+                succeeded = true;
+            } finally {
+                if (!succeeded) {
+                    // failed to set lock meta-data content, cleanup
+                    try {
+                        lockMgr.unlock(this);
+                        refresh(false); /******** HERE **********/
+                    } catch (RepositoryException re) {
+                        // cleanup failed
+                        log.error("error while cleaning up after failed lock 
attempt", re);
+                    }
+                }
+            }

you call refresh(false), invalidating transiente session. This should be done 
in client code. If I want to add a property in a protected node and the 
operation fails on save() because lack of permissions, I have to call a 
refresh(false) because of invalid transient session. This is the same case, 
after a lock() (I don't do save()) I should catch the AccessDeniedException and 
make a refresh(false).

> failing Node.lock() might leave inconsistent transient state
> ------------------------------------------------------------
>
>                 Key: JCR-533
>                 URL: http://issues.apache.org/jira/browse/JCR-533
>             Project: Jackrabbit
>          Issue Type: Bug
>          Components: locks
>    Affects Versions: 1.0.1
>         Environment: Ubuntu Dapper
>            Reporter: Paco Avila
>         Assigned To: Stefan Guggisberg
>         Attachments: DummyLockAccessDenied.java, 
> MyAccessManagerLockAccessDenied.java
>
>
> When I try to node.lock(true, false) a node and the lock fails due to lak of 
> user privilegies, the lock stay in the user transient session. If a perform a 
> node.refresh(false) the node still is locked in the transient session.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to