chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1186526 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server: InMemoryAbstractServiceImpl.java InMemoryObjectServiceImpl.java
Date Wed, 19 Oct 2011 21:59:46 GMT
Author: jens
Date: Wed Oct 19 21:59:46 2011
New Revision: 1186526

URL: http://svn.apache.org/viewvc?rev=1186526&view=rev
Log:
proper checkout status handling in updateProperties

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java?rev=1186526&r1=1186525&r2=1186526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
Wed Oct 19 21:59:46 2011
@@ -138,5 +138,15 @@ public class InMemoryAbstractServiceImpl
             throw new CmisUpdateConflictException("Document " + verDoc.getId() + " is not
checked out.");
         }
     }
+    
+    protected boolean isCheckedOut(StoredObject so, String user) {
+        if (so instanceof VersionedDocument || so instanceof DocumentVersion) {
+            VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
+            return verDoc.isCheckedOut() && user.equals(verDoc.getCheckedOutBy());
+        } else
+            return false;
+        
+
+    }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1186526&r1=1186525&r2=1186526&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
Wed Oct 19 21:59:46 2011
@@ -402,6 +402,11 @@ public class InMemoryObjectServiceImpl e
 
         LOG.debug("start getObjectByPath()");
         StoredObject so = validator.getObjectByPath(context, repositoryId, path, extension);
+        if (so instanceof VersionedDocument) {
+            VersionedDocument verDoc = (VersionedDocument) so;
+            so = verDoc.getLatestVersion(false);
+        }
+        
         String user = context.getUsername();
 
         TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
@@ -569,13 +574,7 @@ public class InMemoryObjectServiceImpl e
         TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
         boolean isCheckedOut = false;
 
-        // if the object is a versionable object it must be checked-out
-        if (so instanceof VersionedDocument || so instanceof DocumentVersion) {
-            // VersionedDocument verDoc =
-            // testIsNotCheckedOutBySomeoneElse(so, user);
-            testHasProperCheckedOutStatus(so, user);
-            isCheckedOut = true;
-        }
+        isCheckedOut = isCheckedOut(so, user);
 
         Map<String, PropertyData<?>> oldProperties = so.getProperties();
 
@@ -593,7 +592,7 @@ public class InMemoryObjectServiceImpl e
 
         for (String key : properties.getProperties().keySet()) {
             if (key.equals(PropertyIds.NAME))
-             {
+            {
                 continue; // ignore here
             }
 
@@ -610,10 +609,11 @@ public class InMemoryObjectServiceImpl e
                 oldProperties.remove(key);
                 hasUpdatedOtherProps = true;
             } else {
-                if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT) &&
!isCheckedOut) {
-                    throw new CmisConstraintException(
-                            "updateProperties failed, following property can't be updated,
because it is not checked-out: "
-                                    + key);
+                if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT)) {
+                    if (!isCheckedOut)
+                        throw new CmisUpdateConflictException(
+                                "updateProperties failed, following property can't be updated,
because it is not checked-out: "
+                                        + key);
                 } else if (!propDef.getUpdatability().equals(Updatability.READWRITE)) {
                     throw new CmisConstraintException(
                             "updateProperties failed, following property can't be updated,
because it is not writable: "
@@ -952,7 +952,7 @@ public class InMemoryObjectServiceImpl e
      */
     private boolean deleteRecursive(ObjectStore folderStore, Folder parentFolder, boolean
continueOnFailure,
             boolean allVersions, List<String> failedToDeleteIds, String user) {
-        List<StoredObject> children = parentFolder.getChildren(-1, -1, "System");
+        List<StoredObject> children = parentFolder.getChildren(-1, -1, "Admin");
 
         if (null == children) {
             return true;
@@ -968,13 +968,13 @@ public class InMemoryObjectServiceImpl e
                 }
             } else {
                 try {
-                    folderStore.deleteObject(child.getId(), true, user);
+                    folderStore.deleteObject(child.getId(), allVersions, user);
                 } catch (Exception e) {
                     failedToDeleteIds.add(child.getId());
                 }
             }
         }
-        folderStore.deleteObject(parentFolder.getId(), true, user);
+        folderStore.deleteObject(parentFolder.getId(), allVersions, user);
         return true;
     }
 



Mime
View raw message