chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1457426 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/ main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/org/apache/chemis...
Date Sun, 17 Mar 2013 11:32:26 GMT
Author: jens
Date: Sun Mar 17 11:32:26 2013
New Revision: 1457426

URL: http://svn.apache.org/r1457426
Log:
InMemory, TypeMutability: 
 - make incomplete types complete, 
 - filter items in getChildren() for CMIS 1.0 calls, 
 - allow colon in ids, 
 - add 1.1 allowable actions

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/NameValidator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.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/InMemoryRepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.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/DataObjectCreator.java?rev=1457426&r1=1457425&r2=1457426&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
Sun Mar 17 11:32:26 2013
@@ -30,17 +30,19 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.PolicyIdList;
-import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceContext;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Content;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Item;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Version;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
@@ -61,6 +63,7 @@ public class DataObjectCreator {
 
         boolean isFolder = so instanceof Folder;
         boolean isDocument = so instanceof Content;
+        boolean isItem = so instanceof Item;
         boolean isCheckedOut = false;
         boolean canCheckOut = false;
         boolean canCheckIn = false;
@@ -70,6 +73,7 @@ public class DataObjectCreator {
         boolean hasRendition = so.hasRendition(user);
         boolean canGetAcl = user != null && (isDocument || isFolder);
         boolean canSetAcl = canGetAcl;
+        boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
       
         
         if (so instanceof Version) {
             isCheckedOut = ((Version) so).isPwc();
@@ -83,13 +87,12 @@ public class DataObjectCreator {
         
         AllowableActionsImpl allowableActions = new AllowableActionsImpl();
         Set<Action> set = allowableActions.getAllowableActions();
-
         if (!isRootFolder) {
             set.add(Action.CAN_DELETE_OBJECT);
             set.add(Action.CAN_UPDATE_PROPERTIES);
         }
 
-        if (isFolder || isDocument) {
+        if (isFolder || isDocument || isItem) {
             set.add(Action.CAN_GET_PROPERTIES);
             if (!isRootFolder) {
                 set.add(Action.CAN_GET_OBJECT_PARENTS);   
@@ -107,6 +110,8 @@ public class DataObjectCreator {
 
             set.add(Action.CAN_CREATE_DOCUMENT);
             set.add(Action.CAN_CREATE_FOLDER);
+            if (cmis11)
+                set.add(Action.CAN_CREATE_ITEM);
             set.add(Action.CAN_GET_CHILDREN);
         }
 
@@ -126,11 +131,12 @@ public class DataObjectCreator {
             set.add(Action.CAN_GET_ALL_VERSIONS);
         }
 
-        if (isDocument) {
+        if (isDocument || isItem) {
             if (so instanceof Filing && ((Filing)so).hasParent()) {
                 set.add(Action.CAN_ADD_OBJECT_TO_FOLDER);
                 set.add(Action.CAN_REMOVE_OBJECT_FROM_FOLDER);
             }
+        if (isDocument)
             if (isVersioned) {
                 if (canCheckIn)
                     set.add(Action.CAN_SET_CONTENT_STREAM);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/NameValidator.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/NameValidator.java?rev=1457426&r1=1457425&r2=1457426&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/NameValidator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/NameValidator.java
Sun Mar 17 11:32:26 2013
@@ -40,14 +40,10 @@ public class NameValidator {
             return false;
         }
 
-        if (s.startsWith("cmis:")) {
-            s = s.substring(5);
-        }
-
         for (int i = 0; i < s.length(); i++) {
             char c = s.charAt(i);
-            if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <=
'z') || (c >= '0' && c <= '9') || c == '.' || c == '-'
-                    || c == '_' || c == ' ')) {
+            if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <=
'z') || (c >= '0' && c <= '9') || c == ':' || c == '.'
+                    || c == '-' || c == '_' || c == ' ')) {
                 return false;
             }
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.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/TypeValidator.java?rev=1457426&r1=1457425&r2=1457426&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java
Sun Mar 17 11:32:26 2013
@@ -20,18 +20,54 @@ package org.apache.chemistry.opencmis.in
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.ItemTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PolicyTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDateTimeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyHtmlDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyIdDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyUriDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.SecondaryTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
+import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ItemTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.SecondaryTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
 
 /**
@@ -58,9 +94,78 @@ public class TypeValidator {
         checkTypeId(tm, td.getId());
         checkTypeQueryName(tm, td.getQueryName());
         checkTypeLocalName(tm, td.getLocalName());
+        
+        if (null != td.getPropertyDefinitions())
+            TypeValidator.checkProperties(tm, td.getPropertyDefinitions().values());    
   
     }
     
-    public static void checkProperties(TypeManager tm, Collection<PropertyDefinition<?>>
pds) {
+    public static AbstractTypeDefinition completeType(TypeDefinition type) {
+        if (type instanceof DocumentTypeDefinition)
+            return completeTypeDoc((DocumentTypeDefinition) type);
+        else if (type instanceof FolderTypeDefinition)
+            return completeTyperFolder((FolderTypeDefinition) type);
+        else if (type instanceof PolicyTypeDefinition)
+            return null;
+        else if (type instanceof ItemTypeDefinition)
+            return completeTypeItem((ItemTypeDefinition) type);
+        else if (type instanceof RelationshipTypeDefinition)
+            return completeTypeRelationship((RelationshipTypeDefinition) type);
+        else if (type instanceof SecondaryTypeDefinition)
+            return completeTypeSecondary((SecondaryTypeDefinition) type);
+        else
+            return null;        
+    }
+
+    public static void adjustTypeNamesAndId(AbstractTypeDefinition typeDef) {
+        if (null == typeDef.getId()) {
+            typeDef.setId(UUID.randomUUID().toString());
+        } else {
+            if (!NameValidator.isValidId(typeDef.getId())) {
+                // if there are illegal characters adjust them
+                String newId = replaceInvalidCharacters(typeDef.getId());
+                typeDef.setId(newId);
+            }
+        }
+        if (!NameValidator.isValidQueryName(typeDef.getQueryName())) {
+            typeDef.setQueryName(typeDef.getId());
+        }
+        if (!NameValidator.isValidLocalName(typeDef.getLocalName())) {
+            typeDef.setLocalName(typeDef.getId());
+        }
+    }
+
+    private static void completeAbstractTypeDefinition(AbstractTypeDefinition td) {
+        if (td.isControllableAcl() == null)
+            td.setIsControllableAcl(true);
+        if (td.isControllablePolicy() == null)
+            td.setIsControllablePolicy(false);
+        if (td.isCreatable() == null)
+            td.setIsCreatable(true);
+        if (td.isFileable() == null)
+            td.setIsFileable(true);
+        td.setIsFulltextIndexed(false);
+        td.setIsIncludedInSupertypeQuery(false);
+        if (td.isQueryable() == null)
+            td.setIsQueryable(true);
+        td.setParentTypeId(td.getParentTypeId());
+        TypeMutabilityImpl tm = new TypeMutabilityImpl();
+        tm.setCanCreate(true);
+        tm.setCanDelete(true);
+        tm.setCanUpdate(true);
+        td.setTypeMutability(tm);
+        td.setExtensions(td.getExtensions());
+        
+        Map<String, PropertyDefinition<?>> propDefsNew = new HashMap<String,
PropertyDefinition<?>>();
+        Map<String, PropertyDefinition<?>> propDefs = td.getPropertyDefinitions();
+        for (PropertyDefinition<?> pd : propDefs.values()) {
+            AbstractPropertyDefinition<?> pdNew = completePropertyDef(pd);
+            adjustPropertyNamesAndId(pdNew);
+            propDefsNew.put(pdNew.getId(), pd);
+        }
+        td.setPropertyDefinitions(propDefsNew);
+    }
+
+    private static void checkProperties(TypeManager tm, Collection<PropertyDefinition<?>>
pds) {
 
         Collection<TypeDefinitionContainer> tdl = tm.getTypeDefinitionList();
         for (PropertyDefinition<?> pd2 : pds) {
@@ -102,6 +207,192 @@ public class TypeValidator {
         }        
     }
     
+    private static void adjustPropertyNamesAndId(AbstractPropertyDefinition<?> propDef)
{
+        if (null == propDef.getId()) {
+            propDef.setId(UUID.randomUUID().toString());
+        } else {
+            if (!NameValidator.isValidId(propDef.getId())) {
+                String newId = replaceInvalidCharacters(propDef.getId());
+                propDef.setId(newId);
+            }
+        }
+        if (!NameValidator.isValidQueryName(propDef.getQueryName())) {
+            propDef.setQueryName(propDef.getId());
+        }
+        if (!NameValidator.isValidLocalName(propDef.getLocalName())) {
+            propDef.setLocalName(propDef.getId());
+        }
+    }
+
+    private static String replaceInvalidCharacters(String id) {
+        // if there are illegal characters adjust them
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i<id.length(); i++) {
+            if (NameValidator.isValidId(id.substring(i, i+1)))
+                sb.append(id.charAt(i));
+            else
+                sb.append('_');
+        }
+        return sb.toString();
+    }
+
+    private static DocumentTypeDefinitionImpl completeTypeDoc(DocumentTypeDefinition type)
{
+        DocumentTypeDefinitionImpl td = new DocumentTypeDefinitionImpl();
+        td.initialize(type);
+        completeAbstractTypeDefinition(td);
+        td.setIsVersionable(type.isVersionable());
+        td.setContentStreamAllowed(type.getContentStreamAllowed());
+        if (td.isVersionable() == null)
+            td.setIsVersionable(false);
+        if (td.getContentStreamAllowed() == null)
+            td.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
+        return td;
+    }
+
+    private static FolderTypeDefinitionImpl completeTyperFolder(FolderTypeDefinition type)
{
+        FolderTypeDefinitionImpl td = new FolderTypeDefinitionImpl();
+        td.initialize(type);
+        completeAbstractTypeDefinition(td);
+        return td;
+    }
+
+    private static RelationshipTypeDefinitionImpl completeTypeRelationship(RelationshipTypeDefinition
type) {
+        RelationshipTypeDefinitionImpl td = new RelationshipTypeDefinitionImpl();
+        td.initialize(type);
+        completeAbstractTypeDefinition(td);
+        td.setAllowedSourceTypes(type.getAllowedSourceTypeIds());
+        td.setAllowedTargetTypes(type.getAllowedTargetTypeIds());
+        return td;
+    }
+
+    private static ItemTypeDefinitionImpl completeTypeItem(ItemTypeDefinition type) {
+        ItemTypeDefinitionImpl td = new ItemTypeDefinitionImpl();
+        td.initialize(type);
+        completeAbstractTypeDefinition(td);
+        return td;        
+    }
+
+    private static SecondaryTypeDefinitionImpl completeTypeSecondary(SecondaryTypeDefinition
type) {
+        SecondaryTypeDefinitionImpl td = new SecondaryTypeDefinitionImpl();
+        td.initialize(type);
+        completeAbstractTypeDefinition(td);
+        return td;        
+    }
+
+    // When creating types PropertyDefinitions may only be partially filled, fill all fields
+    // to make a complete definition
+    private static AbstractPropertyDefinition<?> completePropertyDef(PropertyDefinition<?>
pdSrc) {
+        AbstractPropertyDefinition<?> newPropDef = clonePropertyDefinition(pdSrc);
+        
+        if (null == newPropDef.getPropertyType())
+            throw new CmisInvalidArgumentException("Property " + pdSrc.getId() + "has no
property type.");
+        if (null == newPropDef.getId())
+            newPropDef.setId(UUID.randomUUID().toString());
+        if (null == newPropDef.getQueryName())
+            newPropDef.setQueryName(pdSrc.getId());
+        if (null == newPropDef.getLocalName())
+            newPropDef.setLocalName(pdSrc.getId());
+
+        if (null == newPropDef.getCardinality())
+            newPropDef.setCardinality(Cardinality.SINGLE);
+        if (null == newPropDef.isOrderable())
+            newPropDef.setIsOrderable(true);
+        if (null == newPropDef.isQueryable())
+            newPropDef.setIsQueryable(true);
+        if (null == newPropDef.isRequired())
+            newPropDef.setIsRequired(false);
+        if (null == newPropDef.getUpdatability())
+            newPropDef.setUpdatability(Updatability.READWRITE);
+
+        return newPropDef;
+    }
+
+    private static AbstractPropertyDefinition<?> clonePropertyDefinition(PropertyDefinition<?>
pd) {
+        if (pd instanceof PropertyBooleanDefinition) {
+            PropertyBooleanDefinitionImpl pdBoolDef = new PropertyBooleanDefinitionImpl();
+            PropertyBooleanDefinitionImpl pdSrc = (PropertyBooleanDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdBoolDef);
+            pdBoolDef.setChoices(pdSrc.getChoices());
+            pdBoolDef.setDefaultValue(pdSrc.getDefaultValue());
+            return pdBoolDef;
+        } else if (pd instanceof PropertyDateTimeDefinition) {
+            PropertyDateTimeDefinitionImpl pdDateDef = new PropertyDateTimeDefinitionImpl();
+            PropertyDateTimeDefinitionImpl pdSrc = (PropertyDateTimeDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdDateDef);
+            pdDateDef.setChoices(pdSrc.getChoices());
+            pdDateDef.setDefaultValue(pdSrc.getDefaultValue());
+            pdDateDef.setDateTimeResolution(pdSrc.getDateTimeResolution());
+            return pdDateDef;
+        } else if (pd instanceof PropertyDecimalDefinition) {
+            PropertyDecimalDefinitionImpl pdDecDef = new PropertyDecimalDefinitionImpl();
+            PropertyDecimalDefinitionImpl pdSrc = (PropertyDecimalDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdDecDef);
+            pdDecDef.setChoices(pdSrc.getChoices());
+            pdDecDef.setDefaultValue(pdSrc.getDefaultValue());
+            pdDecDef.setMinValue(pdSrc.getMinValue());
+            pdDecDef.setMaxValue(pdSrc.getMaxValue());
+            pdDecDef.setPrecision(pdSrc.getPrecision());
+            return pdDecDef;
+        } else if (pd instanceof PropertyHtmlDefinition) {
+            PropertyHtmlDefinitionImpl pdHtmlDef = new PropertyHtmlDefinitionImpl();
+            PropertyHtmlDefinitionImpl pdSrc = (PropertyHtmlDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdHtmlDef);
+            pdHtmlDef.setChoices(pdSrc.getChoices());
+            pdHtmlDef.setDefaultValue(pdSrc.getDefaultValue());
+            return pdHtmlDef;
+        } else if (pd instanceof PropertyIdDefinition) {
+            PropertyIdDefinitionImpl pdIdDef = new PropertyIdDefinitionImpl();
+            PropertyIdDefinitionImpl pdSrc = (PropertyIdDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdIdDef);
+            pdIdDef.setChoices(pdSrc.getChoices());
+            pdIdDef.setDefaultValue(pdSrc.getDefaultValue());
+            return pdIdDef;
+        } else if (pd instanceof PropertyIntegerDefinition) {
+            PropertyIntegerDefinitionImpl pdIntDef = new PropertyIntegerDefinitionImpl();
+            PropertyIntegerDefinitionImpl pdSrc = (PropertyIntegerDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdIntDef);
+            pdIntDef.setChoices(pdSrc.getChoices());
+            pdIntDef.setDefaultValue(pdSrc.getDefaultValue());
+            pdIntDef.setMinValue(pdSrc.getMinValue());
+            pdIntDef.setMaxValue(pdSrc.getMaxValue());
+            return pdIntDef;
+        } else if (pd instanceof PropertyStringDefinition) {
+            PropertyStringDefinitionImpl pdStringDef = new PropertyStringDefinitionImpl();
+            PropertyStringDefinitionImpl pdSrc = (PropertyStringDefinitionImpl) pd;
+            initializeAbstractPropertyDefinition(pd, pdStringDef);
+            pdStringDef.setChoices(pdSrc.getChoices());
+            pdStringDef.setDefaultValue(pdSrc.getDefaultValue());
+            pdStringDef.setMaxLength(pdSrc.getMaxLength());
+            return pdStringDef;
+        } else if (pd instanceof PropertyUriDefinition) {
+            PropertyUriDefinitionImpl pdUriDef = new PropertyUriDefinitionImpl();
+            PropertyUriDefinition pdSrc = (PropertyUriDefinition) pd;
+            initializeAbstractPropertyDefinition(pd, pdUriDef);
+            pdUriDef.setChoices(pdSrc.getChoices());
+            pdUriDef.setDefaultValue(pdSrc.getDefaultValue());
+            return pdUriDef;
+        } else 
+            return null;
+    }
+
+    private static void initializeAbstractPropertyDefinition(PropertyDefinition<?>
pdSrc, AbstractPropertyDefinition<?> pdTarget) {
+        pdTarget.setCardinality(pdSrc.getCardinality());
+        pdTarget.setDescription(pdSrc.getDescription());
+        pdTarget.setDisplayName(pdSrc.getDisplayName());
+        pdTarget.setExtensions(pdSrc.getExtensions());
+        pdTarget.setId(pdSrc.getId());
+        pdTarget.setIsInherited(false);
+        pdTarget.setIsOpenChoice(pdSrc.isOpenChoice());
+        pdTarget.setIsOrderable(pdSrc.isOrderable());
+        pdTarget.setIsQueryable(pdSrc.isQueryable());
+        pdTarget.setIsRequired(pdSrc.isRequired());
+        pdTarget.setLocalName(pdSrc.getLocalName());
+        pdTarget.setLocalNamespace(pdSrc.getLocalNamespace());
+        pdTarget.setPropertyType(pdSrc.getPropertyType());
+        pdTarget.setQueryName(pdSrc.getQueryName());
+        pdTarget.setUpdatability(pdSrc.getUpdatability());
+    }
+
     public static Acl expandAclMakros(String user, Acl acl) {
      	boolean mustCopy = false;
     	

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=1457426&r1=1457425&r2=1457426&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
Sun Mar 17 11:32:26 2013
@@ -34,6 +34,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
@@ -52,6 +53,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Item;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.SingleFiling;
@@ -281,7 +283,8 @@ public class InMemoryNavigationServiceIm
         ObjectStore fs = fStoreManager.getObjectStore(repositoryId);
         StoredObject so = fs.getObjectById(folderId);
         Folder folder = null;
-
+        boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
+;
         if (so == null) {
             throw new CmisObjectNotFoundException("Unknown object id: " + folderId);
         }
@@ -297,6 +300,9 @@ public class InMemoryNavigationServiceIm
                 .getChildren(maxItems, skipCount, user);
 
         for (StoredObject spo : children.getChildren()) {
+            if (cmis11 && spo instanceof Item)
+                continue; // ignore items for CMIS 1.1‚
+            
             ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
             if (includePathSegments != null && includePathSegments) {
                 oifd.setPathSegment(spo.getName());

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=1457426&r1=1457425&r2=1457426&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
Sun Mar 17 11:32:26 2013
@@ -21,22 +21,61 @@ package org.apache.chemistry.opencmis.in
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
 
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.ItemTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PolicyTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDateTimeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyHtmlDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyIdDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyUriDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.SecondaryTypeDefinition;
 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.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
+import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ItemTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.SecondaryTypeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.inmemory.NameValidator;
 import org.apache.chemistry.opencmis.inmemory.TypeValidator;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.TypeManagerCreatable;
+import org.apache.chemistry.opencmis.server.support.TypeManager;
 
 public class InMemoryRepositoryServiceImpl extends InMemoryAbstractServiceImpl {
 
@@ -152,12 +191,11 @@ public class InMemoryRepositoryServiceIm
         if (null == typeManager)
             throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
         
-        TypeValidator.checkType(typeManager, type);
-        if (null != type.getPropertyDefinitions())
-            TypeValidator.checkProperties(typeManager, type.getPropertyDefinitions().values());
-        
-        typeManager.addTypeDefinition(type);
-        return type;
+        AbstractTypeDefinition newType = TypeValidator.completeType(type);
+        TypeValidator.adjustTypeNamesAndId(newType);
+        TypeValidator.checkType(typeManager, newType);
+        typeManager.addTypeDefinition(newType);
+        return newType;
     }
 
     public TypeDefinition updateType(String repositoryId, TypeDefinition type, ExtensionsData
extension) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.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/ItemImpl.java?rev=1457426&r1=1457425&r2=1457426&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ItemImpl.java
Sun Mar 17 11:32:26 2013
@@ -18,11 +18,13 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
 
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Item;
+
 /**
  * itemImpl is used for CMIS:item objects. Items are fileable  but do not have content
  *
  */
-public class ItemImpl extends AbstractMultiFilingImpl {
+public class ItemImpl extends AbstractMultiFilingImpl implements Item {
 
     ItemImpl(ObjectStoreImpl objStore) {
         super(objStore);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.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/RepositoryServiceMutabilityTest.java?rev=1457426&r1=1457425&r2=1457426&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java
Sun Mar 17 11:32:26 2013
@@ -160,7 +160,9 @@ public class RepositoryServiceMutability
         // test illegal type id
         InMemoryDocumentTypeDefinition typeDefRef = createTypeForAddingAtRuntime();
         typeDefRef.setId(typeDefRef.getId() + "!!!");
-        checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+        TypeDefinition typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
+        assertEquals(TYPE_ID_MUTABILITY + "___", typeDefNew.getId());
+        fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY+"___", null);
 
         // test illegal parent type id
         typeDefRef = createTypeForAddingAtRuntime();
@@ -170,27 +172,37 @@ public class RepositoryServiceMutability
         // test null type id
         typeDefRef = createTypeForAddingAtRuntime();
         typeDefRef.setId(null);
-        checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+        typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
+        assertTrue(null != typeDefNew.getId() && typeDefNew.getId().length() >
0);
+        fRepSvc.deleteType(repositoryId, typeDefNew.getId(), null);
         
         // test null query name
         typeDefRef = createTypeForAddingAtRuntime();
         typeDefRef.setQueryName(null);
-        checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+        typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
+        assertEquals(TYPE_ID_MUTABILITY, typeDefNew.getQueryName());
+        fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
 
         // test illegal query name
         typeDefRef = createTypeForAddingAtRuntime();
         typeDefRef.setQueryName(typeDefRef.getQueryName() + "!!!");
-        checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+        typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
+        assertEquals(TYPE_ID_MUTABILITY, typeDefNew.getQueryName());
+        fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
 
         // test null local name
         typeDefRef = createTypeForAddingAtRuntime();
         typeDefRef.setLocalName(null);
-        checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+        assertEquals(TYPE_ID_MUTABILITY, typeDefNew.getLocalName());
+        typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
+        fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
 
         // test illegal local name
         typeDefRef = createTypeForAddingAtRuntime();
         typeDefRef.setLocalName(typeDefRef.getLocalName() + "!!!");
-        checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+        assertEquals(TYPE_ID_MUTABILITY, typeDefNew.getLocalName());
+        typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
+        fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
 
         log.info("... testTypeMutabilityTypeNameConstraints() finished.");              
     }



Mime
View raw message