chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1222640 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ test/java/org/apache/chemistry/opencmis/inmemory/
Date Fri, 23 Dec 2011 11:00:27 GMT
Author: jens
Date: Fri Dec 23 11:00:26 2011
New Revision: 1222640

URL: http://svn.apache.org/viewvc?rev=1222640&view=rev
Log:
avoid NPE when creating unfiled documents as non-admin users, improve unit test [CMIS-490]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.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/InMemoryServiceValidatorImpl.java?rev=1222640&r1=1222639&r2=1222640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java
Fri Dec 23 11:00:26 2011
@@ -211,7 +211,8 @@ public class InMemoryServiceValidatorImp
             ExtensionsData extension) {
 
         StoredObject folder = super.createDocument(context, repositoryId, folderId, extension);
-        checkWriteAccess(repositoryId, context.getUsername(), folder);
+        if (null != folder) // not if unfiled
+            checkWriteAccess(repositoryId, context.getUsername(), folder);
         return folder;
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.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/MultiFilingTest.java?rev=1222640&r1=1222639&r2=1222640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java
Fri Dec 23 11:00:26 2011
@@ -38,6 +38,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
 import org.apache.commons.logging.Log;
@@ -83,6 +84,12 @@ public class MultiFilingTest extends Abs
 
         assertNotNull(res);
         assertEquals(res.size(), 0);
+        
+        // test with a different user than Admin:
+        switchCallContext("Alice");
+        docId = createDocument(UNFILED_DOC_NAME + "_2", null, DOCUMENT_TYPE_ID, true);
+        docId2 = getDocument(docId);
+        assertEquals(docId, docId2);
 
         LOG.debug("End testCreatUnfiledDocument()");
     }
@@ -285,4 +292,9 @@ public class MultiFilingTest extends Abs
                 VersioningState.MAJOR, true);
 
     }
+
+    private void switchCallContext(String user) {
+        ((DummyCallContext) fTestCallContext).put(CallContext.USERNAME, user);
+    }
+
 }



Mime
View raw message