chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1460345 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory: ./ server/ storedobj/impl/ types/
Date Sun, 24 Mar 2013 12:59:16 GMT
Author: jens
Date: Sun Mar 24 12:59:16 2013
New Revision: 1460345

URL: http://svn.apache.org/r1460345
Log:
InMemory: Remove all JAXB dependencies

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/TypeUtil.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.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/InMemoryRepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/Permission.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.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/TypeManagerImpl.java?rev=1460345&r1=1460344&r2=1460345&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java
Sun Mar 24 12:59:16 2013
@@ -30,10 +30,8 @@ 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.exceptions.CmisNotSupportedException;
-import org.apache.chemistry.opencmis.commons.impl.Converter;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDefinitionType;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.TypeManagerCreatable;
 import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
@@ -42,6 +40,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryPolicyTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryRelationshipTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemorySecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.TypeUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -245,10 +244,8 @@ public class TypeManagerImpl implements 
     }
 
     private static PropertyDefinition<?> clonePropertyDefinition(PropertyDefinition<?>
src) {
-        // use JAXB converter to easily clone a property definition
-        CmisPropertyDefinitionType tmp = Converter.convert(src);
-        PropertyDefinition<?> clone = Converter.convert(tmp);
+        PropertyDefinition<?> clone = TypeUtil.clonePropertyDefinition(src);
         return clone;
     }
-
+    
 }

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=1460345&r1=1460344&r2=1460345&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 24 12:59:16 2013
@@ -57,6 +57,7 @@ import org.apache.chemistry.opencmis.com
 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.PolicyTypeDefinitionImpl;
 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;
@@ -68,6 +69,7 @@ import org.apache.chemistry.opencmis.com
 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.inmemory.types.TypeUtil;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
 
 /**
@@ -109,9 +111,9 @@ public class TypeValidator {
         if (type instanceof DocumentTypeDefinition)
             return completeTypeDoc((DocumentTypeDefinition) type);
         else if (type instanceof FolderTypeDefinition)
-            return completeTyperFolder((FolderTypeDefinition) type);
+            return completeTypeFolder((FolderTypeDefinition) type);
         else if (type instanceof PolicyTypeDefinition)
-            return null;
+            return completeTypePolicy((PolicyTypeDefinition)type);
         else if (type instanceof ItemTypeDefinition)
             return completeTypeItem((ItemTypeDefinition) type);
         else if (type instanceof RelationshipTypeDefinition)
@@ -122,6 +124,23 @@ public class TypeValidator {
             return null;        
     }
 
+    public static TypeDefinition cloneType(TypeDefinition type) {
+        if (type instanceof DocumentTypeDefinition)
+            return cloneTypeDoc((DocumentTypeDefinition) type);
+        else if (type instanceof FolderTypeDefinition)
+            return cloneTypeFolder((FolderTypeDefinition) type);
+        else if (type instanceof PolicyTypeDefinition)
+            return cloneTypePolicy((PolicyTypeDefinition) type);
+        else if (type instanceof ItemTypeDefinition)
+            return cloneTypeItem((ItemTypeDefinition) type);
+        else if (type instanceof RelationshipTypeDefinition)
+            return cloneTypeRelationship((RelationshipTypeDefinition) type);
+        else if (type instanceof SecondaryTypeDefinition)
+            return cloneTypeSecondary((SecondaryTypeDefinition) type);
+        else
+            return null;        
+    }
+
     public static void adjustTypeNamesAndId(AbstractTypeDefinition typeDef) {
         if (null == typeDef.getId()) {
             typeDef.setId(UUID.randomUUID().toString());
@@ -245,8 +264,7 @@ public class TypeValidator {
     }
 
     private static DocumentTypeDefinitionImpl completeTypeDoc(DocumentTypeDefinition type)
{
-        DocumentTypeDefinitionImpl td = new DocumentTypeDefinitionImpl();
-        td.initialize(type);
+        DocumentTypeDefinitionImpl td = cloneTypeDoc(type);
         completeAbstractTypeDefinition(td);
         td.setIsVersionable(type.isVersionable());
         td.setContentStreamAllowed(type.getContentStreamAllowed());
@@ -257,40 +275,84 @@ public class TypeValidator {
         return td;
     }
 
-    private static FolderTypeDefinitionImpl completeTyperFolder(FolderTypeDefinition type)
{
-        FolderTypeDefinitionImpl td = new FolderTypeDefinitionImpl();
+    private static DocumentTypeDefinitionImpl cloneTypeDoc(DocumentTypeDefinition type) {
+        DocumentTypeDefinitionImpl td = new DocumentTypeDefinitionImpl();
         td.initialize(type);
         completeAbstractTypeDefinition(td);
+        td.setIsVersionable(type.isVersionable());
+        td.setContentStreamAllowed(type.getContentStreamAllowed());
+        return td;
+    }
+
+    private static FolderTypeDefinitionImpl completeTypeFolder(FolderTypeDefinition type)
{
+        FolderTypeDefinitionImpl td = cloneTypeFolder(type);
+        completeAbstractTypeDefinition(td);
+        return td;
+    }
+
+    private static FolderTypeDefinitionImpl cloneTypeFolder(FolderTypeDefinition type) {
+        FolderTypeDefinitionImpl td = new FolderTypeDefinitionImpl();
+        td.initialize(type);
         return td;
     }
 
     private static RelationshipTypeDefinitionImpl completeTypeRelationship(RelationshipTypeDefinition
type) {
+        RelationshipTypeDefinitionImpl td = cloneTypeRelationship(type);
+        completeAbstractTypeDefinition(td);
+        td.setAllowedSourceTypes(type.getAllowedSourceTypeIds());
+        td.setAllowedTargetTypes(type.getAllowedTargetTypeIds());
+        return td;
+    }
+
+    private static RelationshipTypeDefinitionImpl cloneTypeRelationship(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();
+        ItemTypeDefinitionImpl td = cloneTypeItem(type);
         td.initialize(type);
         completeAbstractTypeDefinition(td);
         return td;        
     }
 
+    private static ItemTypeDefinitionImpl cloneTypeItem(ItemTypeDefinition type) {
+        ItemTypeDefinitionImpl td = new ItemTypeDefinitionImpl();
+        td.initialize(type);
+        return td;        
+    }
+    
     private static SecondaryTypeDefinitionImpl completeTypeSecondary(SecondaryTypeDefinition
type) {
+        SecondaryTypeDefinitionImpl td = cloneTypeSecondary(type);
+        completeAbstractTypeDefinition(td);
+        return td;        
+    }
+
+    private static SecondaryTypeDefinitionImpl cloneTypeSecondary(SecondaryTypeDefinition
type) {
         SecondaryTypeDefinitionImpl td = new SecondaryTypeDefinitionImpl();
         td.initialize(type);
-        completeAbstractTypeDefinition(td);
         return td;        
     }
+    
+    private static PolicyTypeDefinitionImpl completeTypePolicy(PolicyTypeDefinition type)
{
+        PolicyTypeDefinitionImpl td = cloneTypePolicy(type);
+        completeAbstractTypeDefinition(td);
+        return null;
+    }
+
+    private static PolicyTypeDefinitionImpl cloneTypePolicy(PolicyTypeDefinition type) {
+        PolicyTypeDefinitionImpl td = new PolicyTypeDefinitionImpl();
+        td.initialize(td);
+        return null;
+    }
 
     // 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);
+        AbstractPropertyDefinition<?> newPropDef = TypeUtil.clonePropertyDefinition(pdSrc);
         
         if (null == newPropDef.getPropertyType())
             throw new CmisInvalidArgumentException("Property " + pdSrc.getId() + "has no
property type.");
@@ -315,92 +377,6 @@ public class TypeValidator {
         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/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=1460345&r1=1460344&r2=1460345&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 24 12:59:16 2013
@@ -21,61 +21,23 @@ 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 {
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.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/InMemoryServiceFactoryImpl.java?rev=1460345&r1=1460344&r2=1460345&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
Sun Mar 24 12:59:16 2013
@@ -18,8 +18,12 @@
  */
 package org.apache.chemistry.opencmis.inmemory.server;
 
+import static org.apache.chemistry.opencmis.commons.impl.XMLUtils.next;
+
+import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -33,18 +37,18 @@ import java.util.concurrent.ScheduledExe
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
 
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
-import org.apache.chemistry.opencmis.commons.impl.Converter;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
 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.jaxb.CmisTypeDefinitionType;
 import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
@@ -56,8 +60,6 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.TypeManagerCreatable;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerFactory;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryJaxbHelper;
-import org.apache.chemistry.opencmis.inmemory.types.TypeDefinitions;
 import org.apache.chemistry.opencmis.server.support.CmisServiceWrapper;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
 import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
@@ -249,29 +251,54 @@ public class InMemoryServiceFactoryImpl 
 
     private void importTypesFromFile(TypeManagerCreatable tmc, String typeDefsFileName) {
 
-        InputStream is = this.getClass().getResourceAsStream("/" + typeDefsFileName);
+        BufferedInputStream stream = null;
+        TypeDefinition typeDef = null;
+        File f = new File(typeDefsFileName);
 
-        if (null == is) {
+        if (!f.canRead()) {
             LOG.warn("Resource file with type definitions " + typeDefsFileName
                     + " could not be found, no types will be created.");
             return;
         }
-
         try {
-            TypeDefinition typeDef = null;
-            Unmarshaller u = InMemoryJaxbHelper.createUnmarshaller();
-            JAXBElement<TypeDefinitions> types = (JAXBElement<TypeDefinitions>)
u.unmarshal(is);
-            for (CmisTypeDefinitionType td : types.getValue().getTypeDefinitions()) {
-                LOG.debug("Found type in file: " + td.getLocalName());
-                typeDef = Converter.convert(td);
-                if (typeDef.getPropertyDefinitions() == null) {
-                    ((AbstractTypeDefinition) typeDef)
-                            .setPropertyDefinitions(new LinkedHashMap<String, PropertyDefinition<?>>());
+            stream = new BufferedInputStream(new FileInputStream(f));
+            XMLStreamReader parser = XMLUtils.createParser(stream);
+            XMLUtils.findNextStartElemenet(parser);
+
+            // walk through all nested tags in top element
+            while (true) {
+                int event = parser.getEventType();
+                if (event == XMLStreamReader.START_ELEMENT) {
+                    QName name = parser.getName();
+                    if (name.getLocalPart().equals("type")) {
+                        typeDef = XMLConverter.convertTypeDefinition(parser);
+                        LOG.debug("Found type in file: " + typeDef.getLocalName());
+                        if (typeDef.getPropertyDefinitions() == null) {
+                            ((AbstractTypeDefinition) typeDef)
+                                    .setPropertyDefinitions(new LinkedHashMap<String,
PropertyDefinition<?>>());
+                        }
+                        tmc.addTypeDefinition(typeDef);
+                    } 
+                    XMLUtils.next(parser);
+                } else if (event == XMLStreamReader.END_ELEMENT) {
+                    break;
+                } else {
+                    if (!next(parser)) {
+                        break;
+                    }
                 }
-                tmc.addTypeDefinition(typeDef);
             }
+            parser.close();
         } catch (Exception e) {
             LOG.error("Could not load type definitions from file '" + typeDefsFileName +
"': " + e);
+        } finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/Permission.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/Permission.java?rev=1460345&r1=1460344&r2=1460345&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/Permission.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/Permission.java
Sun Mar 24 12:59:16 2013
@@ -18,7 +18,7 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
 
-import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumBasicPermissions;
+import org.apache.chemistry.opencmis.commons.BasicPermissions;
 
 
 public enum Permission {
@@ -27,6 +27,31 @@ public enum Permission {
     WRITE("write"),
     ALL("all");
     
+    private enum EnumBasicPermissions {
+
+        CMIS_READ(BasicPermissions.READ),
+        CMIS_WRITE(BasicPermissions.WRITE),
+        CMIS_ALL(BasicPermissions.ALL);
+        private final String value;
+
+        EnumBasicPermissions(String v) {
+            value = v;
+        }
+
+        public String value() {
+            return value;
+        }
+
+        public static EnumBasicPermissions fromValue(String v) {
+            for (EnumBasicPermissions c: EnumBasicPermissions.values()) {
+                if (c.value.equals(v)) {
+                    return c;
+                }
+            }
+            throw new IllegalArgumentException(v);
+        }
+    }
+
     private final String value;
     
     Permission(String v) {

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/TypeUtil.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/types/TypeUtil.java?rev=1460345&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/TypeUtil.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/TypeUtil.java
Sun Mar 24 12:59:16 2013
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.types;
+
+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.impl.dataobjects.AbstractPropertyDefinition;
+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.PolicyTypeDefinitionImpl;
+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;
+
+public final class TypeUtil {
+    
+    public static TypeDefinition cloneType(TypeDefinition type) {
+        if (type instanceof DocumentTypeDefinition)
+            return cloneTypeDoc((DocumentTypeDefinition) type);
+        else if (type instanceof FolderTypeDefinition)
+            return cloneTypeFolder((FolderTypeDefinition) type);
+        else if (type instanceof PolicyTypeDefinition)
+            return cloneTypePolicy((PolicyTypeDefinition) type);
+        else if (type instanceof ItemTypeDefinition)
+            return cloneTypeItem((ItemTypeDefinition) type);
+        else if (type instanceof RelationshipTypeDefinition)
+            return cloneTypeRelationship((RelationshipTypeDefinition) type);
+        else if (type instanceof SecondaryTypeDefinition)
+            return cloneTypeSecondary((SecondaryTypeDefinition) type);
+        else
+            return null;        
+    }
+
+    public 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;
+    }
+
+    public static DocumentTypeDefinitionImpl cloneTypeDoc(DocumentTypeDefinition type) {
+        DocumentTypeDefinitionImpl td = new DocumentTypeDefinitionImpl();
+        td.initialize(type);
+        td.setIsVersionable(type.isVersionable());
+        td.setContentStreamAllowed(type.getContentStreamAllowed());
+        return td;
+    }
+
+    public static FolderTypeDefinitionImpl cloneTypeFolder(FolderTypeDefinition type) {
+        FolderTypeDefinitionImpl td = new FolderTypeDefinitionImpl();
+        td.initialize(type);
+        return td;
+    }
+
+    public static RelationshipTypeDefinitionImpl cloneTypeRelationship(RelationshipTypeDefinition
type) {
+        RelationshipTypeDefinitionImpl td = new RelationshipTypeDefinitionImpl();
+        td.initialize(type);
+        td.setAllowedSourceTypes(type.getAllowedSourceTypeIds());
+        td.setAllowedTargetTypes(type.getAllowedTargetTypeIds());
+        return td;
+    }
+
+    public static ItemTypeDefinitionImpl cloneTypeItem(ItemTypeDefinition type) {
+        ItemTypeDefinitionImpl td = new ItemTypeDefinitionImpl();
+        td.initialize(type);
+        return td;        
+    }
+    
+    public static SecondaryTypeDefinitionImpl cloneTypeSecondary(SecondaryTypeDefinition
type) {
+        SecondaryTypeDefinitionImpl td = new SecondaryTypeDefinitionImpl();
+        td.initialize(type);
+        return td;        
+    }
+    
+    public static PolicyTypeDefinitionImpl cloneTypePolicy(PolicyTypeDefinition type) {
+        PolicyTypeDefinitionImpl td = new PolicyTypeDefinitionImpl();
+        td.initialize(td);
+        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());
+    }
+
+
+}



Mime
View raw message