jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1232530 - in /jackrabbit/branches/2.4: ./ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/ jackrabbit-jcr-tests/src/main/java/org/apache/jackra...
Date Tue, 17 Jan 2012 18:38:58 GMT
Author: jukka
Date: Tue Jan 17 18:38:58 2012
New Revision: 1232530

URL: http://svn.apache.org/viewvc?rev=1232530&view=rev
Log:
2.4: Merged revision 1230688 (JCR-3205)

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
    jackrabbit/branches/2.4/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 17 18:38:58 2012
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1221447,1221579,1221593,1221789,1221818,1225179,1225191,1225196,1225207,1225525,1225528,1226452,1226472,1226515,1226750,1226863,1227171,1227240,1227590,1227593,1227615,1228058,1228149,1228155,1228160,1230507,1230681,1232100
+/jackrabbit/trunk:1221447,1221579,1221593,1221789,1221818,1225179,1225191,1225196,1225207,1225525,1225528,1226452,1226472,1226515,1226750,1226863,1227171,1227240,1227590,1227593,1227615,1228058,1228149,1228155,1228160,1230507,1230681,1230688,1232100

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=1232530&r1=1232529&r2=1232530&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
Tue Jan 17 18:38:58 2012
@@ -666,7 +666,15 @@ public class DefaultItemCollection exten
             }
             try {
                 boolean sessionScoped = EXCLUSIVE_SESSION.equals(reqLockInfo.getScope());
-                Lock jcrLock = ((Node)item).lock(reqLockInfo.isDeep(), sessionScoped);
+                long timeout = reqLockInfo.getTimeout();
+                if (timeout == LockInfo.INFINITE_TIMEOUT) {
+                    timeout = Long.MAX_VALUE;
+                } else {
+                    timeout = timeout/1000;
+                }
+                javax.jcr.lock.LockManager lockMgr = getRepositorySession().getWorkspace().getLockManager();
+                Lock jcrLock = lockMgr.lock((item).getPath(), reqLockInfo.isDeep(),
+                        sessionScoped, timeout, reqLockInfo.getOwner());
                 ActiveLock lock = new JcrActiveLock(jcrLock);
                  // add reference to DAVSession for this lock
                 getSession().addReference(lock.getToken());

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java?rev=1232530&r1=1232529&r2=1232530&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
Tue Jan 17 18:38:58 2012
@@ -124,14 +124,21 @@ public class JcrActiveLock extends Abstr
     }
 
     /**
-     * Since jcr locks do not reveal the time left until they expire, {@link #INFINITE_TIMEOUT}
-     * is returned. A missing timeout causes problems with Microsoft clients.
+     * Calculates the milliseconds of the timeout from
+     * {@link javax.jcr.lock.Lock#getSecondsRemaining()}. If the timeout of
+     * jcr lock is undefined or infinite {@link #INFINITE_TIMEOUT} is
+     * returned. A missing timeout causes problems with Microsoft clients.
      *
      * @return Always returns {@link #INFINITE_TIMEOUT}
      * @see ActiveLock#getTimeout()
      */
     public long getTimeout() {
-        return INFINITE_TIMEOUT;
+        try {
+            long to = lock.getSecondsRemaining();
+            return (to == Long.MAX_VALUE) ? INFINITE_TIMEOUT : to*1000;
+        } catch (RepositoryException e) {
+            return INFINITE_TIMEOUT;
+        }
     }
 
     /**

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java?rev=1232530&r1=1232529&r2=1232530&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
Tue Jan 17 18:38:58 2012
@@ -265,9 +265,11 @@ public abstract class AbstractLockTest e
         // only test if timeout hint was respected.
         long remaining = lock.getSecondsRemaining();
         if (remaining <= hint) {
-            try {
-                wait(remaining * 4000); // wait four time as long to be safe
-            } catch (InterruptedException ignore) {
+            if (remaining > 0) {
+                try {
+                    wait(remaining * 4000); // wait four time as long to be safe
+                } catch (InterruptedException ignore) {
+                }
             }
             long secs = lock.getSecondsRemaining();
             assertTrue(
@@ -286,6 +288,24 @@ public abstract class AbstractLockTest e
     }
 
     /**
+     * Test expiration of the lock
+     */
+    public synchronized void testOwnerHint()
+            throws RepositoryException, NotExecutableException {
+        lockedNode.unlock();
+
+        lock = lockMgr.lock(lockedNode.getPath(), isDeep(), isSessionScoped(), Long.MAX_VALUE,
"test");
+
+        String owner = lock.getLockOwner();
+        if (!"test".equals(lock.getLockOwner())) {
+            throw new NotExecutableException();
+        } else {
+            assertTrue(lockedNode.hasProperty(Property.JCR_LOCK_OWNER));
+            assertEquals("test", lockedNode.getProperty(Property.JCR_LOCK_OWNER).getString());
+        }
+    }
+
+    /**
      * Test if Lock is properly released.
      * 
      * @throws RepositoryException



Mime
View raw message