jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1342692 - /jackrabbit/commons/ocm/trunk/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java
Date Fri, 25 May 2012 15:42:01 GMT
Author: ard
Date: Fri May 25 15:42:01 2012
New Revision: 1342692

URL: http://svn.apache.org/viewvc?rev=1342692&view=rev
Log:
OCM-48 use the collectionDescriptor jcrType to create the jcr collection node with if non-empty.

Also similarly, in updateManagableCollection, when removing the old collection node, again
re-create one of the same type

Modified:
    jackrabbit/commons/ocm/trunk/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java

Modified: jackrabbit/commons/ocm/trunk/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/ocm/trunk/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java?rev=1342692&r1=1342691&r2=1342692&view=diff
==============================================================================
--- jackrabbit/commons/ocm/trunk/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java
(original)
+++ jackrabbit/commons/ocm/trunk/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java
Fri May 25 15:42:01 2012
@@ -32,8 +32,10 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.VersionException;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.jackrabbit.ocm.exception.JcrMappingException;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjectsUtil;
@@ -93,7 +95,7 @@ public class DefaultCollectionConverterI
     }
 
     /**
-     * @see AbstractCollectionConverterImpl#doInsertCollection(Session, Node, CollectionDescriptor,
ManageableCollection)
+     * @see AbstractCollectionConverterImpl#doInsertCollection(Session, Node, CollectionDescriptor,
ManageableObjects)
      */
     protected void doInsertCollection(Session session,
                                       Node parentNode,
@@ -111,7 +113,12 @@ public class DefaultCollectionConverterI
                     + collectionDescriptor.getFieldName() + " for the classdescriptor : "
+ collectionDescriptor.getClassDescriptor().getClassName());
         }
 
-        Node collectionNode = parentNode.addNode(jcrName);
+        Node collectionNode;
+        if (!StringUtils.isBlank(collectionDescriptor.getJcrType())) {
+            collectionNode = parentNode.addNode(jcrName, collectionDescriptor.getJcrType());
+        } else {
+            collectionNode = parentNode.addNode(jcrName);
+        }
 
         ClassDescriptor elementClassDescriptor = mapper.getClassDescriptorByClass( ReflectionUtils.forName(collectionDescriptor.getElementClassName()));
 
@@ -162,7 +169,7 @@ public class DefaultCollectionConverterI
 
     /**
      *
-     * @see AbstractCollectionConverterImpl#doUpdateCollection(Session, Node, CollectionDescriptor,
ManageableCollection)
+     * @see AbstractCollectionConverterImpl#doUpdateCollection(Session, Node, CollectionDescriptor,
ManageableObjects)
      */
     protected void doUpdateCollection(Session session,
                                  Node parentNode,
@@ -207,8 +214,9 @@ public class DefaultCollectionConverterI
         //  If the collection elements have not an id, it is not possible to find the matching
JCR nodes 
         //  => delete the complete collection
         if (!elementClassDescriptor.hasIdField() && !elementClassDescriptor.hasUUIdField())
{
+            String primaryNodeTypeName = collectionNode.getPrimaryNodeType().getName();
             collectionNode.remove();
-            collectionNode = parentNode.addNode(jcrName);
+            collectionNode = parentNode.addNode(jcrName, primaryNodeTypeName);
         }
 
         Iterator collectionIterator = objects.getIterator();



Mime
View raw message