chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1058932 - in /incubator/chemistry/opencmis-cmis11/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/i...
Date Fri, 14 Jan 2011 10:42:53 GMT
Author: jens
Date: Fri Jan 14 10:42:52 2011
New Revision: 1058932

URL: http://svn.apache.org/viewvc?rev=1058932&view=rev
Log:
start with implementing type mutability: allow creation of new types (delete, update not supported)

Modified:
    incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
    incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
    incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
    incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java

Modified: incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java?rev=1058932&r1=1058931&r2=1058932&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
Fri Jan 14 10:42:52 2011
@@ -29,10 +29,14 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.chemistry.opencmis.inmemory.TypeManagerImpl;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 
 public class InMemoryRepositoryServiceImpl extends InMemoryAbstractServiceImpl {
@@ -134,6 +138,41 @@ public class InMemoryRepositoryServiceIm
         return result;
     }
 
+    public void createTypeDefinition(String repositoryId, Holder<TypeDefinition> type,
ExtensionsData extension) {
+
+    	TypeManagerImpl typeManager = (TypeManagerImpl) fStoreManager.getTypeManager(repositoryId);
+        if (null == typeManager)
+            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
+        
+        String typeId = type.getValue().getId();
+
+        if (null == typeId)
+        	throw new CmisInvalidArgumentException("Cannot add type, type id is required.");
+        
+        if (typeManager.getTypeById(typeId) != null)
+			throw new CmisInvalidArgumentException("Cannot add type "
+					+ typeId + ", type already exists");
+        
+        String parentTypeId = type.getValue().getParentTypeId();
+
+        if (null == parentTypeId)
+        	throw new CmisInvalidArgumentException("Cannot add type, parent type id is required.");
+        
+        if (typeManager.getTypeById(parentTypeId) == null)
+			throw new CmisInvalidArgumentException("Cannot add type "
+					+ parentTypeId + " is unknown.");
+
+        typeManager.addTypeDefinition(type.getValue());
+    }
+
+    public void updateTypeDefinition(String repositoryId, Holder<TypeDefinition> type,
ExtensionsData extension) {
+    	throw new CmisNotSupportedException("updating type definition is not supported.");
+    }
+
+    public void deleteTypeDefinition(String repositoryId, String typeId, ExtensionsData extension)
{
+    	throw new CmisNotSupportedException("deleting TypeDefinition is not supported.");
+    }
+    
     private RepositoryInfo getRepositoryInfoFromStoreManager(String repositoryId) {
         RepositoryInfo repoInfo = fStoreManager.getRepositoryInfo(repositoryId);
         if (null == repoInfo || !repoInfo.getId().equals(repositoryId)) {

Modified: incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java?rev=1058932&r1=1058931&r2=1058932&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
Fri Jan 14 10:42:52 2011
@@ -43,6 +43,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
@@ -108,6 +109,18 @@ public class InMemoryService extends Abs
         return fRepSvc.getTypeDefinition(getCallContext(), repositoryId, typeId, extension);
     }
 
+    public void createTypeDefinition(String repositoryId, Holder<TypeDefinition> type,
ExtensionsData extension) {
+    	fRepSvc.createTypeDefinition(repositoryId, type, extension);
+    }
+
+    public void updateTypeDefinition(String repositoryId, Holder<TypeDefinition> type,
ExtensionsData extension) {
+    	fRepSvc.updateTypeDefinition(repositoryId, type, extension);
+    }
+
+    public void deleteTypeDefinition(String repositoryId, String typeId, ExtensionsData extension)
{
+    	fRepSvc.deleteTypeDefinition(repositoryId, typeId, extension);
+    }
+
     public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String
typeId, BigInteger depth,
             Boolean includePropertyDefinitions, ExtensionsData extension) {
         return fRepSvc.getTypeDescendants(getCallContext(), repositoryId, typeId, depth,
includePropertyDefinitions,

Modified: incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=1058932&r1=1058931&r2=1058932&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
Fri Jan 14 10:42:52 2011
@@ -27,6 +27,7 @@ import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
@@ -41,6 +42,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.NewTypeSettableAttributesImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
@@ -328,6 +330,22 @@ public class StoreManagerImpl implements
         // aclCaps.setPermissionMappingData(null);
         // repoInfo.setACLCapabilities(aclCaps);
         repoInfo.setAclCapabilities(null);
+        
+        NewTypeSettableAttributesImpl tsAttrs = new NewTypeSettableAttributesImpl();
+        tsAttrs.setCanSetId(true);
+        tsAttrs.setCanSetLocalName(true);
+        tsAttrs.setCanSetLocalNamespace(true);
+        tsAttrs.setCanSetDisplayName(true);
+        tsAttrs.setCanSetQueryName(true);
+        tsAttrs.setCanSetDescription(true);
+        tsAttrs.setCanSetQueryable(true);
+        tsAttrs.setCanSetFulltextIndexed(false);
+        tsAttrs.setCanSetIncludedInSupertypeQuery(true);
+        tsAttrs.setCanSetControllablePolicy(false);
+        tsAttrs.setCanSetCreatable(true);
+//        repoInfo.setTypeSettableAttributes(tsAttrs);
+        repoInfo.setChangesOnType(null);
+        
         fRepositoryInfo = repoInfo;
         return repoInfo;
     }

Modified: incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java?rev=1058932&r1=1058931&r2=1058932&view=diff
==============================================================================
--- incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
(original)
+++ incubator/chemistry/opencmis-cmis11/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
Fri Jan 14 10:42:52 2011
@@ -48,6 +48,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityRenditions;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
@@ -59,6 +60,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
@@ -479,6 +481,57 @@ public class RepositoryServiceTest exten
         log.info("... testInheritedProperties() finished.");
     }
 
+    @Test
+    public void testTypeMutabilityCreation() throws Exception {
+        log.info("");
+        log.info("starting testTypeMutabilityCreation() ...");
+        TypeDefinition typeDefRef = getTypeForAddingAtRuntime();
+        String repositoryId = getRepositoryId();
+        // add type.
+        fRepSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef),
null);
+        TypeDefinition type = fRepSvc.getTypeDefinition(repositoryId, typeDefRef.getId(),
null);
+        assertEquals(typeDefRef.getId(), type.getId());
+        assertEquals(typeDefRef.getDescription(), type.getDescription());
+        assertEquals(typeDefRef.getDisplayName(), type.getDisplayName());
+        assertEquals(typeDefRef.getLocalName(), type.getLocalName());
+        assertEquals(typeDefRef.getLocalNamespace(), type.getLocalNamespace());
+        containsAllBasePropertyDefinitions(type);
+        log.info("... testTypeMutabilityCreation() finished.");
+    }
+
+    @Test
+    public void testTypeMutabilityUpdate() throws Exception {
+        log.info("");
+        log.info("starting testTypeMutabilityUpdate() ...");
+        TypeDefinition typeDefRef = getTypeForAddingAtRuntime();
+        String repositoryId = getRepositoryId();
+        fRepSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef),
null);
+        // update type.
+        try {
+        	fRepSvc.updateTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef),
null);
+        	fail("updating a type should throw exception.");
+        } catch (Exception e) {
+        	assert(e instanceof CmisNotSupportedException);
+        }
+        log.info("... testTypeMutabilityUpdate() finished.");
+    }
+    @Test
+    public void testTypeMutabilityDeletion() throws Exception {
+        log.info("");
+        log.info("starting testTypeMutabilityDeletion() ...");
+        TypeDefinition typeDefRef = getTypeForAddingAtRuntime();
+        String repositoryId = getRepositoryId();
+        fRepSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef),
null);
+        // delete type.
+        try {
+        	fRepSvc.deleteTypeDefinition(repositoryId, typeDefRef.getId(), null);
+        	fail("deleting a type should throw exception.");
+        } catch (Exception e) {
+        	assert(e instanceof CmisNotSupportedException);
+        }
+        log.info("... testTypeMutabilityDeletion() finished.");
+    }
+
     private String getRepositoryId() {
         List<RepositoryInfo> repositories = fRepSvc.getRepositoryInfos(null);
         RepositoryInfo repository = repositories.get(0);
@@ -568,6 +621,26 @@ public class RepositoryServiceTest exten
         return size;
     }
 
+    private TypeDefinition getTypeForAddingAtRuntime() {
+        
+        InMemoryDocumentTypeDefinition cmisLaterType = new InMemoryDocumentTypeDefinition("BookTypeAddedLater",
+                "Type with two properties", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String,
PropertyDefinition<?>>();
+
+        PropertyIntegerDefinitionImpl prop1 = PropertyCreationHelper.createIntegerDefinition("Number",
+                "Sample Int Property");
+        propertyDefinitions.put(prop1.getId(), prop1);
+
+        PropertyStringDefinitionImpl prop2 = PropertyCreationHelper.createStringDefinition("Title",
+                "Sample String Property");
+        propertyDefinitions.put(prop2.getId(), prop2);
+    	
+        cmisLaterType.addCustomPropertyDefinitions(propertyDefinitions);
+        
+        return cmisLaterType;
+
+    }
     public static class RepositoryTestTypeSystemCreator implements TypeCreator {
 
         public static final String COMPLEX_TYPE = "ComplexType";



Mime
View raw message