jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r563632 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src: main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/ test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/
Date Tue, 07 Aug 2007 19:27:28 GMT
Author: clombart
Date: Tue Aug  7 12:27:27 2007
New Revision: 563632

URL: http://svn.apache.org/viewvc?view=rev&rev=563632
Log:
Fix for issue 1054 - 2 different attributes are used in BeanDescriptor and CollectionDescriptor
to store the jcr type (jcrType and jcrNodeType).

Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java?view=diff&rev=563632&r1=563631&r2=563632
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/main/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
Tue Aug  7 12:27:27 2007
@@ -151,9 +151,9 @@
             getNamespaceHelper().setRegistry(session.getWorkspace().getNamespaceRegistry());
             ArrayList list = new ArrayList();
             
-            if (classDescriptor.getJcrNodeType() != null &&
-                    (classDescriptor.getJcrNodeType().startsWith("nt:")
-                    || classDescriptor.getJcrNodeType().startsWith("mix:")))
+            if (classDescriptor.getJcrType() != null &&
+                    (classDescriptor.getJcrType().startsWith("nt:")
+                    || classDescriptor.getJcrType().startsWith("mix:")))
             {
                 throw new NodeTypeCreationException("Namespace nt and mix are reserved namespaces.
Please specify your own.");
             }
@@ -161,7 +161,7 @@
             if (checkSuperTypes(session.getWorkspace().getNodeTypeManager(),
                     classDescriptor.getJcrSuperTypes()))
             {
-                NodeTypeDef nodeTypeDef = getNodeTypeDef(classDescriptor.getJcrNodeType(),
+                NodeTypeDef nodeTypeDef = getNodeTypeDef(classDescriptor.getJcrType(),
                         classDescriptor.getJcrSuperTypes(),
                         classDescriptor.getClassName());
 
@@ -183,7 +183,7 @@
                     Iterator beanIterator = classDescriptor.getBeanDescriptors().iterator();
                     while (beanIterator.hasNext()) {
                         BeanDescriptor field = (BeanDescriptor) beanIterator.next();
-                        if (field.getJcrType() != null) {
+                        if (this.isPropertyType(field.getJcrType())) {
                             propDefs.add(getPropertyDefinition(field.getFieldName(), field,
nodeTypeDef.getName()));
                         } else {
                             nodeDefs.add(getNodeDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
@@ -195,7 +195,7 @@
                     Iterator collectionIterator = classDescriptor.getCollectionDescriptors().iterator();
                     while (collectionIterator.hasNext()) {
                         CollectionDescriptor field = (CollectionDescriptor) collectionIterator.next();
-                        if (field.getJcrType() != null) {
+                        if (this.isPropertyType(field.getJcrType())) {
                             propDefs.add(getPropertyDefinition(field.getFieldName(), field,
nodeTypeDef.getName()));
                         } else {
                             nodeDefs.add(getNodeDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
@@ -348,8 +348,8 @@
             node.setName(getNamespaceHelper().getQName("*"));
         }
 
-        if (field.getJcrNodeType() != null) {
-            node.setRequiredPrimaryTypes(getJcrSuperTypes(field.getJcrNodeType()));
+        if (field.getJcrType() != null) {
+            node.setRequiredPrimaryTypes(getJcrSuperTypes(field.getJcrType()));
         }
 
         node.setDeclaringNodeType(declaringNodeType);
@@ -588,5 +588,19 @@
     public void setNamespaceHelper(NamespaceHelper object)
     {
         this.namespaceHelper = object;
+    }
+    
+
+    private boolean isPropertyType(String type)
+    {
+    	return (type.equals(PropertyType.TYPENAME_BINARY) ||
+    	        type.equals(PropertyType.TYPENAME_BOOLEAN) ||
+    	        type.equals(PropertyType.TYPENAME_DATE) ||
+    	        type.equals(PropertyType.TYPENAME_DOUBLE) ||
+    	        type.equals(PropertyType.TYPENAME_LONG) ||
+    	        type.equals(PropertyType.TYPENAME_NAME) ||
+    	        type.equals(PropertyType.TYPENAME_PATH) ||
+    	        type.equals(PropertyType.TYPENAME_REFERENCE) ||
+    	        type.equals(PropertyType.TYPENAME_STRING));    	       
     }
 }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java?view=diff&rev=563632&r1=563631&r2=563632
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-nodemanagement/src/test/java/org/apache/jackrabbit/ocm/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
Tue Aug  7 12:27:27 2007
@@ -97,7 +97,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.TestClass");
-        classDescriptor.setJcrNodeType("ocm:test2");
+        classDescriptor.setJcrType("ocm:test2");
         classDescriptor.setJcrSuperTypes("nt:base");
         
         FieldDescriptor field1 = new FieldDescriptor();
@@ -148,7 +148,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test3Class");
-        classDescriptor.setJcrNodeType("test3");
+        classDescriptor.setJcrType("test3");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         FieldDescriptor field1 = new FieldDescriptor();
@@ -193,7 +193,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test5Class");
-        classDescriptor.setJcrNodeType("ocm:test5");
+        classDescriptor.setJcrType("ocm:test5");
         classDescriptor.setJcrSuperTypes("ocm:test2");
         
         FieldDescriptor field1 = new FieldDescriptor();
@@ -217,7 +217,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test6Class");
-        classDescriptor.setJcrNodeType("nt:test3");
+        classDescriptor.setJcrType("nt:test3");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         FieldDescriptor field1 = new FieldDescriptor();
@@ -245,13 +245,14 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test9Class");
-        classDescriptor.setJcrNodeType("ocm:test9");
+        classDescriptor.setJcrType("ocm:test9");
         classDescriptor.setJcrSuperTypes("nt:base");
         
         CollectionDescriptor collection1 = new CollectionDescriptor();
         collection1.setFieldName("a");
         collection1.setJcrName("a");
         collection1.setJcrType("String");
+        
         classDescriptor.addCollectionDescriptor(collection1);
         
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
@@ -270,7 +271,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test10Class");
-        classDescriptor.setJcrNodeType("ocm:test10");
+        classDescriptor.setJcrType("ocm:test10");
         classDescriptor.setJcrSuperTypes("nt:base");
         
         BeanDescriptor bean1 = new BeanDescriptor();
@@ -296,14 +297,13 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test13Class");
-        classDescriptor.setJcrNodeType("ocm:test13");
+        classDescriptor.setJcrType("ocm:test13");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         CollectionDescriptor collection1 = new CollectionDescriptor();
         collection1.setFieldName("a");
         collection1.setJcrName("a");
-        collection1.setJcrType("String");      // should overwrite setJcrNodeType
-        collection1.setJcrNodeType("nt:base"); // should be ignored
+        collection1.setJcrType("String");            
         classDescriptor.addCollectionDescriptor(collection1);
 
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
@@ -322,14 +322,13 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test14Class");
-        classDescriptor.setJcrNodeType("ocm:test14");
+        classDescriptor.setJcrType("ocm:test14");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         BeanDescriptor bean1 = new BeanDescriptor();
         bean1.setFieldName("a");
         bean1.setJcrName("a");
-        bean1.setJcrType("String");      // should overwrite setJcrNodeType
-        bean1.setJcrNodeType("nt:base"); // should be ignored
+        bean1.setJcrType("String");         
         classDescriptor.addBeanDescriptor(bean1);
 
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
@@ -349,13 +348,13 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test11Class");
-        classDescriptor.setJcrNodeType("ocm:test11");
+        classDescriptor.setJcrType("ocm:test11");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         CollectionDescriptor collection1 = new CollectionDescriptor();
         collection1.setFieldName("a");
         collection1.setJcrName("b");
-        collection1.setJcrNodeType("nt:unstructured");
+        collection1.setJcrType("nt:unstructured");
         classDescriptor.addCollectionDescriptor(collection1);
 
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
@@ -376,13 +375,13 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test12Class");
-        classDescriptor.setJcrNodeType("ocm:test12");
+        classDescriptor.setJcrType("ocm:test12");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         BeanDescriptor bean1 = new BeanDescriptor();
         bean1.setFieldName("a");
         bean1.setJcrName("b");
-        bean1.setJcrNodeType("nt:unstructured");
+        bean1.setJcrType("nt:unstructured");
         classDescriptor.addBeanDescriptor(bean1);
 
         getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
@@ -394,7 +393,6 @@
         // assert property definition a
         NodeDefinition nodeDef = getChildNodeDefinition(test12.getChildNodeDefinitions(),
"b");
         assertNotNull(nodeDef);
-        assertNotNull(nodeDef);
         assertNotNull(nodeDef.getRequiredPrimaryTypes());
         assertEquals(nodeDef.getRequiredPrimaryTypes().length, 1);
         assertEquals(nodeDef.getRequiredPrimaryTypes()[0].getName(), "nt:unstructured");
@@ -404,7 +402,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test6Class");
-        classDescriptor.setJcrNodeType("ocm:test6");
+        classDescriptor.setJcrType("ocm:test6");
         classDescriptor.setJcrSuperTypes("nt:base");
         
         FieldDescriptor field1 = new FieldDescriptor();
@@ -421,7 +419,7 @@
         
         ClassDescriptor classDescriptor2 = new ClassDescriptor();
         classDescriptor2.setClassName("test.Test7Class");
-        classDescriptor2.setJcrNodeType("ocm:test7");
+        classDescriptor2.setJcrType("ocm:test7");
         classDescriptor2.setJcrSuperTypes("nt:base");
         
         FieldDescriptor field3 = new FieldDescriptor();
@@ -453,7 +451,7 @@
     {
         ClassDescriptor classDescriptor = new ClassDescriptor();
         classDescriptor.setClassName("test.Test8Class");
-        classDescriptor.setJcrNodeType("ocm:test8");
+        classDescriptor.setJcrType("ocm:test8");
         classDescriptor.setJcrSuperTypes("nt:base");
 
         FieldDescriptor field1 = new FieldDescriptor();



Mime
View raw message