chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1494177 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ main/java/org...
Date Tue, 18 Jun 2013 15:33:09 GMT
Author: jens
Date: Tue Jun 18 15:33:09 2013
New Revision: 1494177

URL: http://svn.apache.org/r1494177
Log:
InMemory: Fix for CMIS 1.1, getLatestVersion() does not include PWC

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.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/AtomLinkInfoProvider.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java
Tue Jun 18 15:33:09 2013
@@ -95,7 +95,7 @@ public class AtomLinkInfoProvider {
             objInfo.setIsCurrentVersion(ver == ver.getParentDocument().getLatestVersion(false));
             objInfo.setVersionSeriesId(ver.getParentDocument().getId());
             objInfo.setWorkingCopyId(pwc == null ? null : pwc.getId());
-            objInfo.setWorkingCopyOriginalId(pwc == ver ? ver.getParentDocument().getLatestVersion(false).getId()
+            objInfo.setWorkingCopyOriginalId(pwc == ver ? ver.getParentDocument().getPwc().getId()
                     : null);
         } else if (so instanceof VersionedDocument) {
             VersionedDocument doc = (VersionedDocument) so;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.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/InMemoryNavigationServiceImpl.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
Tue Jun 18 15:33:09 2013
@@ -101,8 +101,8 @@ public class InMemoryNavigationServiceIm
         } else {
             LOG.debug("getting checked-out documents for folder: " + folderId);
             ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter,
orderBy,
-                    includeAllowableActions, includeRelationships, renditionFilter, false,
-1, -1, false, context
-                            .isObjectInfoRequired() ? objectInfos : null, user);
+                    includeAllowableActions, includeRelationships, renditionFilter, false,
-1, -1, false, true,
+                    context.isObjectInfoRequired() ? objectInfos : null, user);
             for (ObjectInFolderData child : children.getObjects()) {
                 ObjectData obj = child.getObject();
                 StoredObject so = fStoreManager.getObjectStore(repositoryId).getObjectById(obj.getId());
@@ -138,7 +138,7 @@ public class InMemoryNavigationServiceIm
         int skipCountInt = skipCount == null ? 0 : skipCount.intValue();
         String user = context.getUsername();
         ObjectInFolderList res = getChildrenIntern(repositoryId, folderId, filter, orderBy,
includeAllowableActions,
-                includeRelationships, renditionFilter, includePathSegment, maxItemsInt, skipCountInt,
false,
+                includeRelationships, renditionFilter, includePathSegment, maxItemsInt, skipCountInt,
false, false,
                 context.isObjectInfoRequired() ? objectInfos : null, user);
         LOG.debug("stop getChildren()");
         return res;
@@ -270,7 +270,7 @@ public class InMemoryNavigationServiceIm
 
     private ObjectInFolderList getChildrenIntern(String repositoryId, String folderId, String
filter, String orderBy,
             Boolean includeAllowableActions, IncludeRelationships includeRelationships, String
renditionFilter,
-            Boolean includePathSegments, int maxItems, int skipCount, boolean folderOnly,
ObjectInfoHandler objectInfos,
+            Boolean includePathSegments, int maxItems, int skipCount, boolean folderOnly,
boolean includePwc, ObjectInfoHandler objectInfos,
             String user) {
 
         ObjectInFolderListImpl result = new ObjectInFolderListImpl();
@@ -292,11 +292,11 @@ public class InMemoryNavigationServiceIm
         }
 
         Children.ChildrenResult children = folderOnly ? folder.getFolderChildren(maxItems,
skipCount, user) : folder
-                .getChildren(maxItems, skipCount, user);
+                .getChildren(maxItems, skipCount, user, includePwc);
 
         for (StoredObject spo : children.getChildren()) {
             if (!cmis11 && spo instanceof Item)
-                continue; // ignore items for CMIS 1.1‚
+                continue; // ignore items for CMIS 1.0
             
             ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
             if (includePathSegments != null && includePathSegments) {
@@ -342,7 +342,7 @@ public class InMemoryNavigationServiceIm
             String orderBy = PropertyIds.NAME;
             ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter,
orderBy,
                     includeAllowableActions, includeRelationships, renditionFilter, includePathSegments,
1000, 0,
-                    folderOnly, objectInfos, user);
+                    folderOnly, false, objectInfos, user);
 
             childrenOfFolderId = new ArrayList<ObjectInFolderContainer>();
             if (null != children) {

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=1494177&r1=1494176&r2=1494177&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
Tue Jun 18 15:33:09 2013
@@ -1214,7 +1214,7 @@ public class InMemoryObjectServiceImpl e
      */
     private boolean deleteRecursive(ObjectStore folderStore, Folder parentFolder, boolean
continueOnFailure,
             boolean allVersions, List<String> failedToDeleteIds, String user) {
-        ChildrenResult childrenResult = parentFolder.getChildren(-1, -1, "Admin");
+        ChildrenResult childrenResult = parentFolder.getChildren(-1, -1, "Admin", true);
         List<? extends StoredObject> children = childrenResult.getChildren();
 
         if (null == children) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.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/storedobj/api/Children.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
Tue Jun 18 15:33:09 2013
@@ -55,13 +55,17 @@ public interface Children {
      * @param skipCount
      *            initial offset where to start fetching
      * @param user 
+     * 			user to determine visible children
+     * @param usePwc 
+     * 			if true return private working copy otherwise return latest version; 
+     * 
      * @return list of children objects
      */
-    ChildrenResult getChildren(int maxItems, int skipCount, String user );
+    ChildrenResult getChildren(int maxItems, int skipCount, String user, boolean usePwc);
 
     /**
      * get all the children of this folder which are folders. To support paging
-     * an initial offset and a maximum number of childrent to retrieve can be
+     * an initial offset and a maximum number of children to retrieve can be
      * passed.
      * 
      * @param maxItems

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.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/storedobj/impl/DocumentVersionImpl.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
Tue Jun 18 15:33:09 2013
@@ -163,10 +163,14 @@ public class DocumentVersionImpl extends
 
     private boolean isLatestVersion() {
         List<DocumentVersion> allVers = fContainer.getAllVersions();
+        boolean hasPwc = null != fContainer.getPwc();
         boolean isLatestVersion;
-        isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
-        if (isPwc())
-        	isLatestVersion = false; // CMIS 1.1 forbids it for PWC
+        if (hasPwc) {
+        	// CMIS 1.1 forbids it for PWC
+            isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size()
- 2).equals(this);        	
+        } else {
+            isLatestVersion = allVers.get(allVers.size() - 1).equals(this);        	
+        }
         return isLatestVersion;
     }
 
@@ -184,7 +188,7 @@ public class DocumentVersionImpl extends
             }
         }
 
-        boolean isLatestMajorVersion = latestMajor == this && !isPwc(); // CMIS 1.1
forbids it for PWC
+        boolean isLatestMajorVersion = latestMajor == this; 
         return isLatestMajorVersion;
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.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/storedobj/impl/FolderImpl.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
Tue Jun 18 15:33:09 2013
@@ -122,7 +122,7 @@ public class FolderImpl extends Abstract
         }
     }
 
-    public ChildrenResult getChildren(int maxItems, int skipCount, String user) {
+    public ChildrenResult getChildren(int maxItems, int skipCount, String user, boolean usePwc)
{
         List<StoredObject> result = new ArrayList<StoredObject>();
         for (String id : fObjStore.getIds()) {
             StoredObject obj = fObjStore.getObject(id);
@@ -130,8 +130,15 @@ public class FolderImpl extends Abstract
                 Filing pathObj = (Filing) obj;
                 if (fObjStore.hasReadAccess(user, obj) && pathObj.getParents(user).contains(this))
{
                     if (pathObj instanceof VersionedDocument) {
-                        DocumentVersion ver = ((VersionedDocument) pathObj).getLatestVersion(false);
-                        result.add(ver);
+                    	DocumentVersion ver;
+                    	if (usePwc) {
+                    		ver = ((VersionedDocument) pathObj).getPwc();
+                    		if (null == ver)
+                    			ver = ((VersionedDocument) pathObj).getLatestVersion(false);
+                    	} else {
+                    		ver = ((VersionedDocument) pathObj).getLatestVersion(false);
+                    	}
+                    	result.add(ver);
                     } else if (pathObj instanceof DocumentVersion) {
                         // ignore
                     } else {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.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/storedobj/impl/ObjectStoreImpl.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
Tue Jun 18 15:33:09 2013
@@ -499,7 +499,7 @@ public class ObjectStoreImpl implements 
         }
 
         // check if children exist
-        List<? extends StoredObject> children = ((Folder) folder).getChildren(-1, -1,
user).getChildren();
+        List<? extends StoredObject> children = ((Folder) folder).getChildren(-1, -1,
user, true).getChildren();
         if (children != null && !children.isEmpty()) {
             throw new CmisConstraintException("Cannot delete folder with id:  " + folderId
+ ". Folder is not empty.");
         }
@@ -614,7 +614,7 @@ public class ObjectStoreImpl implements 
     }
 
     private Acl applyAclRecursive(Folder folder, Acl addAces, Acl removeAces, String principalId)
{
-        List<? extends StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID).getChildren();
+        List<? extends StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID,
false).getChildren();
         
         Acl result = applyAcl(folder, addAces, removeAces);  
 
@@ -636,7 +636,7 @@ public class ObjectStoreImpl implements 
     }
     
     private Acl applyAclRecursive(Folder folder, Acl acl, String principalId) {
-        List<? extends StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID).getChildren();
+        List<? extends StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID,
false).getChildren();
 
         Acl result = applyAcl(folder, acl);  
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.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/storedobj/impl/VersionedDocumentImpl.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
Tue Jun 18 15:33:09 2013
@@ -142,12 +142,18 @@ public class VersionedDocumentImpl exten
 
         if (major) {
             for (DocumentVersion ver : fVersions) {
-                if (ver.isMajor()) {
+                if (ver.isMajor() && !ver.isPwc()) {
                     latest = ver;
                 }
             }
         } else {
-            latest = fVersions.get(fVersions.size() - 1);
+        	if (null == getPwc()) {
+        		latest = fVersions.get(fVersions.size() - 1);
+        	} else if (fVersions.size() > 1) {
+        		latest = fVersions.get(fVersions.size() - 2);
+        	} else {
+        		latest = null;
+        	}
         }
         return latest;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
Tue Jun 18 15:33:09 2013
@@ -79,11 +79,11 @@ public class FolderTest extends TestCase
         assertEquals(f1, fTest);
         fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1", USER);
         assertEquals(f11, fTest);
-        List<? extends StoredObject> subFolders = fRoot.getChildren(-1, -1, "user").getChildren();
+        List<? extends StoredObject> subFolders = fRoot.getChildren(-1, -1, "user",
false).getChildren();
         assertEquals(4, subFolders.size());
-        subFolders = f2.getChildren(-1, -1, "user").getChildren();
+        subFolders = f2.getChildren(-1, -1, "user", false).getChildren();
         assertEquals(0, subFolders.size());
-        subFolders = f1.getChildren(-1, -1, "user").getChildren();
+        subFolders = f1.getChildren(-1, -1, "user", false).getChildren();
         assertEquals(1, subFolders.size());
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java?rev=1494177&r1=1494176&r2=1494177&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
Tue Jun 18 15:33:09 2013
@@ -516,7 +516,9 @@ public class VersioningTest extends Abst
         boolean bVal = pdb.getFirstValue();
         if (versioningState != VersioningState.CHECKEDOUT)
         	assertTrue(bVal); 
-
+        else
+        	assertFalse(bVal); 
+        	
         pdb = (PropertyBoolean) props.get(PropertyIds.IS_MAJOR_VERSION);
         assertNotNull(pdb);
         bVal = pdb.getFirstValue();



Mime
View raw message