You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2010/04/01 14:37:20 UTC

svn commit: r929943 - in /incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime: PersistentDocumentImpl.java PersistentFolderImpl.java PersistentSessionImpl.java

Author: fmui
Date: Thu Apr  1 12:37:20 2010
New Revision: 929943

URL: http://svn.apache.org/viewvc?rev=929943&view=rev
Log:
another small step towards a thread-safe client API

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java?rev=929943&r1=929942&r2=929943&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java Thu Apr  1 12:37:20 2010
@@ -168,31 +168,36 @@ public class PersistentDocumentImpl exte
    */
   public ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream,
       String checkinComment, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces) {
+    String objectId;
+    ObjectType type;
     readLock();
     try {
-      String objectId = getObjectId();
-      Holder<String> objectIdHolder = new Holder<String>(objectId);
+      objectId = getObjectId();
+      type = getType();
+    }
+    finally {
+      readUnlock();
+    }
 
-      ObjectFactory of = getObjectFactory();
+    Holder<String> objectIdHolder = new Holder<String>(objectId);
 
-      Set<Updatability> updatebility = new HashSet<Updatability>();
-      updatebility.add(Updatability.READWRITE);
-      updatebility.add(Updatability.WHENCHECKEDOUT);
-
-      getProvider().getVersioningService().checkIn(getRepositoryId(), objectIdHolder, major,
-          of.convertProperties(properties, getType(), updatebility),
-          of.convertContentStream(contentStream), checkinComment, of.convertPolicies(policies),
-          of.convertAces(addAces), of.convertAces(removeAces), null);
+    ObjectFactory of = getObjectFactory();
 
-      if (objectIdHolder.getValue() == null) {
-        return null;
-      }
+    Set<Updatability> updatebility = new HashSet<Updatability>();
+    updatebility.add(Updatability.READWRITE);
+    updatebility.add(Updatability.WHENCHECKEDOUT);
+
+    getProvider().getVersioningService().checkIn(getRepositoryId(), objectIdHolder, major,
+        of.convertProperties(properties, type, updatebility),
+        of.convertContentStream(contentStream), checkinComment, of.convertPolicies(policies),
+        of.convertAces(addAces), of.convertAces(removeAces), null);
 
-      return getSession().createObjectId(objectIdHolder.getValue());
-    }
-    finally {
-      readUnlock();
+    if (objectIdHolder.getValue() == null) {
+      return null;
     }
+
+    return getSession().createObjectId(objectIdHolder.getValue());
+
   }
 
   /*
@@ -211,8 +216,17 @@ public class PersistentDocumentImpl exte
    * OperationContext)
    */
   public List<Document> getAllVersions(OperationContext context) {
-    String objectId = getObjectId();
-    String versionSeriesId = getVersionSeriesId();
+    String objectId;
+    String versionSeriesId;
+
+    readLock();
+    try {
+      objectId = getObjectId();
+      versionSeriesId = getVersionSeriesId();
+    }
+    finally {
+      readUnlock();
+    }
 
     List<ObjectData> versions = getProvider().getVersioningService().getAllVersions(
         getRepositoryId(), objectId, versionSeriesId, context.getFilterString(),
@@ -234,6 +248,7 @@ public class PersistentDocumentImpl exte
     }
 
     return result;
+
   }
 
   /*
@@ -302,8 +317,8 @@ public class PersistentDocumentImpl exte
    * org.apache.opencmis.client.api.ContentStream)
    */
   public ObjectId setContentStream(boolean overwrite, ContentStream contentStream) {
-    String objectId = null;
-    String changeToken = null;
+    String objectId;
+    String changeToken;
 
     readLock();
     try {
@@ -333,8 +348,8 @@ public class PersistentDocumentImpl exte
    * @see org.apache.opencmis.client.api.Document#deleteContentStream()
    */
   public ObjectId deleteContentStream() {
-    String objectId = null;
-    String changeToken = null;
+    String objectId;
+    String changeToken;
 
     readLock();
     try {

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java?rev=929943&r1=929942&r2=929943&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java Thu Apr  1 12:37:20 2010
@@ -515,26 +515,34 @@ public class PersistentFolderImpl extend
    * @see org.apache.opencmis.client.api.Folder#getPath()
    */
   public String getPath() {
-    // get the path property
-    String path = getPropertyValue(PropertyIds.CMIS_PATH);
+    String path;
 
-    // if the path property isn't set, get it
-    if (path == null) {
-      String objectId = getObjectId();
-      ObjectData objectData = getProvider().getObjectService().getObject(getRepositoryId(),
-          objectId, PropertyIds.CMIS_PATH, false, IncludeRelationships.NONE, "cmis:none", false,
-          false, null);
-
-      if ((objectData.getProperties() != null)
-          && (objectData.getProperties().getProperties() != null)) {
-        PropertyData<?> pathProperty = objectData.getProperties().getProperties().get(
-            PropertyIds.CMIS_PATH);
-
-        if (pathProperty instanceof PropertyStringData) {
-          path = ((PropertyStringData) pathProperty).getFirstValue();
+    readLock();
+    try {
+      // get the path property
+      path = getPropertyValue(PropertyIds.CMIS_PATH);
+
+      // if the path property isn't set, get it
+      if (path == null) {
+        String objectId = getObjectId();
+        ObjectData objectData = getProvider().getObjectService().getObject(getRepositoryId(),
+            objectId, PropertyIds.CMIS_PATH, false, IncludeRelationships.NONE, "cmis:none", false,
+            false, null);
+
+        if ((objectData.getProperties() != null)
+            && (objectData.getProperties().getProperties() != null)) {
+          PropertyData<?> pathProperty = objectData.getProperties().getProperties().get(
+              PropertyIds.CMIS_PATH);
+
+          if (pathProperty instanceof PropertyStringData) {
+            path = ((PropertyStringData) pathProperty).getFirstValue();
+          }
         }
       }
     }
+    finally {
+      readUnlock();
+    }
 
     // we still don't know the path ... it's not a CMIS compliant repository
     if (path == null) {

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java?rev=929943&r1=929942&r2=929943&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java Thu Apr  1 12:37:20 2010
@@ -462,32 +462,6 @@ public class PersistentSessionImpl imple
   public RepositoryInfo getRepositoryInfo() {
     fLock.readLock().lock();
     try {
-      if (this.repositoryInfo == null) {
-        fLock.readLock().unlock();
-        fLock.writeLock().lock();
-        try {
-          // try again
-          if (this.repositoryInfo != null) {
-            return this.repositoryInfo;
-          }
-
-          /* get initial repository id from session parameter */
-          String repositoryId = this.determineRepositoryId(this.parameters);
-          if (repositoryId == null) {
-            throw new IllegalStateException("Repository Id is not set!");
-          }
-
-          RepositoryInfoData data = getProvider().getRepositoryService().getRepositoryInfo(
-              repositoryId, null);
-
-          this.repositoryInfo = new RepositoryInfoImpl(data);
-        }
-        finally {
-          fLock.writeLock().unlock();
-          fLock.readLock().lock();
-        }
-      }
-
       return this.repositoryInfo;
     }
     finally {
@@ -681,6 +655,17 @@ public class PersistentSessionImpl imple
     fLock.writeLock().lock();
     try {
       this.provider = CmisProviderHelper.createProvider(this.parameters);
+
+      /* get initial repository id from session parameter */
+      String repositoryId = this.determineRepositoryId(this.parameters);
+      if (repositoryId == null) {
+        throw new IllegalStateException("Repository Id is not set!");
+      }
+
+      RepositoryInfoData data = getProvider().getRepositoryService().getRepositoryInfo(
+          repositoryId, null);
+
+      this.repositoryInfo = new RepositoryInfoImpl(data);
     }
     finally {
       fLock.writeLock().unlock();