jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r781017 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logg...
Date Tue, 02 Jun 2009 12:36:44 GMT
Author: angela
Date: Tue Jun  2 12:36:43 2009
New Revision: 781017

URL: http://svn.apache.org/viewvc?rev=781017&view=rev
Log:
JCR-2004: Update SPI locking to match JCR 2.0

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrLockManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManager.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrLockManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrLockManager.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrLockManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrLockManager.java
Tue Jun  2 12:36:43 2009
@@ -93,7 +93,7 @@
      *
      * @see javax.jcr.lock.LockManager#getLockTokens()
      */
-    public String[] getLockTokens() {
+    public String[] getLockTokens() throws RepositoryException {
         return lockStateMgr.getLockTokens();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Tue Jun  2 12:36:43 2009
@@ -463,7 +463,12 @@
      * @see javax.jcr.Session#getLockTokens()
      */
     public String[] getLockTokens() {
-        return getLockStateManager().getLockTokens();
+        try {
+            return getLockStateManager().getLockTokens();
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve lock tokens for this session. (" + e.getMessage()
+ ")");            
+            return new String[0];
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Tue Jun  2 12:36:43 2009
@@ -100,7 +100,6 @@
 import javax.jcr.ItemExistsException;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.MergeException;
-import javax.jcr.Session;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.version.VersionException;
@@ -211,15 +210,15 @@
         return service.getWorkspaceNames(sessionInfo);
     }
 
-    public IdFactory getIdFactory() throws RepositoryException {
+    public IdFactory getIdFactory() {
         return idFactory;
     }
 
-    public NameFactory getNameFactory() throws RepositoryException {
+    public NameFactory getNameFactory() {
         return nameFactory;
     }
 
-    public PathFactory getPathFactory() throws RepositoryException {
+    public PathFactory getPathFactory()  {
         return pathFactory;
     }
 
@@ -231,44 +230,42 @@
         return service.getLockInfo(sessionInfo, nodeId);
     }
 
-    public String[] getLockTokens() {
+    /**
+     * Returns the lock tokens present with the <code>SessionInfo</code>.
+     *
+     * @return lock tokens present with the <code>SessionInfo</code>.
+     * @throws UnsupportedRepositoryOperationException
+     * @throws RepositoryException
+     * @see org.apache.jackrabbit.spi.SessionInfo#getLockTokens() 
+     */
+    public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException
{
         return sessionInfo.getLockTokens();
     }
 
     /**
-     * This method always succeeds.
-     * This is not compliant to the requirements for {@link Session#addLockToken(String)}
-     * as defined by JSR170, which defines that at most one single <code>Session</code>
-     * may contain the same lock token. However, with SPI it is not possible
-     * to determine, whether another session holds the lock, nor can the client
-     * determine, which lock this token belongs to. The latter would be
-     * necessary in order to build the 'Lock' object properly.
+     * This method succeeds if the lock tokens could be added to the
+     * <code>SessionInfo</code>.
      *
      * @param lt
+     * @throws UnsupportedRepositoryOperationException
      * @throws LockException
      * @throws RepositoryException
+     * @see SessionInfo#addLockToken(String)
      */
-    public void addLockToken(String lt) throws LockException, RepositoryException {
+    public void addLockToken(String lt) throws UnsupportedRepositoryOperationException, LockException,
RepositoryException {
         sessionInfo.addLockToken(lt);
-        /*
-        // TODO: JSR170 defines that a token can be present with one session only.
-        //       however, we cannot find out about another session holding the lock.
-        //       and neither knows the server, which session is holding a lock token.
-        */
     }
 
     /**
-     * Tries to remove the given token from the <code>SessionInfo</code>. If
the
-     * SessionInfo does not contains the specified token, this method returns
-     * silently.<br>
-     * Note, that any restriction regarding removal of lock tokens must be asserted
-     * before this method is called.
+     * Tries to remove the given token from the <code>SessionInfo</code>.
      *
      * @param lt
+     * @throws UnsupportedRepositoryOperationException
      * @throws LockException
      * @throws RepositoryException
+     * @see SessionInfo#removeLockToken(String)
      */
-    public void removeLockToken(String lt) throws LockException, RepositoryException {
+    public void removeLockToken(String lt) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException {
         String[] tokems = sessionInfo.getLockTokens();
         for (int i = 0; i < tokems.length; i++) {
             if (tokems[i].equals(lt)) {
@@ -278,7 +275,7 @@
         }
         // sessionInfo doesn't contain the given lock token and is therefore
         // not the lock holder
-        throw new RepositoryException("Unable to remove locktoken '" + lt + "' from Session.");
+        throw new LockException("Unable to remove locktoken '" + lt + "' from Session.");
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
Tue Jun  2 12:36:43 2009
@@ -33,7 +33,6 @@
 import org.apache.jackrabbit.spi.LockInfo;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,6 +41,7 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import java.util.HashMap;
@@ -192,7 +192,7 @@
      *
      * @see LockStateManager#getLockTokens()
      */
-    public String[] getLockTokens() {
+    public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException
{
         return wspManager.getLockTokens();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManager.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManager.java
Tue Jun  2 12:36:43 2009
@@ -114,7 +114,7 @@
      * @return The lock tokens associated with the <code>Session</code> this
      * lock manager has been created for.
      */
-    public String[] getLockTokens();
+    public String[] getLockTokens() throws RepositoryException;
 
     /**
      * Invoked by a session to inform that a lock token has been added.

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java
Tue Jun  2 12:36:43 2009
@@ -18,6 +18,8 @@
 
 import org.apache.jackrabbit.spi.SessionInfo;
 
+import javax.jcr.RepositoryException;
+
 /**
  * Log wrapper for a {@link SessionInfo}.
  */
@@ -60,26 +62,26 @@
         }, "getWorkspaceName()", new Object[]{});
     }
 
-    public String[] getLockTokens() {
-        return (String[]) execute(new SafeCallable() {
-            public Object call() {
+    public String[] getLockTokens() throws RepositoryException {
+        return (String[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
                 return sessionInfo.getLockTokens();
             }
         }, "getLockTokens()", new Object[]{});
     }
 
-    public void addLockToken(final String lockToken) {
-        execute(new SafeCallable() {
-            public Object call() {
+    public void addLockToken(final String lockToken) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
                 sessionInfo.addLockToken(lockToken);
                 return null;
             }
         }, "addLockToken(String)", new Object[]{lockToken});
     }
 
-    public void removeLockToken(final String lockToken) {
-        execute(new SafeCallable() {
-            public Object call() {
+    public void removeLockToken(final String lockToken) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
                 sessionInfo.removeLockToken(lockToken);
                 return null;
             }

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
Tue Jun  2 12:36:43 2009
@@ -16,6 +16,10 @@
  */
 package org.apache.jackrabbit.spi;
 
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+
 /**
  * <code>SessionInfo</code> is created upon
  * {@link RepositoryService#obtain(javax.jcr.Credentials, String)} or
@@ -51,8 +55,10 @@
      * Returns the lock tokens present on this <code>SessionInfo</code>.
      *
      * @return lock tokens present on this <code>SessionInfo</code>.
+     * @throws UnsupportedRepositoryOperationException If locking is not supported.
+     * @throws RepositoryException If another error occurs.
      */
-    public String[] getLockTokens();
+    public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException;
 
     /**
      * Add the given lock token to this <code>SessionInfo</code>. The token will
@@ -60,8 +66,12 @@
      * lock identified by the given token.
      *
      * @param lockToken to be added.
+     * @param lockToken
+     * @throws UnsupportedRepositoryOperationException If locking is not supported.
+     * @throws LockException If the token cannot be added.
+     * @throws RepositoryException If another error occurs.
      */
-    public void addLockToken(String lockToken);
+    public void addLockToken(String lockToken) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException;
 
     /**
      * Removes the given lock token from this <code>SessionInfo</code>.
@@ -72,6 +82,9 @@
      * with LockException provided the lock hasn't been released.
      *
      * @param lockToken to be removed.
+     * @throws UnsupportedRepositoryOperationException If locking is not supported.
+     * @throws LockException If the token cannot be removed.
+     * @throws RepositoryException If another error occurs.
      */
-    public void removeLockToken(String lockToken);
+    public void removeLockToken(String lockToken) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException;
 }

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
Tue Jun  2 12:36:43 2009
@@ -380,10 +380,15 @@
     }
 
     private static void addIfHeader(SessionInfo sInfo, HttpMethod method) {
-        String[] locktokens = sInfo.getLockTokens();
-        if (locktokens != null && locktokens.length > 0) {
-            IfHeader ifH = new IfHeader(locktokens);
-            method.setRequestHeader(ifH.getHeaderName(), ifH.getHeaderValue());
+        try {
+            String[] locktokens = sInfo.getLockTokens();
+            if (locktokens != null && locktokens.length > 0) {
+                IfHeader ifH = new IfHeader(locktokens);
+                method.setRequestHeader(ifH.getHeaderName(), ifH.getHeaderValue());
+            }
+        } catch (RepositoryException e) {
+            // should never get here
+            log.error("Unable to retrieve lock tokens: omitted from request header.");
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml Tue Jun  2 12:36:43 2009
@@ -69,7 +69,6 @@
               <value>
                 org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryTest#testReRegisteredNamespaceVisibility
                 org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryTest#testRegisteredNamespaceVisibility
-                org.apache.jackrabbit.test.api.lock.LockManagerTest
                 org.apache.jackrabbit.test.api.observation.GetDateTest
                 org.apache.jackrabbit.test.api.observation.GetIdentifierTest
                 org.apache.jackrabbit.test.api.observation.GetInfoTest

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java?rev=781017&r1=781016&r2=781017&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/SessionInfoImpl.java
Tue Jun  2 12:36:43 2009
@@ -35,6 +35,8 @@
 import javax.jcr.Session;
 import javax.jcr.RepositoryException;
 import javax.jcr.Credentials;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.LockException;
 import java.io.ObjectInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ObjectOutputStream;
@@ -225,21 +227,21 @@
     /**
      * @inheritDoc
      */
-    public String[] getLockTokens() {
-        return session.getLockTokens();
+    public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException
{
+        return session.getWorkspace().getLockManager().getLockTokens();
     }
 
     /**
      * @inheritDoc
      */
-    public void addLockToken(String lockToken) {
-        session.addLockToken(lockToken);
+    public void addLockToken(String lockToken) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException {
+        session.getWorkspace().getLockManager().addLockToken(lockToken);
     }
 
     /**
      * @inheritDoc
      */
-    public void removeLockToken(String lockToken) {
-        session.removeLockToken(lockToken);
+    public void removeLockToken(String lockToken) throws UnsupportedRepositoryOperationException,
LockException, RepositoryException {
+        session.getWorkspace().getLockManager().removeLockToken(lockToken);
     }
 }



Mime
View raw message