jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r582815 - in /jackrabbit/trunk/contrib/spi: jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/ spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ spi2jcr/src/main/java/org/apache...
Date Mon, 08 Oct 2007 13:13:41 GMT
Author: angela
Date: Mon Oct  8 06:13:39 2007
New Revision: 582815

URL: http://svn.apache.org/viewvc?rev=582815&view=rev
Log:
JCR-1159 SPI: improve description of locking methods on RepositoryService

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=582815&r1=582814&r2=582815&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Mon Oct  8 06:13:39 2007
@@ -415,7 +415,6 @@
         // NOTE: wspManager has already been disposed upon SessionItemStateManager.dispose()
     }
 
-
     IdFactory getIdFactory() {
         return wspManager.getIdFactory();
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=582815&r1=582814&r2=582815&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Mon Oct  8 06:13:39 2007
@@ -127,6 +127,7 @@
     private final HierarchyManager hierarchyManager;
     private final CacheBehaviour cacheBehaviour;
 
+    private final IdFactory idFactory;
     private final NamespaceRegistryImpl nsRegistry;
     private final NodeTypeRegistryImpl ntRegistry;
     private final ItemDefinitionProvider definitionProvider;
@@ -158,6 +159,7 @@
         this.sessionInfo = sessionInfo;
         this.cacheBehaviour = cacheBehaviour;
 
+        idFactory = service.getIdFactory();
         nsRegistry = createNamespaceRegistry(NamespaceCache.getInstance(service));
         ntRegistry = createNodeTypeRegistry(nsRegistry);
         changeFeed = createChangeFeed(pollTimeout, enableObservation);
@@ -165,7 +167,7 @@
 
         TransientItemStateFactory stateFactory = createItemStateFactory();
         this.isf = stateFactory;
-        this.hierarchyManager = createHierarchyManager(stateFactory, service.getIdFactory());
+        this.hierarchyManager = createHierarchyManager(stateFactory, idFactory);
         createHierarchyListener(hierarchyManager);
     }
 
@@ -182,7 +184,7 @@
     }
 
     public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider() {
-        return (NodeTypeRegistryImpl) ntRegistry;
+        return ntRegistry;
     }
 
     public HierarchyManager getHierarchyManager() {
@@ -194,14 +196,14 @@
     }
 
     public IdFactory getIdFactory() {
-        return service.getIdFactory();
+        return idFactory;
     }
 
     public ItemStateFactory getItemStateFactory() {
         return isf;
     }
 
-    public LockInfo getLockInfo(NodeId nodeId) throws LockException, RepositoryException
{
+    public LockInfo getLockInfo(NodeId nodeId) throws RepositoryException {
         return service.getLockInfo(sessionInfo, nodeId);
     }
 
@@ -515,7 +517,7 @@
         // identified by the resulting id.
         // the server must be able to deal with paths and with proper ids anyway.
         // TODO: 'createNodeId' is basically wrong since isGranted is unspecific for any
item.
-        ItemId id = getIdFactory().createNodeId((NodeId) parentState.getWorkspaceId(), relPath);
+        ItemId id = idFactory.createNodeId((NodeId) parentState.getWorkspaceId(), relPath);
         return service.isGranted(sessionInfo, id, actions);
     }
 
@@ -841,7 +843,7 @@
                 NodeId targetId;
                 Path relPath = operation.getRelativePath();
                 if (relPath != null) {
-                    targetId = getIdFactory().createNodeId(nId, relPath);
+                    targetId = idFactory.createNodeId(nId, relPath);
                 } else {
                     targetId = nId;
                 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=582815&r1=582814&r2=582815&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
Mon Oct  8 06:13:39 2007
@@ -315,10 +315,8 @@
     private LockState buildLockState(NodeState nodeState) throws RepositoryException {
         NodeId nId = nodeState.getNodeId();
         NodeState lockHoldingState = null;
-        LockInfo lockInfo;
-        try {
-            lockInfo = wspManager.getLockInfo(nId);
-        } catch (LockException e) {
+        LockInfo lockInfo = wspManager.getLockInfo(nId);
+        if (lockInfo == null) {
             // no lock present
             return null;
         }
@@ -438,10 +436,9 @@
      * lock info.
      *
      * @param lt
-     * @throws LockException
      * @throws RepositoryException
      */
-    private void notifyTokenAdded(String lt) throws LockException, RepositoryException {
+    private void notifyTokenAdded(String lt) throws RepositoryException {
         LockTokenListener[] listeners = (LockTokenListener[]) lockMap.values().toArray(new
LockTokenListener[lockMap.size()]);
         for (int i = 0; i < listeners.length; i++) {
             listeners[i].lockTokenAdded(lt);
@@ -453,10 +450,9 @@
      * removed lock token and allow them to reload their lock info, if necessary.
      *
      * @param lt
-     * @throws LockException
      * @throws RepositoryException
      */
-    private void notifyTokenRemoved(String lt) throws LockException, RepositoryException
{
+    private void notifyTokenRemoved(String lt) throws RepositoryException {
         LockTokenListener[] listeners = (LockTokenListener[]) lockMap.values().toArray(new
LockTokenListener[lockMap.size()]);
         for (int i = 0; i < listeners.length; i++) {
             listeners[i].lockTokenRemoved(lt);
@@ -507,12 +503,15 @@
         /**
          * Reload the lockInfo from the server.
          *
-         * @throws LockException
          * @throws RepositoryException
          */
-        private void reloadLockInfo() throws LockException, RepositoryException {
+        private void reloadLockInfo() throws RepositoryException {
             NodeId nId = lockHoldingState.getNodeEntry().getWorkspaceId();
             lockInfo = wspManager.getLockInfo(nId);
+            if (lockInfo == null) {
+                // lock has been released on the server
+                unlocked();
+            }
         }
 
         /**
@@ -697,11 +696,10 @@
          * from the server.
          *
          * @param lockToken
-         * @throws LockException
          * @throws RepositoryException
          * @see LockTokenListener#lockTokenAdded(String)
          */
-        public void lockTokenAdded(String lockToken) throws LockException, RepositoryException
{
+        public void lockTokenAdded(String lockToken) throws RepositoryException {
             if (getLockToken() == null) {
                 // could be that this affects this lock and session became
                 // lock holder -> releoad info to assert.
@@ -713,10 +711,9 @@
          *
          * @param lockToken
          * @throws LockException
-         * @throws RepositoryException
          * @see LockTokenListener#lockTokenRemoved(String)
          */
-        public void lockTokenRemoved(String lockToken) throws LockException, RepositoryException
{
+        public void lockTokenRemoved(String lockToken) throws RepositoryException {
             // reload lock info, if session gave away its lock-holder status
             // for this lock.
             if (lockToken.equals(getLockToken())) {
@@ -740,8 +737,6 @@
             if (reloadInfo) {
                 try {
                     lockState.reloadLockInfo();
-                } catch (LockException e) {
-                    lockState.unlocked();
                 } catch (RepositoryException e) {
                     // may occur if session has been logged out. rather throw?
                     log.warn("Unable to determine lock status.", e.getMessage());
@@ -768,7 +763,7 @@
          * @throws LockException
          * @throws RepositoryException
          */
-        void lockTokenAdded(String lockToken) throws LockException, RepositoryException;
+        void lockTokenAdded(String lockToken) throws RepositoryException;
 
         /**
          *
@@ -776,6 +771,6 @@
          * @throws LockException
          * @throws RepositoryException
          */
-        void lockTokenRemoved(String lockToken) throws LockException, RepositoryException;
+        void lockTokenRemoved(String lockToken) throws RepositoryException;
     }
 }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=582815&r1=582814&r2=582815&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Mon Oct  8 06:13:39 2007
@@ -1037,7 +1037,7 @@
     /**
      * @see RepositoryService#getLockInfo(SessionInfo, NodeId)
      */
-    public LockInfo getLockInfo(SessionInfo sessionInfo, NodeId nodeId) throws LockException,
RepositoryException {
+    public LockInfo getLockInfo(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException
{
         // set of Dav-properties to be retrieved
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
         nameSet.add(DavPropertyName.LOCKDISCOVERY);
@@ -1065,7 +1065,9 @@
                 NodeId parentId = getParentId(ps, sessionInfo);
                 return retrieveLockInfo(ld, sessionInfo, nodeId, parentId);
             }  else {
-                throw new LockException("No Lock present on node with id " + nodeId);
+                // no lock present
+                log.debug("No Lock present on node with id " + nodeId);
+                return null;
             }
         } catch (IOException e) {
             throw new RepositoryException(e);

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=582815&r1=582814&r2=582815&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Mon Oct  8 06:13:39 2007
@@ -559,10 +559,15 @@
      * {@inheritDoc}
      */
     public LockInfo getLockInfo(SessionInfo sessionInfo, NodeId nodeId)
-            throws LockException, RepositoryException {
+            throws RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
-        return new LockInfoImpl(getNode(nodeId, sInfo).getLock(), idFactory,
-                sInfo.getNamespaceResolver());
+        try {
+            Lock lock = getNode(nodeId, sInfo).getLock();
+            return new LockInfoImpl(lock, idFactory, sInfo.getNamespaceResolver());
+        } catch (LockException e) {
+            // no lock present on this node.
+            return null;
+        }
     }
 
     /**



Mime
View raw message