chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r921826 - in /incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider: cache/ cache/impl/ spi/atompub/
Date Thu, 11 Mar 2010 12:38:50 GMT
Author: fmui
Date: Thu Mar 11 12:38:50 2010
New Revision: 921826

URL: http://svn.apache.org/viewvc?rev=921826&view=rev
Log:
CMIS-155: provider layer should now be thread-safe

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/Cache.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/AbstractAtomPubService.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/LinkCache.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/NavigationServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/ObjectServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/RelationshipServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/VersioningServiceImpl.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/Cache.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/Cache.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/Cache.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/Cache.java
Thu Mar 11 12:38:50 2010
@@ -85,4 +85,14 @@ public interface Cache extends Serializa
    *         the object is in the cache
    */
   int check(String... keys);
+
+  /**
+   * Applies a write lock.
+   */
+  void writeLock();
+
+  /**
+   * Releases a write lock.
+   */
+  void writeUnlock();
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java
Thu Mar 11 12:38:50 2010
@@ -302,6 +302,24 @@ public class CacheImpl implements Cache 
     return keys.length;
   }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.provider.cache.Cache#writeLock()
+   */
+  public void writeLock() {
+    fLock.writeLock().lock();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.provider.cache.Cache#writeUnlock()
+   */
+  public void writeUnlock() {
+    fLock.writeLock().unlock();
+  }
+
   // ---- internal ----
 
   /**

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/AbstractAtomPubService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/AbstractAtomPubService.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/AbstractAtomPubService.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/AbstractAtomPubService.java
Thu Mar 11 12:38:50 2010
@@ -189,6 +189,20 @@ public class AbstractAtomPubService {
   }
 
   /**
+   * Locks the link cache.
+   */
+  protected void lockLinks() {
+    getLinkCache().lockLinks();
+  }
+
+  /**
+   * Unlocks the link cache.
+   */
+  protected void unlockLinks() {
+    getLinkCache().unlockLinks();
+  }
+
+  /**
    * Checks a link throw an appropriate exception.
    */
   protected void throwLinkException(String repositoryId, String id, String rel, String type)
{
@@ -269,6 +283,20 @@ public class AbstractAtomPubService {
   }
 
   /**
+   * Locks the type link cache.
+   */
+  protected void lockTypeLinks() {
+    getLinkCache().lockTypeLinks();
+  }
+
+  /**
+   * Unlocks the type link cache.
+   */
+  protected void unlockTypeLinks() {
+    getLinkCache().unlockTypeLinks();
+  }
+
+  /**
    * Gets a collection from the cache.
    */
   protected String getCollection(String repositoryId, String collection) {
@@ -678,18 +706,24 @@ public class AbstractAtomPubService {
       throw new CmisConnectionException("Received Atom entry is not a CMIS entry!");
     }
 
-    // clean up cache
-    removeLinks(repositoryId, entry.getId());
+    lockLinks();
+    try {
+      // clean up cache
+      removeLinks(repositoryId, entry.getId());
 
-    // walk through the entry
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-      }
-      else if (element.getObject() instanceof CmisObjectType) {
-        result = convert((CmisObjectType) element.getObject());
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
+        else if (element.getObject() instanceof CmisObjectType) {
+          result = convert((CmisObjectType) element.getObject());
+        }
       }
     }
+    finally {
+      unlockLinks();
+    }
 
     return result;
   }
@@ -717,19 +751,25 @@ public class AbstractAtomPubService {
       throw new CmisConnectionException("Received Atom entry is not a CMIS entry!");
     }
 
-    // clean up cache
-    removeTypeLinks(repositoryId, entry.getId());
+    lockTypeLinks();
+    try {
+      // clean up cache
+      removeTypeLinks(repositoryId, entry.getId());
 
-    // walk through the entry
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-      }
-      else if (element.getObject() instanceof CmisTypeDefinitionType) {
-        result = convert((CmisTypeDefinitionType) element.getObject());
-        break;
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
+        else if (element.getObject() instanceof CmisTypeDefinitionType) {
+          result = convert((CmisTypeDefinitionType) element.getObject());
+          break;
+        }
       }
     }
+    finally {
+      unlockTypeLinks();
+    }
 
     return result;
   }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/LinkCache.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/LinkCache.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/LinkCache.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/LinkCache.java
Thu Mar 11 12:38:50 2010
@@ -144,6 +144,20 @@ public class LinkCache implements Serial
   }
 
   /**
+   * Locks the link cache.
+   */
+  public void lockLinks() {
+    fLinkCache.writeLock();
+  }
+
+  /**
+   * Unlocks the link cache.
+   */
+  public void unlockLinks() {
+    fLinkCache.writeUnlock();
+  }
+
+  /**
    * Adds a type link.
    */
   public void addTypeLink(String repositoryId, String id, String rel, String type, String
link) {
@@ -172,6 +186,20 @@ public class LinkCache implements Serial
   }
 
   /**
+   * Locks the type link cache.
+   */
+  public void lockTypeLinks() {
+    fTypeLinkCache.writeLock();
+  }
+
+  /**
+   * Unlocks the type link cache.
+   */
+  public void unlockTypeLinks() {
+    fTypeLinkCache.writeUnlock();
+  }
+
+  /**
    * Adds a collection.
    */
   public void addCollection(String repositoryId, String collection, String link) {

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/NavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/NavigationServiceImpl.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/NavigationServiceImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/NavigationServiceImpl.java
Thu Mar 11 12:38:50 2010
@@ -120,22 +120,28 @@ public class NavigationServiceImpl exten
         ObjectInFolderDataImpl child = null;
         String pathSegment = null;
 
-        // clean up cache
-        removeLinks(repositoryId, entry.getId());
-
-        // walk through the entry
-        for (AtomElement element : entry.getElements()) {
-          if (element.getObject() instanceof AtomLink) {
-            addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-          }
-          else if (isStr(NAME_PATH_SEGMENT, element)) {
-            pathSegment = (String) element.getObject();
-          }
-          else if (element.getObject() instanceof CmisObjectType) {
-            child = new ObjectInFolderDataImpl();
-            child.setObject(convert((CmisObjectType) element.getObject()));
+        lockLinks();
+        try {
+          // clean up cache
+          removeLinks(repositoryId, entry.getId());
+
+          // walk through the entry
+          for (AtomElement element : entry.getElements()) {
+            if (element.getObject() instanceof AtomLink) {
+              addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+            }
+            else if (isStr(NAME_PATH_SEGMENT, element)) {
+              pathSegment = (String) element.getObject();
+            }
+            else if (element.getObject() instanceof CmisObjectType) {
+              child = new ObjectInFolderDataImpl();
+              child.setObject(convert((CmisObjectType) element.getObject()));
+            }
           }
         }
+        finally {
+          unlockLinks();
+        }
 
         if (child != null) {
           child.setPathSegment(pathSegment);
@@ -229,18 +235,24 @@ public class NavigationServiceImpl exten
       throw new CmisRuntimeException("Unexpected document!");
     }
 
-    // clean up cache
-    removeLinks(repositoryId, entry.getId());
+    lockLinks();
+    try {
+      // clean up cache
+      removeLinks(repositoryId, entry.getId());
 
-    // walk through the entry
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-      }
-      else if (element.getObject() instanceof CmisObjectType) {
-        result = convert((CmisObjectType) element.getObject());
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
+        else if (element.getObject() instanceof CmisObjectType) {
+          result = convert((CmisObjectType) element.getObject());
+        }
       }
     }
+    finally {
+      unlockLinks();
+    }
 
     return result;
   }
@@ -349,21 +361,27 @@ public class NavigationServiceImpl exten
     ObjectParentDataImpl result = null;
     String relativePathSegment = null;
 
-    // clean up cache
-    removeLinks(repositoryId, entry.getId());
+    lockLinks();
+    try {
+      // clean up cache
+      removeLinks(repositoryId, entry.getId());
 
-    // walk through the entry
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-      }
-      else if (element.getObject() instanceof CmisObjectType) {
-        result = new ObjectParentDataImpl(convert((CmisObjectType) element.getObject()));
-      }
-      else if (is(NAME_RELATIVE_PATH_SEGMENT, element)) {
-        relativePathSegment = (String) element.getObject();
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
+        else if (element.getObject() instanceof CmisObjectType) {
+          result = new ObjectParentDataImpl(convert((CmisObjectType) element.getObject()));
+        }
+        else if (is(NAME_RELATIVE_PATH_SEGMENT, element)) {
+          relativePathSegment = (String) element.getObject();
+        }
       }
     }
+    finally {
+      unlockLinks();
+    }
 
     if (result != null) {
       result.setRelativePathSegment(relativePathSegment);
@@ -426,18 +444,24 @@ public class NavigationServiceImpl exten
       for (AtomEntry entry : feed.getEntries()) {
         ObjectData child = null;
 
-        // clean up cache
-        removeLinks(repositoryId, entry.getId());
-
-        // walk through the entry
-        for (AtomElement element : entry.getElements()) {
-          if (element.getObject() instanceof AtomLink) {
-            addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-          }
-          else if (element.getObject() instanceof CmisObjectType) {
-            child = convert((CmisObjectType) element.getObject());
+        lockLinks();
+        try {
+          // clean up cache
+          removeLinks(repositoryId, entry.getId());
+
+          // walk through the entry
+          for (AtomElement element : entry.getElements()) {
+            if (element.getObject() instanceof AtomLink) {
+              addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+            }
+            else if (element.getObject() instanceof CmisObjectType) {
+              child = convert((CmisObjectType) element.getObject());
+            }
           }
         }
+        finally {
+          unlockLinks();
+        }
 
         if (child != null) {
           result.getObjects().add(child);
@@ -465,24 +489,31 @@ public class NavigationServiceImpl exten
       String pathSegment = null;
       List<ObjectInFolderContainer> childContainerList = new ArrayList<ObjectInFolderContainer>();
 
-      // clean up cache
-      removeLinks(repositoryId, entry.getId());
+      lockLinks();
+      try {
+        // clean up cache
+        removeLinks(repositoryId, entry.getId());
 
-      // walk through the entry
-      for (AtomElement element : entry.getElements()) {
-        if (element.getObject() instanceof AtomLink) {
-          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-        }
-        else if (element.getObject() instanceof CmisObjectType) {
-          objectInFolder = new ObjectInFolderDataImpl(convert((CmisObjectType) element.getObject()));
-        }
-        else if (is(NAME_PATH_SEGMENT, element)) {
-          pathSegment = (String) element.getObject();
-        }
-        else if (element.getObject() instanceof AtomFeed) {
-          addDescendantsLevel(repositoryId, (AtomFeed) element.getObject(), childContainerList);
+        // walk through the entry
+        for (AtomElement element : entry.getElements()) {
+          if (element.getObject() instanceof AtomLink) {
+            addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+          }
+          else if (element.getObject() instanceof CmisObjectType) {
+            objectInFolder = new ObjectInFolderDataImpl(convert((CmisObjectType) element
+                .getObject()));
+          }
+          else if (is(NAME_PATH_SEGMENT, element)) {
+            pathSegment = (String) element.getObject();
+          }
+          else if (element.getObject() instanceof AtomFeed) {
+            addDescendantsLevel(repositoryId, (AtomFeed) element.getObject(), childContainerList);
+          }
         }
       }
+      finally {
+        unlockLinks();
+      }
 
       if (objectInFolder != null) {
         objectInFolder.setPathSegment(pathSegment);

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/ObjectServiceImpl.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/ObjectServiceImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/ObjectServiceImpl.java
Thu Mar 11 12:38:50 2010
@@ -359,36 +359,42 @@ public class ObjectServiceImpl extends A
       changeToken.setValue(null); // just in case
     }
 
-    // clean up cache
-    removeLinks(repositoryId, entry.getId());
+    lockLinks();
+    try {
+      // clean up cache
+      removeLinks(repositoryId, entry.getId());
+
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
+        else if (element.getObject() instanceof CmisObjectType) {
+          // extract new change token
+          if (changeToken != null) {
+            object = (CmisObjectType) element.getObject();
+
+            if (object.getProperties() != null) {
+              for (CmisProperty property : object.getProperties().getProperty()) {
+                if (PropertyIds.CMIS_CHANGE_TOKEN.equals(property.getPropertyDefinitionId())
+                    && (property instanceof CmisPropertyString)) {
+
+                  CmisPropertyString changeTokenProperty = (CmisPropertyString) property;
+                  if (!changeTokenProperty.getValue().isEmpty()) {
+                    changeToken.setValue(changeTokenProperty.getValue().get(0));
+                  }
 
-    // walk through the entry
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-      }
-      else if (element.getObject() instanceof CmisObjectType) {
-        // extract new change token
-        if (changeToken != null) {
-          object = (CmisObjectType) element.getObject();
-
-          if (object.getProperties() != null) {
-            for (CmisProperty property : object.getProperties().getProperty()) {
-              if (PropertyIds.CMIS_CHANGE_TOKEN.equals(property.getPropertyDefinitionId())
-                  && (property instanceof CmisPropertyString)) {
-
-                CmisPropertyString changeTokenProperty = (CmisPropertyString) property;
-                if (!changeTokenProperty.getValue().isEmpty()) {
-                  changeToken.setValue(changeTokenProperty.getValue().get(0));
+                  break;
                 }
-
-                break;
               }
             }
           }
         }
       }
     }
+    finally {
+      unlockLinks();
+    }
   }
 
   /*

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/RelationshipServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/RelationshipServiceImpl.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/RelationshipServiceImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/RelationshipServiceImpl.java
Thu Mar 11 12:38:50 2010
@@ -109,23 +109,30 @@ public class RelationshipServiceImpl ext
       for (AtomEntry entry : feed.getEntries()) {
         ObjectData relationship = null;
 
-        // clean up cache
-        removeLinks(repositoryId, entry.getId());
+        lockLinks();
+        try {
+          // clean up cache
+          removeLinks(repositoryId, entry.getId());
 
-        // walk through the entry
-        for (AtomElement element : entry.getElements()) {
-          if (element.getObject() instanceof AtomLink) {
-            addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-          }
-          else if (element.getObject() instanceof CmisObjectType) {
-            relationship = convert((CmisObjectType) element.getObject());
+          // walk through the entry
+          for (AtomElement element : entry.getElements()) {
+            if (element.getObject() instanceof AtomLink) {
+              addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+            }
+            else if (element.getObject() instanceof CmisObjectType) {
+              relationship = convert((CmisObjectType) element.getObject());
+            }
           }
         }
+        finally {
+          unlockLinks();
+        }
 
         if (relationship != null) {
           result.getObjects().add(relationship);
         }
       }
+
     }
 
     return result;

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/VersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/VersioningServiceImpl.java?rev=921826&r1=921825&r2=921826&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/VersioningServiceImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/VersioningServiceImpl.java
Thu Mar 11 12:38:50 2010
@@ -101,15 +101,21 @@ public class VersioningServiceImpl exten
 
     objectId.setValue(entry.getId());
 
-    // clean up cache
-    removeLinks(repositoryId, entry.getId());
-
-    // walk through the entry
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+    lockLinks();
+    try {
+      // clean up cache
+      removeLinks(repositoryId, entry.getId());
+
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
       }
     }
+    finally {
+      unlockLinks();
+    }
 
     if (contentCopied != null) {
       contentCopied.setValue(null);
@@ -204,21 +210,28 @@ public class VersioningServiceImpl exten
     // set object id
     objectId.setValue(entry.getId());
 
-    // clean up cache
-    removeLinks(repositoryId, entry.getId());
-
-    // walk through the entry
     AccessControlList originalAces = null;
-    for (AtomElement element : entry.getElements()) {
-      if (element.getObject() instanceof AtomLink) {
-        addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-      }
-      else if (element.getObject() instanceof CmisObjectType) {
-        // extract current ACL
-        object = (CmisObjectType) element.getObject();
-        originalAces = convert(object.getAcl(), object.isExactACL());
+
+    lockLinks();
+    try {
+      // clean up cache
+      removeLinks(repositoryId, entry.getId());
+
+      // walk through the entry
+      for (AtomElement element : entry.getElements()) {
+        if (element.getObject() instanceof AtomLink) {
+          addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+        }
+        else if (element.getObject() instanceof CmisObjectType) {
+          // extract current ACL
+          object = (CmisObjectType) element.getObject();
+          originalAces = convert(object.getAcl(), object.isExactACL());
+        }
       }
     }
+    finally {
+      unlockLinks();
+    }
 
     // handle ACL modifications
     if ((originalAces != null) && (isAclMergeRequired(addAces, removeAces))) {
@@ -263,18 +276,24 @@ public class VersioningServiceImpl exten
       for (AtomEntry entry : feed.getEntries()) {
         ObjectData version = null;
 
-        // clean up cache
-        removeLinks(repositoryId, entry.getId());
-
-        // walk through the entry
-        for (AtomElement element : entry.getElements()) {
-          if (element.getObject() instanceof AtomLink) {
-            addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
-          }
-          else if (element.getObject() instanceof CmisObjectType) {
-            version = convert((CmisObjectType) element.getObject());
+        lockLinks();
+        try {
+          // clean up cache
+          removeLinks(repositoryId, entry.getId());
+
+          // walk through the entry
+          for (AtomElement element : entry.getElements()) {
+            if (element.getObject() instanceof AtomLink) {
+              addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+            }
+            else if (element.getObject() instanceof CmisObjectType) {
+              version = convert((CmisObjectType) element.getObject());
+            }
           }
         }
+        finally {
+          unlockLinks();
+        }
 
         if (version != null) {
           result.add(version);



Mime
View raw message