chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1547529 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory: server/ storedobj/api/
Date Tue, 03 Dec 2013 19:12:49 GMT
Author: jens
Date: Tue Dec  3 19:12:48 2013
New Revision: 1547529

URL: http://svn.apache.org/r1547529
Log:
InMemory: Some improvements on type validation

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.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/BaseServiceValidatorImpl.java?rev=1547529&r1=1547528&r2=1547529&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
Tue Dec  3 19:12:48 2013
@@ -18,17 +18,34 @@
  */
 package org.apache.chemistry.opencmis.inmemory.server;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collection;
 import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.data.CreatablePropertyTypes;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes;
 import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
+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.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
@@ -45,6 +62,8 @@ public class BaseServiceValidatorImpl im
     protected static final String UNKNOWN_REPOSITORY_ID = "Unknown repository id: ";
     protected static final String OBJECT_ID_CANNOT_BE_NULL = "Object Id cannot be null.";
     protected static final String REPOSITORY_ID_CANNOT_BE_NULL = "Repository Id cannot be
null.";
+    protected static final String UNKNOWN_TYPE_ID = "Unknown type id: ";
+    protected static final String TYPE_ID_CANNOT_BE_NULL = "Type Id cannot be null.";
     protected final StoreManager fStoreManager;
 
     public BaseServiceValidatorImpl(StoreManager sm) {
@@ -186,6 +205,261 @@ public class BaseServiceValidatorImpl im
         }
     }
 
+    protected void checkCreatablePropertyTypes(String repositoryId,
+            Collection<PropertyDefinition<?>> propertyDefinitions )
+    {
+        RepositoryInfo repositoryInfo = fStoreManager.getRepositoryInfo(repositoryId);
+        RepositoryCapabilities repositoryCapabilities = repositoryInfo.getCapabilities();
+        CreatablePropertyTypes creatablePropertyTypes = repositoryCapabilities.getCreatablePropertyTypes();
+        
+        Set<PropertyType> creatablePropertyTypeSet = creatablePropertyTypes.canCreate();
+        for (PropertyDefinition<?> propertyDefinition : propertyDefinitions)
+        {
+            if (!creatablePropertyTypeSet.contains(propertyDefinition.getPropertyType()))
+                throw new CmisConstraintException("propertyDefinition " + propertyDefinition.getId()
+
+                        "is of not creatable type " + propertyDefinition.getPropertyType());
+            
+            // mandatory properties must have a default value
+            if (propertyDefinition.isRequired() && 
+                    (propertyDefinition.getDefaultValue() == null))
+            {
+                throw new CmisConstraintException("property: " + propertyDefinition.getId()
+ 
+                        "required properties must have a default value");
+            }
+        }
+    }
+    
+    protected void checkSettableAttributes(String repositoryId, TypeDefinition oldTypeDefinition,
+            TypeDefinition newTypeDefinition )
+    {
+        RepositoryInfo repositoryInfo = fStoreManager.getRepositoryInfo(repositoryId);
+        RepositoryCapabilities repositoryCapabilities = repositoryInfo.getCapabilities();
+        NewTypeSettableAttributes newTypeSettableAttributes = repositoryCapabilities.getNewTypeSettableAttributes();
+        
+        if (null == newTypeSettableAttributes)
+            return; // no restrictions defined
+        if (newTypeSettableAttributes.canSetControllableAcl() &&
+                newTypeSettableAttributes.canSetControllablePolicy() &&
+                newTypeSettableAttributes.canSetCreatable() &&
+                newTypeSettableAttributes.canSetDescription() &&
+                newTypeSettableAttributes.canSetDisplayName() &&
+                newTypeSettableAttributes.canSetFileable() &&
+                newTypeSettableAttributes.canSetFulltextIndexed() &&
+                newTypeSettableAttributes.canSetId() &&
+                newTypeSettableAttributes.canSetIncludedInSupertypeQuery() &&
+                newTypeSettableAttributes.canSetLocalName() &&
+                newTypeSettableAttributes.canSetLocalNamespace() &&
+                newTypeSettableAttributes.canSetQueryable() &&
+                newTypeSettableAttributes.canSetQueryName())
+            return;  // all is allowed
+        if (!newTypeSettableAttributes.canSetControllableAcl() && 
+                oldTypeDefinition.isControllableAcl() != newTypeDefinition.isControllableAcl())
+            throw new CmisConstraintException("controllableAcl is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in controllableAcl");
+        if (!newTypeSettableAttributes.canSetControllablePolicy() && 
+                oldTypeDefinition.isControllablePolicy() != newTypeDefinition.isControllablePolicy())
+            throw new CmisConstraintException("controllablePolicy is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in controllablePolicy");
+        if (!newTypeSettableAttributes.canSetCreatable() && 
+                oldTypeDefinition.isCreatable() != newTypeDefinition.isCreatable())
+            throw new CmisConstraintException("isCreatable is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in isCreatable");
+        if (!newTypeSettableAttributes.canSetDescription() && 
+                oldTypeDefinition.getDescription() != newTypeDefinition.getDescription())
+            throw new CmisConstraintException("description is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their description");
+        if (!newTypeSettableAttributes.canSetDisplayName() && 
+                oldTypeDefinition.getDisplayName() != newTypeDefinition.getDisplayName())
+            throw new CmisConstraintException("displayName is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their displayName");
+        if (!newTypeSettableAttributes.canSetFileable() && 
+                oldTypeDefinition.isFileable() != newTypeDefinition.isFileable())
+            throw new CmisConstraintException("fileable is not settable in repository " +
repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in isFileable");
+        if (!newTypeSettableAttributes.canSetFulltextIndexed() && 
+                oldTypeDefinition.isFulltextIndexed() != newTypeDefinition.isFulltextIndexed())
+            throw new CmisConstraintException("fulltextIndexed is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in isFulltextIndexed");
+        // TODO  how can the ids differ?
+        if (!newTypeSettableAttributes.canSetId() && 
+                oldTypeDefinition.getId() != newTypeDefinition.getId())
+            throw new CmisConstraintException("id is not settable in repository " + repositoryId
+ ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their id");
+        if (!newTypeSettableAttributes.canSetIncludedInSupertypeQuery() && 
+                oldTypeDefinition.isIncludedInSupertypeQuery() != newTypeDefinition.isIncludedInSupertypeQuery())
+            throw new CmisConstraintException("includedInSupertypeQuery is not settable in
repository " + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their isIncludedInSupertypeQuery");
+        if (!newTypeSettableAttributes.canSetLocalName() && 
+                oldTypeDefinition.getLocalName() != newTypeDefinition.getLocalName())
+            throw new CmisConstraintException("localName is not settable in repository "
+ repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their localName");
+        if (!newTypeSettableAttributes.canSetLocalNamespace() && 
+                oldTypeDefinition.getLocalNamespace() != newTypeDefinition.getLocalNamespace())
+            throw new CmisConstraintException("localNamespace is not settable in repository
" + repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their localNamespace");
+        if (!newTypeSettableAttributes.canSetQueryable() && 
+                oldTypeDefinition.isQueryable() != newTypeDefinition.isQueryable())
+            throw new CmisConstraintException("queryable is not settable in repository "
+ repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their isQueryable");
+        if (!newTypeSettableAttributes.canSetQueryName() && 
+                oldTypeDefinition.getQueryName() != newTypeDefinition.getQueryName())
+            throw new CmisConstraintException("queryName is not settable in repository "
+ repositoryId + ", but " +
+                     oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + "
differ in their queryName");
+    }
+
+    protected void checkUpdatePropertyDefinitions(Map<String,PropertyDefinition<?>>
oldPropertyDefinitions,
+            Map<String,PropertyDefinition<?>> newPropertyDefinitions)
+    {
+        for(PropertyDefinition<?> newPropertyDefinition : newPropertyDefinitions.values())
+        {                   
+            PropertyDefinition<?> oldPropertyDefinition = oldPropertyDefinitions.get(newPropertyDefinition.getId());
+        
+            if (oldPropertyDefinition.isInherited())
+                throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                        " update of inherited properties is not allowed");
+            if (!(oldPropertyDefinition.isRequired()) && newPropertyDefinition.isRequired())
+                throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                        " optional properties must not be changed to required");    
+            if (oldPropertyDefinition.getPropertyType() != newPropertyDefinition.getPropertyType())
+                throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                        " cannot update the propertyType (" + oldPropertyDefinition.getPropertyType()
+ ")");   
+            if (oldPropertyDefinition.getCardinality() != newPropertyDefinition.getCardinality())
+                throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                        " cannot update the cardinality (" + oldPropertyDefinition.getCardinality()
+ ")"); 
+            
+            if (oldPropertyDefinition.isOpenChoice() && !newPropertyDefinition.isOpenChoice()
)
+                throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                        " open choice cannot change from true to false");
+            
+            // check choices
+            if (!oldPropertyDefinition.isOpenChoice())
+            {
+                List<?> oldChoices = oldPropertyDefinition.getChoices();
+                if (null == oldChoices)
+                    throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                            " there should be any choices when it's no open choice");
+                List<?> newChoices = newPropertyDefinition.getChoices();
+                if (null == newChoices)
+                throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ 
+                        " there should be any choices when it's no open choice");
+                ListIterator<?> newChoicesIterator = newChoices.listIterator();
+                for (Object oldChoiceObject : oldChoices)
+                {
+                    Object newChoiceObject = newChoicesIterator.next();
+                    if (!(oldChoiceObject instanceof Choice))
+                        throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ 
+                                " old choice object is not of class Choice: " + oldChoiceObject.toString());
+                    if (!(newChoiceObject instanceof Choice))
+                        throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ 
+                                " new choice object is not of class Choice: " + newChoiceObject.toString());
+                    Choice<?> oldChoice = (Choice<?>) oldChoiceObject;
+                    Choice<?> newChoice = (Choice<?>) newChoiceObject;
+                    List<?> oldValues = oldChoice.getValue();
+                    List<?> newValues = newChoice.getValue();
+                    for (Object oldValue : oldValues)
+                    {                       
+                        if (! newValues.contains(oldValue))
+                            throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ 
+                                    " value: " + oldValue.toString() + " is not in new values
of the new choice");
+                    }       
+                }   
+            }
+        
+            // check restrictions
+            if (oldPropertyDefinition instanceof PropertyDecimalDefinition)
+            {
+                PropertyDecimalDefinition oldPropertyDecimalDefinition = (PropertyDecimalDefinition)
oldPropertyDefinition;
+                PropertyDecimalDefinition newPropertyDecimalDefinition = (PropertyDecimalDefinition)
newPropertyDefinition;
+                
+                BigDecimal oldMinValue = oldPropertyDecimalDefinition.getMinValue();
+                BigDecimal newMinValue = newPropertyDecimalDefinition.getMinValue();
+                if (null != newMinValue &&
+                        (oldMinValue == null || (newMinValue.compareTo( oldMinValue) >
0)))
+                    throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                            " minValue " + oldMinValue + " cannot be further restricted to
" + newMinValue);
+                
+                BigDecimal oldMaxValue = oldPropertyDecimalDefinition.getMaxValue();
+                BigDecimal newMaxValue = newPropertyDecimalDefinition.getMaxValue();
+                if (null != newMaxValue &&
+                        (oldMaxValue == null || (newMaxValue.compareTo( oldMaxValue) <
0)))
+                    throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                            " maxValue " + oldMaxValue + " cannot be further restricted to
" + newMaxValue);
+            }
+            if (oldPropertyDefinition instanceof PropertyIntegerDefinition)
+            {
+                PropertyIntegerDefinition oldPropertyIntegerDefinition = (PropertyIntegerDefinition)
oldPropertyDefinition;
+                PropertyIntegerDefinition newPropertyIntegerDefinition = (PropertyIntegerDefinition)
newPropertyDefinition;
+                
+                BigInteger oldMinValue = oldPropertyIntegerDefinition.getMinValue();
+                BigInteger newMinValue = newPropertyIntegerDefinition.getMinValue();
+                if (null != newMinValue &&
+                        (oldMinValue == null || (newMinValue.compareTo( oldMinValue) >
0)))
+                    throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                            " minValue " + oldMinValue + " cannot be further restricted to
" + newMinValue);
+                
+                BigInteger oldMaxValue = oldPropertyIntegerDefinition.getMaxValue();
+                BigInteger newMaxValue = newPropertyIntegerDefinition.getMaxValue();
+                if (null != newMaxValue &&
+                        (oldMaxValue == null || (newMaxValue.compareTo( oldMaxValue) <
0)))
+                    throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                            " maxValue " + oldMaxValue + " cannot be further restricted to
" + newMaxValue);
+            }
+            if (oldPropertyDefinition instanceof PropertyStringDefinition)
+            {
+                PropertyStringDefinition oldPropertyStringDefinition = (PropertyStringDefinition)
oldPropertyDefinition;
+                PropertyStringDefinition newPropertyStringDefinition = (PropertyStringDefinition)
newPropertyDefinition;
+                
+                BigInteger oldMaxValue = oldPropertyStringDefinition.getMaxLength();
+                BigInteger newMaxValue = newPropertyStringDefinition.getMaxLength();
+                if (null != newMaxValue &&
+                        (oldMaxValue == null || (newMaxValue.compareTo( oldMaxValue) <
0)))
+                    throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                            " maxValue " + oldMaxValue + " cannot be further restricted to
" + newMaxValue);
+            }
+        }
+        
+        // check for removed properties
+        for(PropertyDefinition<?> oldPropertyDefinition : oldPropertyDefinitions.values())
+        {
+            PropertyDefinition<?> newPropertyDefinition = newPropertyDefinitions.get(oldPropertyDefinition.getId());
+            if (null == newPropertyDefinition)
+            {
+                throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ 
+                        " cannot remove that property");    
+            }
+        }
+    }
+    
+    protected void checkUpdateType (TypeDefinition updateType, TypeDefinition type)
+    {
+        if (updateType.getId() != type.getId())
+            throw new CmisConstraintException("type to update must be of the same id: " +
updateType.getId() + ", " + type.getId());
+        if (updateType.getBaseTypeId() != type.getBaseTypeId())
+            throw new CmisConstraintException("base type to update must be the same: " +
updateType.getBaseTypeId() + ", " + type.getBaseTypeId());
+        // anything else should be ignored          
+    }
+    
+    protected TypeDefinition checkExistingTypeId(String repositoryId, String typeId) {
+
+        if (null == typeId) {
+            throw new CmisInvalidArgumentException(TYPE_ID_CANNOT_BE_NULL);
+        }
+
+        TypeDefinitionContainer tdc = fStoreManager.getTypeById(repositoryId, typeId);
+        if (tdc == null) {
+            throw new CmisObjectNotFoundException(UNKNOWN_TYPE_ID + typeId);
+        }
+
+        return tdc.getTypeDefinition();
+    }
+
+
+    protected void checkBasicType(TypeDefinition type)
+    {
+        if (type.getId() == type.getBaseTypeId().value())       
+            throw new CmisConstraintException("type " + type.getId() + " is a basic type,
basic types are read-only");  
+    }
+    
     @Override
     public void getRepositoryInfos(CallContext context, ExtensionsData extension) {
     }
@@ -550,4 +824,56 @@ public class BaseServiceValidatorImpl im
 
         return checkStandardParameters(repositoryId, objectId);
     }
+    
+    @Override
+    public void createType(CallContext callContext, String repositoryId, TypeDefinition type,
ExtensionsData extension) {
+        checkRepositoryId(repositoryId);
+
+        if (null == type) {
+            throw new CmisInvalidArgumentException("Type cannot be null.");
+        }
+        String parentTypeId = type.getParentTypeId();
+        TypeDefinitionContainer parentTypeContainer = fStoreManager.getTypeById(repositoryId,
parentTypeId);
+        if (null == parentTypeContainer) {
+            throw new CmisInvalidArgumentException(UNKNOWN_TYPE_ID + parentTypeId);
+        }
+        TypeDefinition parentType = parentTypeContainer.getTypeDefinition();
+        // check type mutability
+        if (!(parentType.getTypeMutability().canCreate())) {
+            throw new CmisConstraintException("parent type: " + parentTypeId + " does not
allow mutability create");
+        }
+        checkCreatablePropertyTypes(repositoryId, type.getPropertyDefinitions().values());
+    }
+
+    @Override
+    public TypeDefinition updateType(CallContext callContext,
+            String repositoryId, TypeDefinition type, ExtensionsData extension) {
+        checkRepositoryId(repositoryId);
+        
+        TypeDefinition updateType = checkExistingTypeId(repositoryId, type.getId());
+        checkUpdateType(updateType, type);
+        checkBasicType(type);
+        // check type mutability
+        if (!(updateType.getTypeMutability().canUpdate())) {
+            throw new CmisConstraintException("type: " + type.getId() + " does not allow
mutability update");
+        }
+        checkCreatablePropertyTypes(repositoryId, type.getPropertyDefinitions().values());
+        checkSettableAttributes(repositoryId, updateType, type );
+        checkUpdatePropertyDefinitions(updateType.getPropertyDefinitions(), type.getPropertyDefinitions());
+        return updateType;
+    }
+
+    @Override
+    public TypeDefinition deleteType(CallContext callContext, String repositoryId,
+            String typeId, ExtensionsData extension) {
+        checkRepositoryId(repositoryId);
+        
+        TypeDefinition deleteType =  checkExistingTypeId(repositoryId, typeId);
+        // check type mutability
+        if (!(deleteType.getTypeMutability().canDelete())) {
+            throw new CmisConstraintException("type: " + typeId + " does not allow mutability
delete");
+        }
+        return deleteType;
+    }
+    
 }

Modified: chemistry/opencmis/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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java?rev=1547529&r1=1547528&r2=1547529&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
Tue Dec  3 19:12:48 2013
@@ -142,17 +142,10 @@ public class InMemoryRepositoryServiceIm
         return result;
     }
 
-    public TypeDefinition createType(String repositoryId, TypeDefinition type, ExtensionsData
extension) {
-
-        if (null == repositoryId) {
-            throw new CmisInvalidArgumentException("Repository id may not be null");
-        }
+    public TypeDefinition createType(CallContext context, String repositoryId, TypeDefinition
type, ExtensionsData extension) {
 
+        validator.createType(context, repositoryId, type, extension);        
         TypeManager typeManager = fStoreManager.getTypeManager(repositoryId);
-        if (null == typeManager) {
-            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
-        }
-
         AbstractTypeDefinition newType = TypeValidator.completeType(type);
         TypeValidator.adjustTypeNamesAndId(newType);
         TypeValidator.checkType(typeManager, newType);
@@ -160,7 +153,8 @@ public class InMemoryRepositoryServiceIm
         return newType;
     }
 
-    public TypeDefinition updateType(String repositoryId, TypeDefinition type, ExtensionsData
extension) {
+    public TypeDefinition updateType(CallContext context, String repositoryId, TypeDefinition
type, ExtensionsData extension) {
+        validator.updateType(context, repositoryId, type, extension);        
         String typeId = type.getId();
         TypeManager typeManager = fStoreManager.getTypeManager(repositoryId);
         if (null == typeManager) {
@@ -176,17 +170,10 @@ public class InMemoryRepositoryServiceIm
         return type;
     }
 
-    public void deleteType(String repositoryId, String typeId, ExtensionsData extension)
{
+    public void deleteType(CallContext context, String repositoryId, String typeId, ExtensionsData
extension) {
 
+        validator.deleteType(context, repositoryId, typeId, extension);        
         TypeManager typeManager = fStoreManager.getTypeManager(repositoryId);
-        if (null == typeManager) {
-            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
-        }
-
-        TypeDefinitionContainer typeDefC = typeManager.getTypeById(typeId);
-        if (null == typeDefC) {
-            throw new CmisInvalidArgumentException("Cannot delete type unknown type id: "
+ typeId);
-        }
 
         ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
         if (objectStore.isTypeInUse(typeId)) {

Modified: chemistry/opencmis/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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java?rev=1547529&r1=1547528&r2=1547529&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
Tue Dec  3 19:12:48 2013
@@ -119,17 +119,17 @@ public class InMemoryService extends Abs
 
     @Override
     public TypeDefinition createType(String repositoryId, TypeDefinition type, ExtensionsData
extension) {
-        return fRepSvc.createType(repositoryId, type, extension);
+        return fRepSvc.createType(getCallContext(), repositoryId, type, extension);
     }
 
     @Override
     public TypeDefinition updateType(String repositoryId, TypeDefinition type, ExtensionsData
extension) {
-        return fRepSvc.updateType(repositoryId, type, extension);
+        return fRepSvc.updateType(getCallContext(), repositoryId, type, extension);
     }
 
     @Override
     public void deleteType(String repositoryId, String typeId, ExtensionsData extension)
{
-        fRepSvc.deleteType(repositoryId, typeId, extension);
+        fRepSvc.deleteType(getCallContext(), repositoryId, typeId, extension);
     }
 
     @Override

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.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/CmisServiceValidator.java?rev=1547529&r1=1547528&r2=1547529&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/CmisServiceValidator.java
Tue Dec  3 19:12:48 2013
@@ -23,6 +23,7 @@ import java.util.List;
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -157,4 +158,10 @@ public interface CmisServiceValidator {
     StoredObject createItem(CallContext context, String repositoryId, Properties properties,
String folderId,
             List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension);
 
+    void createType(CallContext callContext, String repositoryId, TypeDefinition type, ExtensionsData
extension);
+    
+    TypeDefinition updateType(CallContext callContext, String repositoryId, TypeDefinition
type, 
+            ExtensionsData extension);
+    
+    TypeDefinition deleteType(CallContext callContext, String repositoryId, String typeId,
ExtensionsData extension);
 }
\ No newline at end of file



Mime
View raw message