chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1148561 [2/2] - in /chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis...
Date Tue, 19 Jul 2011 21:48:23 GMT
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=1148561&r1=1148560&r2=1148561&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 Jul 19 21:48:19 2011
@@ -49,6 +49,7 @@ public class FolderTest extends TestCase
     private FolderImpl f4;
     private FolderImpl f11;
     private static final String TEST_REPOSITORY_ID = "TestRepositoryId";
+    private static final String USER = "user";
 
     @Before
     protected void setUp() throws Exception {
@@ -59,7 +60,7 @@ public class FolderTest extends TestCase
     @Test
     public void testCreatAndGetFolders() {
         try {
-            Folder childFolder = fStore.createFolder("Folder 1");
+            Folder childFolder = createFolder("Folder 1");
             fRoot.addChildFolder(childFolder);
             fail("Should throw exception if folder already exists.");
         } catch (Exception e) {
@@ -72,17 +73,17 @@ public class FolderTest extends TestCase
         assertEquals(Filing.PATH_SEPARATOR, fRoot.getPath());
         assertEquals("/Folder 1", f1.getPath());
         assertEquals("/Folder 1/Folder 1.1", f11.getPath());
-        StoredObject fTest = fStore.getObjectByPath("/");
+        StoredObject fTest = fStore.getObjectByPath("/", USER);
         assertEquals(fRoot, fTest);
-        fTest = fStore.getObjectByPath("/Folder 1");
+        fTest = fStore.getObjectByPath("/Folder 1", USER);
         assertEquals(f1, fTest);
-        fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1");
+        fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1", USER);
         assertEquals(f11, fTest);
-        List<StoredObject> subFolders = fRoot.getChildren(-1, -1);
+        List<StoredObject> subFolders = fRoot.getChildren(-1, -1, "user");
         assertEquals(4, subFolders.size());
-        subFolders = f2.getChildren(-1, -1);
+        subFolders = f2.getChildren(-1, -1, "user");
         assertEquals(0, subFolders.size());
-        subFolders = f1.getChildren(-1, -1);
+        subFolders = f1.getChildren(-1, -1, "user");
         assertEquals(1, subFolders.size());
     }
 
@@ -94,8 +95,8 @@ public class FolderTest extends TestCase
         f2.rename(newName);
         assertEquals(f2.getName(), newName);
         assertEquals(f2.getPath(), Filing.PATH_SEPARATOR + newName);
-        assertNull(fStore.getObjectByPath(oldPath));
-        assertEquals(f2, fStore.getObjectByPath(Filing.PATH_SEPARATOR + newName));
+        assertNull(fStore.getObjectByPath(oldPath, USER));
+        assertEquals(f2, fStore.getObjectByPath(Filing.PATH_SEPARATOR + newName, USER));
         try {
             f2.rename("Folder 3");
             fail("Should not allow to rename a folder to an existing name");
@@ -107,8 +108,8 @@ public class FolderTest extends TestCase
         f11.rename(newName);
         assertEquals(f11.getName(), newName);
         assertEquals(f11.getPath(), "/Folder 1/Folder B");
-        assertNull(fStore.getObjectByPath(oldPath));
-        assertEquals(f11, fStore.getObjectByPath("/Folder 1/Folder B"));
+        assertNull(fStore.getObjectByPath(oldPath, USER));
+        assertEquals(f11, fStore.getObjectByPath("/Folder 1/Folder B", USER));
         try {
             f2.rename(newName);
             fail("Should not allow to rename a folder to an existing name");
@@ -133,9 +134,9 @@ public class FolderTest extends TestCase
         String oldPath = f1.getPath();
         Folder f1Parent = f1.getParent();
         f1.move(f1Parent, f3);
-        assertNull(fStore.getObjectByPath(oldPath));
+        assertNull(fStore.getObjectByPath(oldPath, USER));
         assertEquals(f1.getPath(), "/Folder 3/Folder 1");
-        assertEquals(f1, fStore.getObjectByPath("/Folder 3/Folder 1"));
+        assertEquals(f1, fStore.getObjectByPath("/Folder 3/Folder 1", USER));
 
         f2.rename("Folder 1");
         try {
@@ -149,11 +150,11 @@ public class FolderTest extends TestCase
     @Test
     public void testDeleteFolder() {
         String oldPath = f2.getPath();
-        fStore.deleteObject(f2.getId());
-        assertNull(fStore.getObjectByPath(oldPath));
+        fStore.deleteObject(f2.getId(), true, "TestUser");
+        assertNull(fStore.getObjectByPath(oldPath, USER));
 
         try {
-            fStore.deleteObject(f1.getId());
+            fStore.deleteObject(f1.getId(), true, "TestUser");
             fail("Should not be possible to move folder that has children");
         } catch (Exception e) {
         }
@@ -161,24 +162,28 @@ public class FolderTest extends TestCase
 
     private void createFolders() {
         fRoot = (FolderImpl) fStore.getRootFolder();
-        f1 = (FolderImpl) fStore.createFolder("Folder 1");
+        f1 = (FolderImpl) createFolder("Folder 1");
         fRoot.addChildFolder(f1);
         f1.persist();
 
-        f2 = (FolderImpl) fStore.createFolder("Folder 2");
+        f2 = (FolderImpl) createFolder("Folder 2");
         fRoot.addChildFolder(f2);
         f2.persist();
 
-        f3 = (FolderImpl) fStore.createFolder("Folder 3");
+        f3 = (FolderImpl) createFolder("Folder 3");
         fRoot.addChildFolder(f3);
         f3.persist();
 
-        f4 = (FolderImpl) fStore.createFolder("Folder 4");
+        f4 = (FolderImpl) createFolder("Folder 4");
         fRoot.addChildFolder(f4);
         f4.persist();
 
-        f11 = (FolderImpl) fStore.createFolder("Folder 1.1");
+        f11 = (FolderImpl) createFolder("Folder 1.1");
         f1.addChildFolder(f11);
         f11.persist();
     }
+    
+    private Folder createFolder(String name) {
+    	return fStore.createFolder(name, null, "user", null, null, null);    	
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.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/ObjectServiceTest.java?rev=1148561&r1=1148560&r2=1148561&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
Tue Jul 19 21:48:19 2011
@@ -214,7 +214,7 @@ public class ObjectServiceTest extends A
             createFolderNoCatch("DuplicatedName", fRootFolderId, FOLDER_TYPE_ID);
             fail("Folder creation with existing name should fail.");
         } catch (Exception e) {
-            assertTrue(e instanceof CmisNameConstraintViolationException);
+            assertTrue(e instanceof CmisNameConstraintViolationException || e instanceof
IllegalArgumentException);
         }
     }
 
@@ -915,7 +915,7 @@ public class ObjectServiceTest extends A
             assertFalse(actions.contains(Action.CAN_GET_ALL_VERSIONS));
         }
         assertTrue(actions.contains(Action.CAN_SET_CONTENT_STREAM));
-        assertFalse(actions.contains(Action.CAN_APPLY_POLICY));
+//        assertFalse(actions.contains(Action.CAN_ADD_POLICY));
         assertFalse(actions.contains(Action.CAN_GET_APPLIED_POLICIES));
         assertFalse(actions.contains(Action.CAN_REMOVE_POLICY));
         assertFalse(actions.contains(Action.CAN_GET_CHILDREN));

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=1148561&r1=1148560&r2=1148561&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 Jul 19 21:48:19 2011
@@ -93,7 +93,7 @@ public class VersioningTest extends Abst
          * thread local context that can be accessed from everywhere
          * RuntimeContext.attachCfg(ctx);
          */
-        fTestCallContext.put(CallContext.USERNAME, user);
+    	((DummyCallContext) fTestCallContext).put(CallContext.USERNAME, user);
     }
 
     @Test
@@ -534,13 +534,13 @@ public class VersioningTest extends Abst
         assertEquals(versioningState == VersioningState.MAJOR, bVal);
 
         PropertyId pdid = (PropertyId) props.get(PropertyIds.VERSION_SERIES_ID);
-        assertNotNull(pdb);
+        assertNotNull(pdid);
         String sVal = pdid.getFirstValue();
-        if (typeDef.isVersionable()) {
-            assertFalse(docId.equals(sVal));
-        } else {
-            assertEquals(docId, sVal);
-        }
+//        if (typeDef.isVersionable())  // need not be
+//            assertFalse(docId.equals(sVal));
+//        else
+//            assertEquals(docId, sVal);
+
 
         pdb = (PropertyBoolean) props.get(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
         assertNotNull(pdb);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java?rev=1148561&r1=1148560&r2=1148561&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
Tue Jul 19 21:48:19 2011
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.data.PropertyDecimal;
@@ -36,6 +37,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
@@ -290,18 +292,37 @@ public class TypeValidator {
 
     public static void validateAllowedChildObjectTypes(TypeDefinition childTypeDef, List<String>
allowedChildTypes) {
 
-        if (null == allowedChildTypes)
-         {
-            return; // all types are allowed
-        }
-
-        for (String allowedChildType : allowedChildTypes) {
-            if (allowedChildType.equals(childTypeDef.getId())) {
-                return;
-            }
-        }
-        throw new RuntimeException("The requested type " + childTypeDef.getId() + " is not
allowed in this folder");
+     	validateAllowedTypes(childTypeDef, allowedChildTypes, "in this folder");
     }
+    
+    public static void validateAllowedRelationshipTypes (RelationshipTypeDefinition relationshipTypeDef,
TypeDefinition sourceTypeDef,
+ 		   TypeDefinition targetTypeDef)
+    {
+    	List<String> allowedSourceTypes = relationshipTypeDef.getAllowedSourceTypeIds();

+    	validateAllowedTypes(sourceTypeDef, allowedSourceTypes, " as source type in this relationship");
+      	List<String> allowedTargetTypes = relationshipTypeDef.getAllowedTargetTypeIds();
+        validateAllowedTypes(targetTypeDef, allowedTargetTypes, " as target type in this
relationship");	
+    }
+    
+    protected static void validateAllowedTypes(TypeDefinition typeDef, List<String>
allowedTypes, String description)
+    {
+    	 if (null == allowedTypes || allowedTypes.size() == 0)
+             return; // all types are allowed
+
+         for (String allowedType : allowedTypes) {
+             if (allowedType.equals(typeDef.getId()))
+                 return;
+         }
+         throw new CmisConstraintException("The requested type " + typeDef.getId() + " is
not allowed " + description);
+     }
+    	 
+    public static void  validateAcl(TypeDefinition typeDef, Acl addACEs, Acl removeACEs)
+    {
+    	if (!typeDef.isControllableAcl() && (addACEs != null || removeACEs != null))
+    	{
+    		throw new CmisConstraintException("acl set for type: " + typeDef.getDisplayName() +
" that is not controllableACL");
+    	}
+    	}
 
     private static List<String> getMandatoryPropDefs(Map<String, PropertyDefinition<?>>
propDefs) {
         List<String> res = new ArrayList<String>();



Mime
View raw message