incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r325963 [2/3] - in /incubator/graffito/trunk/jcr-mapping/src: java/org/apache/portals/graffito/jcr/exception/ java/org/apache/portals/graffito/jcr/mapper/ java/org/apache/portals/graffito/jcr/mapper/impl/ java/org/apache/portals/graffito/jc...
Date Mon, 17 Oct 2005 19:08:06 GMT
Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java Mon Oct 17 12:07:21 2005
@@ -22,31 +22,44 @@
 import java.util.Vector;
 
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ManageableArrayList;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ManageableVector;
 
 /**
- *  
+ * Utility class used to instantiate {@link ManageableCollection} 
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  *
  */
 public class ManageableCollectionUtil
 {
-    public static ManageableCollection getManageableCollection(String manageableCollectionName) throws JcrMappingException
+	
+	/**
+	 * Instantiate a new {@link ManageableCollection}
+	 * @param manageableCollectionClassName The manageable collection class name
+	 * @return an emtpy created {@link ManageableCollection}
+	 */
+    public static ManageableCollection getManageableCollection(String manageableCollectionClassName)
     {
         try
         {
-            Class collectionClass = Class.forName(manageableCollectionName);
+            Class collectionClass = Class.forName(manageableCollectionClassName);
             return (ManageableCollection) collectionClass.newInstance();
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to create the manageable collection", e);
+            throw new PersistenceException("Impossible to create the manageable collection : " + manageableCollectionClassName, e);
         }
     }
 
-    public static ManageableCollection getManageableCollection(Class collectionClass) throws JcrMappingException
+	/**
+	 * Instantiate a new {@link ManageableCollection}
+	 * @param collectionClass the collection class name 
+	 * @return an emtpy created {@link ManageableCollection}
+	 */
+    
+    public static ManageableCollection getManageableCollection(Class collectionClass)
     {
         try
         {
@@ -69,7 +82,7 @@
             Object collection  = collectionClass.newInstance();
             if (! (collection instanceof ManageableCollection))
             {
-               throw new JcrMappingException("Unsupported collection type :" + collectionClass.getName());
+               throw new PersistenceException("Unsupported collection type :" + collectionClass.getName());
             }
             else
             {
@@ -78,11 +91,21 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to create the manageable collection", e);
+            throw new PersistenceException("Impossible to create the manageable collection", e);
         }
     }
 
-    public static ManageableCollection getManageableCollection(Object object) throws JcrMappingException
+    /**
+     * Convert a java Collection object into a {@link ManageableCollection}.
+     * Until now, only the following class are supported :
+     * Collection, List, ArrayList, Vector
+     * 
+     * If you need a Map, you have to write your own {@link ManageableCollection}.
+     * @param object the java collection or Map
+     * @return The converted {@link ManageableCollection}
+     *
+     */
+    public static ManageableCollection getManageableCollection(Object object)
     {
         try
         {
@@ -117,11 +140,11 @@
                 return manageableArrayList;
             }
 
-            throw new JcrMappingException("Unsupported collection type :" + object.getClass().getName());
+            throw new PersistenceException("Unsupported collection type :" + object.getClass().getName());
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to create the manageable collection", e);
+            throw new PersistenceException("Impossible to create the manageable collection", e);
         }
     }
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java Mon Oct 17 12:07:21 2005
@@ -19,20 +19,28 @@
 import java.util.Map;
 
 import org.apache.portals.graffito.jcr.mapper.Mapper;
+import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 
 /** 
- *
+ * Abstract class used for all CollectionConverter
+ * 
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * 
  */
-public abstract class AbstractCollectionConverterImpl
+public abstract class AbstractCollectionConverterImpl implements CollectionConverter
 {
     protected Map atomicTypeConverters;
 	protected ObjectConverter objectConverter;    
     protected Mapper mapper;
     
-    
+    /**
+     * Constructor
+     * 
+     * @param atomicTypeConverters The atomic type converter to used
+     * @param objectConverter The object converter to used
+     * @param mapper The mapper to used
+     */
     public AbstractCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
     {
     	this.atomicTypeConverters = atomicTypeConverters;

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java Mon Oct 17 12:07:21 2005
@@ -25,11 +25,10 @@
 import javax.jcr.Session;
 
 import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
@@ -37,8 +36,8 @@
 /** 
  * Default Collection Mapping/convertion implementation.
  * 
- * This collection mapping strategy maps a collection under an extra JCR node (specify by the jcrName).
- * It can be usefull when the node type "nt:unstructured" is used for the collection elements. By this way, it is possible 
+ * This collection mapping strategy maps a collection under an extra JCR node (specify by the jcrName in the CollectionDescriptor).
+ * It is usefull when the node type "nt:unstructured" is applied to the collection elements. By this way, it is possible 
  * to distinguish the collection elements from the other main object fields.
  * 
  * If the collection element class contains an id (see the FieldDescriptor definition), this id value is used to build the collection element node.
@@ -65,11 +64,17 @@
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * 
  */
-public class DefaultCollectionConverterImpl extends AbstractCollectionConverterImpl implements CollectionConverter
+public class DefaultCollectionConverterImpl extends AbstractCollectionConverterImpl 
 {
 
     private static final String COLLECTION_ELEMENT_NAME = "collection-element";
 
+    /**
+     * Constructor 
+     * @param atomicTypeConverters
+     * @param objectConverter
+     * @param mapper
+     */
     public DefaultCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
     {
         super(atomicTypeConverters, objectConverter, mapper);
@@ -79,8 +84,7 @@
      * 
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
      */
-    public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            ManageableCollection collection) throws JcrMappingException
+    public void insertCollection(Session session, Node parentNode,  CollectionDescriptor collectionDescriptor, ManageableCollection collection)  
     {
 
         try
@@ -95,7 +99,7 @@
 
             if (jcrName == null)
             {
-                throw new JcrMappingException("The JcrName attribute is not defined for the CollectionDescriptor : "
+                throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
                         + collectionDescriptor.getCollectionConverterClassName());
             }
 
@@ -129,7 +133,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
 
@@ -139,8 +143,7 @@
      * 
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#updateCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
      */
-    public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            ManageableCollection collection) throws JcrMappingException
+    public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,  ManageableCollection collection)
     {
         try
         {
@@ -149,7 +152,7 @@
 
             if (jcrName == null)
             {
-                throw new JcrMappingException("The JcrName attribute is not defined for the CollectionDescriptor : "
+                throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
                         + collectionDescriptor.getCollectionConverterClassName());
             }
 
@@ -230,7 +233,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
 
@@ -239,8 +242,7 @@
     /**
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#getCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, java.lang.Class)
      */
-    public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            Class collectionFieldClass) throws JcrMappingException
+    public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, Class collectionFieldClass)
     {
         try
         {
@@ -267,7 +269,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
     }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java Mon Oct 17 12:07:21 2005
@@ -23,7 +23,7 @@
 
 /** 
  *
- * {@link ManageableCollection} implementation for ArrayList
+ * {@link ManageableCollection} ArrayList implementation
  * 
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * 
@@ -31,17 +31,29 @@
 public class ManageableArrayList extends ArrayList implements ManageableCollection
 {
 
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#addObject(java.lang.Object)
+	 */
     public void addObject(Object object)
     {
         this.add(object);
      
     }
 
+    /**
+     * 
+     * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getIterator()
+     */
     public Iterator getIterator()
     {
         return this.iterator();
     }
 
+    /**
+     * 
+     * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getSize()
+     */
 	public int getSize()
 	{
 		

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java Mon Oct 17 12:07:21 2005
@@ -23,23 +23,35 @@
 
 /** 
  *
- * {@link ManageableCollection} implementation for ArrayList
+ * {@link ManageableCollection} Vector implementation 
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * 
  */
 public class ManageableVector extends Vector implements ManageableCollection
 {
 
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#addObject(java.lang.Object)
+	 */
     public void addObject(Object object)
     {
         this.add(object);
     }
 
+    /**
+     * 
+     * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getIterator()
+     */
     public Iterator getIterator()
     {
         return this.iterator();
     }
     
+    /**
+     * 
+     * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getSize()
+     */
 	public int getSize()
 	{
 		

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java Mon Oct 17 12:07:21 2005
@@ -24,26 +24,31 @@
 import javax.jcr.Session;
 import javax.jcr.Value;
 
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 
 /** 
- * Collection Mapping/convertion implementation for multi values properties
+ * Collection Mapping/convertion implementation used for multi values properties
  * 
  * This collection mapping strategy maps a collection into a JCR multi value property
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * 
  */
-public class MultiValueCollectionConverterImpl extends AbstractCollectionConverterImpl implements CollectionConverter
+public class MultiValueCollectionConverterImpl extends AbstractCollectionConverterImpl
 {
-    
+    /**
+     * Constructor 
+     * 
+     * @param atomicTypeConverters
+     * @param objectConverter
+     * @param mapper
+     */
     public MultiValueCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
     {
         super(atomicTypeConverters, objectConverter, mapper);
@@ -53,8 +58,7 @@
      * 
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
      */
-    public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            ManageableCollection collection) throws JcrMappingException
+    public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection) 
     {
 
         try
@@ -69,7 +73,7 @@
 
             if (jcrName == null)
             {
-                throw new JcrMappingException("The JcrName attribute is not defined for the CollectionDescriptor : "
+                throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
                         + collectionDescriptor.getCollectionConverterClassName());
             }
     
@@ -86,7 +90,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
 
@@ -96,8 +100,7 @@
      * 
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#updateCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
      */
-    public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            ManageableCollection collection) throws JcrMappingException
+    public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
     {
         try
         {
@@ -114,7 +117,7 @@
 
             if (jcrName == null)
             {
-                throw new JcrMappingException("The JcrName attribute is not defined for the CollectionDescriptor : "
+                throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
                         + collectionDescriptor.getCollectionConverterClassName());
             }
     
@@ -135,7 +138,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
 
@@ -144,8 +147,7 @@
     /**
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#getCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, java.lang.Class)
      */
-    public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            Class collectionFieldClass) throws JcrMappingException
+    public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, Class collectionFieldClass) 
     {
         try
         {
@@ -170,7 +172,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
     }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java Mon Oct 17 12:07:21 2005
@@ -27,11 +27,10 @@
 import javax.jcr.query.QueryResult;
 
 import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
@@ -64,11 +63,18 @@
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * 
  */
-public class NTCollectionConverterImpl extends AbstractCollectionConverterImpl implements CollectionConverter
+public class NTCollectionConverterImpl extends AbstractCollectionConverterImpl
 {
 
     private static final String COLLECTION_ELEMENT_NAME = "collection-element";
 
+    /**
+     * Constructor
+     * 
+     * @param atomicTypeConverters
+     * @param objectConverter
+     * @param mapper
+     */
     public NTCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
     {
         super(atomicTypeConverters, objectConverter, mapper);
@@ -78,8 +84,7 @@
      * 
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
      */
-    public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            ManageableCollection collection) throws JcrMappingException
+    public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
     {
 
         try
@@ -119,7 +124,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
 
@@ -129,7 +134,7 @@
      * 
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#updateCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
      */
-    public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection) throws JcrMappingException
+    public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
     {
         try
         {
@@ -204,7 +209,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
 
@@ -213,8 +218,7 @@
     /**
      * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#getCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, java.lang.Class)
      */
-    public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
-            Class collectionFieldClass) throws JcrMappingException
+    public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, Class collectionFieldClass)
     {
         try
         {
@@ -236,7 +240,7 @@
         }
         catch (Exception e)
         {
-            throw new JcrMappingException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
+            throw new PersistenceException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
                     + "for " + collectionDescriptor.getElementClassName(), e);
         }
     }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java Mon Oct 17 12:07:21 2005
@@ -27,7 +27,7 @@
 
 
 /**
- * ObjectIterator is a wrapper class for NodeIterator
+ * ObjectIterator is a wrapper class for JCR NodeIterator
  * 
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  *
@@ -44,20 +44,35 @@
 	private ObjectConverter objectConverter;
 
 	
-	
-	public ObjectIterator(NodeIterator iterator, Class class1, ObjectConverter converter, Session session)
+	/**
+	 * Constructor 
+	 * 
+	 * @param iterator JCR node iterator 
+	 * @param objectClass the object class used to instantiate the objects
+	 * @param converter The object converter
+	 * @param session the JCR session 
+	 */
+	public ObjectIterator(NodeIterator iterator, Class objectClass, ObjectConverter converter, Session session)
 	{
 		nodeIterator = iterator;
-		objectClass = class1;
+		this.objectClass = objectClass;
 		objectConverter = converter;
 		this.session = session;
 	}
 
+	/**
+	 * 
+	 * @see java.util.Iterator#hasNext()
+	 */
 	public boolean hasNext()
 	{
 		return nodeIterator.hasNext();
 	}
 
+	/**
+	 * 
+	 * @see java.util.Iterator#next()
+	 */
 	public Object next() 
 	{
 
@@ -73,6 +88,10 @@
 
 	}
 
+	/**
+	 * 
+	 * @see java.util.Iterator#remove()
+	 */
 	public void remove()
 	{
 		nodeIterator.remove();

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java Mon Oct 17 12:07:21 2005
@@ -29,33 +29,41 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
 import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
 
-/** Interface that specifies howto interact with a jcr repository (JCR broker).
+/** 
+ * 
+ * Default implementation for {@link org.apache.jackrabbit.core.state.PersistenceManager}
  * 
  * @author Sandro Boehme
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe</a>
  * 
- * @version $Id: Exp $
  */
 public class PersistenceManagerImpl implements PersistenceManager
 {
-	/** Logger.
+	/** 
+	 * Logger.
 	 */
 	private final static Log log = LogFactory.getLog(PersistenceManagerImpl.class);
 
 
-	/** Jackrabbit jcr session.
+	/** 
+	 * JCR session.
 	 */
 	protected Session session;
 
 
-	protected org.apache.portals.graffito.jcr.query.QueryManager queryManager;
+	/**
+	 * The Graffito query manager
+	 */
+	protected QueryManager queryManager;
 
 	 
 	/**
@@ -64,33 +72,27 @@
 	protected ObjectConverter objectConverter;
 
 	/**
-	 * Contructor for setting up a session to interact with a jcr repository. 
+	 * Contructor 
 	 * 
 	 * @param mapper the Mapper component
-	 * @param repository The JCR repository reference
-	 * @param session The JCR Session
+	 * @param atomicTypeConverters Atomic type converters to used
+	 * @param queryManager the query manager to used
+	 * @param session The JCR session 
 	 * 
-	 * @throws JcrMappingException when it is impossible to create the PersistenceManager
 	 */
-	public PersistenceManagerImpl(Mapper mapper, Map atomicTypeConverters, org.apache.portals.graffito.jcr.query.QueryManager queryManager, Session session) throws JcrMappingException
+	public PersistenceManagerImpl(Mapper mapper, Map atomicTypeConverters, QueryManager queryManager, Session session)
 	{
-		try
-		{
 			this.session = session;
 			this.objectConverter = new ObjectConverterImpl(mapper, atomicTypeConverters);
 			this.queryManager = queryManager;
-		}
-		catch (Exception e)
-		{
-			throw new JcrMappingException("Impossible to create the persistenceManager", e);
-		}
 	}
 
+  
 	/**
 	 * 
-	 * @see org.apache.portals.graffito.jcr.session.JcrSession#getObject(java.lang.Class, java.lang.String)
+	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(java.lang.Class, java.lang.String)
 	 */
-	public Object getObject(Class pojoClass, String path) throws JcrMappingException
+	public Object getObject(Class pojoClass, String path)
 	{
 		try
 		{
@@ -102,7 +104,7 @@
 		}
 		catch (Exception e)
 		{
-			throw new JcrMappingException("Impossible to get the object at " + path, e);
+			throw new PersistenceException("Impossible to get the object at " + path, e);
 		}
 
 		return objectConverter.getObject(session, pojoClass, path);
@@ -113,18 +115,18 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#insert(java.lang.String, java.lang.Object)
 	 */
-	public void insert(String path, Object object) throws JcrMappingException
+	public void insert(String path, Object object) 
 	{
 		try
 		{
 			if (session.itemExists(path))
 			{
-				throw new JcrMappingException("Path already exists : " + path);
+				throw new PersistenceException("Path already exists : " + path);
 			}
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to insert the object at " + path, e);
+			throw new PersistenceException("Impossible to insert the object at " + path, e);
 		}
 
 		objectConverter.insert(session, path, object);
@@ -135,18 +137,18 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#update(java.lang.String, java.lang.Object)
 	 */
-	public void update(String path, Object object) throws JcrMappingException
+	public void update(String path, Object object) 
 	{
 		try
 		{
 			if (!session.itemExists(path))
 			{
-				throw new JcrMappingException("Path is not existing : " + path);
+				throw new PersistenceException("Path is not existing : " + path);
 			}
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to update", e);
+			throw new PersistenceException("Impossible to update", e);
 		}
 
 		objectConverter.update(session, path, object);
@@ -156,7 +158,7 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#remove(java.lang.String)
 	 */
-	public void remove(String path) throws JcrMappingException
+	public void remove(String path) 
 	{
 
 		try
@@ -167,14 +169,16 @@
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to remove the object at " + path);
+			throw new PersistenceException("Impossible to remove the object at " + path);
 		}
 	}
 	
-	
-
 
-	public void remove(Query query) throws JcrMappingException
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#remove(org.apache.portals.graffito.jcr.query.Query)
+	 */
+	public void remove(Query query)
 	{
 		try
 		{
@@ -196,24 +200,25 @@
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to delte the object collection", e);
+			throw new PersistenceException("Impossible to delte the object collection", e);
 		}
 		
 	}
 
 	/**
 	 * 
-	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#itemExists(java.lang.String)
+	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#objectExists(java.lang.String)
 	 */
-	public boolean itemExists(String path) throws JcrMappingException
+	public boolean objectExists(String path)
 	{
 		try
 		{
+			//TODO : Check also if it is an object 
 			return session.itemExists(path);
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to check if the object exist", e);
+			throw new PersistenceException("Impossible to check if the object exist", e);
 		}
 	}
 
@@ -221,7 +226,7 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(org.apache.portals.graffito.jcr.query.Query)
 	 */
-	public Object getObject(Query query) throws JcrMappingException
+	public Object getObject(Query query) 
 	{
 		
 		try
@@ -236,7 +241,7 @@
 
             if (nodeIterator.getSize() > 1)
             {
-            	throw new JcrMappingException("Impossible to get the object - the query returns more than one object");
+            	throw new PersistenceException("Impossible to get the object - the query returns more than one object");
             }
             
 			Object object = null; 
@@ -250,7 +255,7 @@
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to get the object collection", e);
+			throw new PersistenceException("Impossible to get the object collection", e);
 		}
 
 	}
@@ -259,7 +264,7 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObjects(org.apache.portals.graffito.jcr.query.Query)
 	 */
-	public Collection getObjects(Query query) throws JcrMappingException
+	public Collection getObjects(Query query) 
 	{
 		try
 		{
@@ -283,7 +288,7 @@
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to get the object collection", e);
+			throw new PersistenceException("Impossible to get the object collection", e);
 		}
 	}
 
@@ -291,7 +296,7 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObjectIterator(org.apache.portals.graffito.jcr.query.Query)
 	 */
-	public Iterator getObjectIterator(Query query) throws JcrMappingException
+	public Iterator getObjectIterator(Query query) 
 	{
 		try
 		{
@@ -307,7 +312,7 @@
 		}
 		catch (RepositoryException e)
 		{
-			throw new JcrMappingException("Impossible to get the object collection", e);
+			throw new PersistenceException("Impossible to get the object collection", e);
 		}
 	}	
 	
@@ -315,7 +320,7 @@
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#logout()
 	 */
-	public void logout() throws JcrMappingException
+	public void logout()
 	{
 		try
 		{
@@ -324,16 +329,16 @@
 		}
 		catch (Exception e)
 		{
-			throw new JcrMappingException("Impossible to logout", e);
+			throw new PersistenceException("Impossible to logout", e);
 		}
 	}
 	
-	public Session getSession()
-	{
-		return this.session;
-	}
 
-	public void save() throws JcrMappingException
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#save()
+	 */
+	public void save()
 	{
 		try
 		{
@@ -341,10 +346,16 @@
 		}
 		catch(Exception e)
 		{
-			throw new JcrMappingException("Impossible to save", e);
+			throw new PersistenceException("Impossible to save", e);
 		}
 	}
 	
-	
+	/**
+	 * @return The JCR Session
+	 */
+	public Session getSession()
+	{
+		return this.session;
+	}	
 
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java Mon Oct 17 12:07:21 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2004 The Apache Software Foundation.
+ * Copyright 2000-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@
 import javax.jcr.Node;
 import javax.jcr.Session;
 
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 
 
 /**
- * Convert any kind of bean into JCR nodes & properties
+ * Convert any kind of beans into JCR nodes & properties
  * 
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
  * @version $Id: Exp $
@@ -35,9 +35,10 @@
 	 * @param session the JCR session 
 	 * @param path the JCR path 
 	 * @param object the object to insert
-	 * @throws JcrMappingException when it is not possible to insert the object
+	 * @throws PersistenceException when it is not possible to insert the object
+	 * 
 	 */
-    public void insert(Session session, String path, Object object) throws JcrMappingException;
+    public void insert(Session session, String path, Object object) throws PersistenceException;
     
 	/**
 	 * Update the object 
@@ -45,9 +46,9 @@
 	 * @param session the JCR session 
 	 * @param path the JCR path 
 	 * @param object the object to update
-	 * @throws JcrMappingException when it is not possible to update the object
+	 * @throws PersistenceException when it is not possible to update the object
 	 */    
-    public void update(Session session, String path, Object object) throws JcrMappingException;
+    public void update(Session session, String path, Object object) throws PersistenceException;
     
     /**
      * Retrieve an object from the JCR repo
@@ -55,10 +56,11 @@
      * @param session The JCR session 
      * @param clazz The class assigned to the object to retrieve
      * @param path the JCR path
-     * @return The object found
-     * @throws JcrMappingException
+     * @return The object found or null
+     * 
+     * @throws PersistenceException when it is not possible to retrieve the object
      */
-    public Object getObject(Session session, Class clazz, String path) throws JcrMappingException;
+    public Object getObject(Session session, Class clazz, String path) throws PersistenceException;
     
     
 	/**
@@ -68,9 +70,9 @@
 	 * @param parentNode The parent node used to store the new JCR element (object) 
 	 * @param nodeName The node name used to store the object
 	 * @param object the object to insert
-	 * @throws JcrMappingException when it is not possible to insert the object
+	 * @throws PersistenceException when it is not possible to insert the object
 	 */
-    public void insert(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException;
+    public void insert(Session session, Node parentNode, String nodeName, Object object) throws PersistenceException;
     
 	/**
 	 * Update the object 
@@ -79,9 +81,9 @@
 	 * @param parentNode The parent node used to store the new JCR element (object) 
 	 * @param nodeName The node name used to store the object
 	 * @param object the object to update
-	 * @throws JcrMappingException when it is not possible to update the object
+	 * @throws PersistenceException when it is not possible to update the object
 	 */    
-    public void update(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException;
+    public void update(Session session, Node parentNode, String nodeName, Object object) throws PersistenceException;
     
    
 

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java Mon Oct 17 12:07:21 2005
@@ -25,11 +25,15 @@
 import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.VersionException;
 
 import org.apache.commons.beanutils.ConstructorUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
@@ -51,430 +55,396 @@
  */
 public class ObjectConverterImpl implements ObjectConverter
 {
-    private Mapper mapper;
-    private Map atomicTypeConverters;
+	private Mapper mapper;
 
-    public ObjectConverterImpl(Mapper mapper, Map atomicTypeConverters)
-    {
-        this.mapper = mapper;
-        this.atomicTypeConverters = atomicTypeConverters;
-    }
+	private Map atomicTypeConverters;
 
-    /**
+	/**
+	 * Constructor
+	 * 
+	 * @param mapper The mapper to used
+	 * @param atomicTypeConverters The atomic type converters to used
+	 * 
+	 */
+	public ObjectConverterImpl(Mapper mapper, Map atomicTypeConverters)
+	{
+		this.mapper = mapper;
+		this.atomicTypeConverters = atomicTypeConverters;
+	}
+
+	/**
 	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#insert(javax.jcr.Session, java.lang.String, java.lang.Object)
 	 */
-    public void insert(Session session, String path, Object object) throws JcrMappingException
-    {
-        try
-        {
-            String parentPath = RepositoryUtil.getParentPath(path);
-            String nodeName = RepositoryUtil.getNodeName(path);
-            Node parentNode = (Node) session.getItem(parentPath);
-            this.insert(session, parentNode, nodeName, object);            
-            
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the object at " + path, e);
-        }
-
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#insert(javax.jcr.Session, javax.jcr.Node, java.lang.String, java.lang.Object)
-     */
-    public void insert(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException
-    {
-        try
-        {
-            ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
-            if (classDescriptor == null) 
-            {
-                throw new JcrMappingException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing" );
-            }
-            
-            String jcrNodeType = classDescriptor.getJcrNodeType();
-            if (jcrNodeType == null || jcrNodeType.equals(""))
-            {
-                throw new JcrMappingException("Undefined node type for  " + parentNode);
-            }
-
-            Node objectNode = null;
-            objectNode = parentNode.addNode(nodeName, jcrNodeType);
-
-            storeSimpleFields(object, classDescriptor, objectNode);
-            insertBeanFields(session, object, classDescriptor, objectNode);            
-            insertCollectionFields(session, object, classDescriptor, objectNode);
-            
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to add the node : " + parentNode, e);
-        }
-
-    }
-    
-    /**
+	public void insert(Session session, String path, Object object)
+	{
+		try
+		{
+			String parentPath = RepositoryUtil.getParentPath(path);
+			String nodeName = RepositoryUtil.getNodeName(path);
+			Node parentNode = (Node) session.getItem(parentPath);
+			this.insert(session, parentNode, nodeName, object);
+
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to insert the object at " + path, e);
+		}
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#insert(javax.jcr.Session, javax.jcr.Node, java.lang.String, java.lang.Object)
+	 */
+	public void insert(Session session, Node parentNode, String nodeName, Object object)
+	{
+		try
+		{
+			ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
+			if (classDescriptor == null)
+			{
+				throw new PersistenceException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
+			}
+
+			String jcrNodeType = classDescriptor.getJcrNodeType();
+			if (jcrNodeType == null || jcrNodeType.equals(""))
+			{
+				throw new PersistenceException("Undefined node type for  " + parentNode);
+			}
+
+			Node objectNode = null;
+			objectNode = parentNode.addNode(nodeName, jcrNodeType);
+
+			storeSimpleFields(object, classDescriptor, objectNode);
+			insertBeanFields(session, object, classDescriptor, objectNode);
+			insertCollectionFields(session, object, classDescriptor, objectNode);
+
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to insert the object at " + parentNode, e);
+		}
+
+	}
+
+	/**
 	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#update(javax.jcr.Session, java.lang.String, java.lang.Object)
 	 */
-    public void update(Session session, String path, Object object) throws JcrMappingException
-    {
-        try
-        {
-            String parentPath = RepositoryUtil.getParentPath(path);
-            String nodeName = RepositoryUtil.getNodeName(path);
-            Node parentNode = (Node) session.getItem(parentPath);
-            this.update(session, parentNode, nodeName, object);
-            
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the object at " + path, e);
-        }
-    }
-    
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#update(javax.jcr.Session, javax.jcr.Node, java.lang.String, java.lang.Object)
-     */
-    public void update(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException
-    {
-        try
-        {
-            ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
-            if (classDescriptor == null) 
-            {
-                throw new JcrMappingException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing" );
-            }
-            
-            String jcrNodeType = classDescriptor.getJcrNodeType();
-            if (jcrNodeType == null || jcrNodeType.equals(""))
-            {
-                throw new JcrMappingException("Undefined node type for  " + parentNode);
-            }
-
-            Node objectNode = null;
-            objectNode = parentNode.getNode(nodeName);
-
-            storeSimpleFields(object, classDescriptor, objectNode);
-            updateBeanFields(session, object, classDescriptor, objectNode);            
-            updateCollectionFields(session, object, classDescriptor, objectNode);
-            
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to add the node : " + parentNode, e);
-        }
+	public void update(Session session, String path, Object object) 
+	{
+		try
+		{
+			String parentPath = RepositoryUtil.getParentPath(path);
+			String nodeName = RepositoryUtil.getNodeName(path);
+			Node parentNode = (Node) session.getItem(parentPath);
+			this.update(session, parentNode, nodeName, object);
+
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to update the object at " + path, e);
+		}
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#update(javax.jcr.Session, javax.jcr.Node, java.lang.String, java.lang.Object)
+	 */
+	public void update(Session session, Node parentNode, String nodeName, Object object) 
+	{
+		try
+		{
+			ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
+			if (classDescriptor == null)
+			{
+				throw new PersistenceException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
+			}
+
+			String jcrNodeType = classDescriptor.getJcrNodeType();
+			if (jcrNodeType == null || jcrNodeType.equals(""))
+			{
+				throw new PersistenceException("Undefined node type for  " + parentNode);
+			}
+
+			Node objectNode = null;
+			objectNode = parentNode.getNode(nodeName);
+
+			storeSimpleFields(object, classDescriptor, objectNode);
+			updateBeanFields(session, object, classDescriptor, objectNode);
+			updateCollectionFields(session, object, classDescriptor, objectNode);
+
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to update the node : " + parentNode, e);
+		}
 
-    }    
-    
+	}
 
-    /**
+	/**
 	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#getObject(javax.jcr.Session, java.lang.Class, java.lang.String)
 	 */
-    public Object getObject(Session session, Class clazz, String path) throws JcrMappingException
-    {
+	public Object getObject(Session session, Class clazz, String path)
+	{
+		try
+    	{
+
+			if (!session.itemExists(path))
+			{
+				return null;
+			}
+
+			ClassDescriptor classDescriptor = mapper.getClassDescriptor(clazz);
+			if (classDescriptor == null)
+			{
+				throw new PersistenceException("Class of type: " + clazz.getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
+			}
+
+			Node node = (Node) session.getItem(path);
+			Object object = clazz.newInstance();
+
+			retrieveSimpleFields(classDescriptor, node, object);
+			retrieveBeanFields(session, path, classDescriptor, object);
+			retrieveCollectionFields(session, classDescriptor, node, object);
+
+			return object;
+
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to get the object at " + path, e);
+		}
+	}
+
+	/**
+	 * Retrieve simple fields (atomic fields)
+	 */
+	private void retrieveSimpleFields(ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, ValueFormatException, IllegalAccessException,
+			InvocationTargetException, NoSuchMethodException
+	{
+		Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
+
+		while (fieldDescriptorIterator.hasNext())
+		{
+			FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
+			String fieldName = fieldDescriptor.getFieldName();
+			String propertyName = fieldDescriptor.getJcrName();
+
+			AtomicTypeConverter converter = (AtomicTypeConverter) atomicTypeConverters.get(PropertyUtils.getPropertyType(object, fieldName));
+			if (node.hasProperty(propertyName))
+			{
+				Object fieldValue = converter.getObject(node.getProperty(propertyName).getValue());
+				PropertyUtils.setNestedProperty(object, fieldName, fieldValue);
+			}
+		}
+	}
 
-        try
-        {
-            
-            if (! session.itemExists(path))
-            {
-                return null;
-            }
-            
-            ClassDescriptor classDescriptor = mapper.getClassDescriptor(clazz);
-            if (classDescriptor == null) 
-            {
-                throw new JcrMappingException("Class of type: " + clazz.getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing" );
-            }
-            
-
-            Node node = (Node) session.getItem(path);
-            Object object = clazz.newInstance();
-
-            retrieveSimpleFields(classDescriptor, node, object);
-            retrieveBeanFields(session, path, classDescriptor, object);
-            retrieveCollectionFields(session, classDescriptor, node, object);
-            
-            return object;
-
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to get the object at " + path, e);
-        }
-    }
-
-    /**
-     * @param classDescriptor
-     * @param node
-     * @param object
-     * @throws PathNotFoundException
-     * @throws RepositoryException
-     * @throws ValueFormatException
-     * @throws JcrMappingException
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     * @throws NoSuchMethodException
-     */
-    private void retrieveSimpleFields(ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, ValueFormatException, JcrMappingException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
-    {
-        Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
-        
-        while (fieldDescriptorIterator.hasNext())
-        {
-            FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
-            String fieldName = fieldDescriptor.getFieldName();
-            String propertyName = fieldDescriptor.getJcrName();
-            
-            AtomicTypeConverter converter = (AtomicTypeConverter) atomicTypeConverters.get(PropertyUtils.getPropertyType(object, fieldName));
-            if (node.hasProperty(propertyName))
-            {
-                Object fieldValue = converter.getObject(node.getProperty(propertyName).getValue());            
-                PropertyUtils.setNestedProperty(object, fieldName, fieldValue);
-            }
-        }        
-    }    
-    
-    
-    /**
-     * @param session
-     * @param path
-     * @param classDescriptor
-     * @param object
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     * @throws NoSuchMethodException
-     * @throws JcrMappingException
-     */
-    private void retrieveBeanFields(Session session, String path, ClassDescriptor classDescriptor, Object object) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, JcrMappingException
-    {
-        Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
-        while (beanDescriptorIterator.hasNext())
-        {
-            BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
-            String beanName = beanDescriptor.getFieldName();
-            Class beanClass = PropertyUtils.getPropertyDescriptor(object, beanName).getPropertyType();
-            Object bean = this.getObject(session, beanClass, path + "/" + beanDescriptor.getJcrName());
-            PropertyUtils.setNestedProperty(object, beanName, bean);
-        }
-    }
-
-    
-    /**
-     * @param session
-     * @param classDescriptor
-     * @param node
-     * @param object
-     * @throws PathNotFoundException
-     * @throws RepositoryException
-     * @throws JcrMappingException
-     * @throws ClassNotFoundException
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     * @throws NoSuchMethodException
-     */
-    private void retrieveCollectionFields(Session session, ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, JcrMappingException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
-    {
-        Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
-        while(collectionDescriptorIterator.hasNext())
-        {
-            CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
-            CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
-            Class collectionFieldClass = PropertyUtils.getPropertyDescriptor(object, collectionDescriptor.getFieldName()).getPropertyType();
-            ManageableCollection collection = collectionConverter.getCollection(session, node, collectionDescriptor, collectionFieldClass );
-            PropertyUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), collection);
-        }
-    }
-
-    
-    private void insertBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
-            while (beanDescriptorIterator.hasNext())
-            {
-                BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
-                String jcrName = beanDescriptor.getJcrName();
-                Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
-                if (bean != null)
-                {
-                    this.insert(session, objectNode, jcrName, bean);
-                }
-
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-        
-    }
-    
-    private void updateBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
-            while (beanDescriptorIterator.hasNext())
-            {
-                BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
-                String jcrName = beanDescriptor.getJcrName();
-                Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
-                
-                // if the bean is null, remove existing node
-                if ((bean == null))
-                {
-                   if (objectNode.hasNode(jcrName))
-                   {
-                       objectNode.getNode(jcrName).remove();
-                   }
-                }
-                else
-                {
-                   this.update(session, objectNode, jcrName, bean);
-                }
-
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-        
-    }    
-    
-    private void insertCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
-            while (collectionDescriptorIterator.hasNext())
-            {
-                CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
-                CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
-                Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
-                ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
-                collectionConverter.insertCollection(session, objectNode, collectionDescriptor, manageableCollection);
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the collection fields", e);
-        }
-        
-    }    
-    
-    private void updateCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
-            while (collectionDescriptorIterator.hasNext())
-            {
-                CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
-                CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
-                Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
-                ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
-                collectionConverter.updateCollection(session, objectNode, collectionDescriptor, manageableCollection);
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-        
-    }      
-
-    private void storeSimpleFields(Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
-            while (fieldDescriptorIterator.hasNext())
-            {
-                FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
-                String fieldName = fieldDescriptor.getFieldName();
-                String jcrName = fieldDescriptor.getJcrName();                
-                
-                // Check if the node property is "autocreated"
-                boolean autoCreated = false;
-                
-                if (objectNode.hasProperty(jcrName))
-                {
-                      autoCreated = objectNode.getProperty(jcrName).getDefinition().isAutoCreated();
-                }
-                
-               // All auto created JCR properties are ignored
-                if (! autoCreated)
-                {
-                   Object fieldValue = PropertyUtils.getNestedProperty(object, fieldName);                
-                                   
-                   AtomicTypeConverter converter = (AtomicTypeConverter) atomicTypeConverters.get(PropertyUtils.getPropertyType(object, fieldName));
-                   Value value = converter.getValue(fieldValue);
-                   // Check if mandatory property are not null
-                   this.checkMandatoryProperty(objectNode, fieldDescriptor, value);
-                   
-                   objectNode.setProperty(jcrName, value);
-                }
-                
-                                               
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-    }
-    
-    private CollectionConverter getCollectionConverter(CollectionDescriptor collectionDescriptor) throws JcrMappingException
-    {
-        
-         try
-        {
-            String className = collectionDescriptor.getCollectionConverterClassName();
-             if (className == null)
-             {
-                 return new DefaultCollectionConverterImpl(this.atomicTypeConverters, this, this.mapper);
-             }
-             else
-             {
-                 Class converterClass = Class.forName(className);
-                 Object[] param  = {this.atomicTypeConverters, this, this.mapper};
-                 return (CollectionConverter) ConstructorUtils.invokeConstructor(converterClass, param);
-             }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to get the collection descriptor for " + collectionDescriptor.getCollectionConverterClassName(), e); 
-        }
-       
-    }
-    
-    private void checkMandatoryProperty(Node objectNode, FieldDescriptor fieldDescriptor, Value value ) throws JcrMappingException
-    {
-        try
-        {
-            PropertyDefinition[] propertyDefinitions = objectNode.getPrimaryNodeType().getDeclaredPropertyDefinitions();
-            for (int i = 0; i < propertyDefinitions.length; i++)
-            {
-                PropertyDefinition definition = propertyDefinitions[i];
-                if (definition.getName().equals(fieldDescriptor.getJcrName()) && definition.isMandatory()
-                        && definition.isAutoCreated() == false && value == null)
-                {
-                    throw new JcrMappingException("Class of type:" + fieldDescriptor.getClassDescriptor().getClassName()
-                            + " has property: " + fieldDescriptor.getFieldName() + " declared as JCR property: "
-                            + fieldDescriptor.getJcrName() + " This property is mandatory but property in bean has value null");
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to check mandatory property" , e);
-        }
-    }
+	/**
+	 * Retrieve bean fields
+	 */
+	private void retrieveBeanFields(Session session, String path, ClassDescriptor classDescriptor, Object object) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
+	{
+		Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
+		while (beanDescriptorIterator.hasNext())
+		{
+			BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
+			String beanName = beanDescriptor.getFieldName();
+			Class beanClass = PropertyUtils.getPropertyDescriptor(object, beanName).getPropertyType();
+			Object bean = this.getObject(session, beanClass, path + "/" + beanDescriptor.getJcrName());
+			PropertyUtils.setNestedProperty(object, beanName, bean);
+		}
+	}
+
+	/**
+	 * Retrieve Collection fields
+	 */
+	private void retrieveCollectionFields(Session session, ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, JcrMappingException,
+			ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException
+	{
+		Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
+		while (collectionDescriptorIterator.hasNext())
+		{
+			CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
+			CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
+			Class collectionFieldClass = PropertyUtils.getPropertyDescriptor(object, collectionDescriptor.getFieldName()).getPropertyType();
+			ManageableCollection collection = collectionConverter.getCollection(session, node, collectionDescriptor, collectionFieldClass);
+			PropertyUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), collection);
+		}
+	}
+
+	/**
+	 * Insert Bean fields
+	 */
+	private void insertBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) 
+	{
+		try
+		{
+			Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
+			while (beanDescriptorIterator.hasNext())
+			{
+				BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
+				String jcrName = beanDescriptor.getJcrName();
+				Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
+				if (bean != null)
+				{
+					this.insert(session, objectNode, jcrName, bean);
+				}
+
+			}
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to insert the bean fields", e);
+		}
+
+	}
+
+	/**
+	 * Update Bean fields
+	 */
+	private void updateBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) 
+	{
+		try
+		{
+			Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
+			while (beanDescriptorIterator.hasNext())
+			{
+				BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
+				String jcrName = beanDescriptor.getJcrName();
+				Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
+
+				// if the bean is null, remove existing node
+				if ((bean == null))
+				{
+					if (objectNode.hasNode(jcrName))
+					{
+						objectNode.getNode(jcrName).remove();
+					}
+				}
+				else
+				{
+					this.update(session, objectNode, jcrName, bean);
+				}
+
+			}
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to update the bean fields", e);
+		}
+
+	}
+
+	private void insertCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode)
+	{
+		try
+		{
+			Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
+			while (collectionDescriptorIterator.hasNext())
+			{
+				CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
+				CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
+				Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
+				ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
+				collectionConverter.insertCollection(session, objectNode, collectionDescriptor, manageableCollection);
+			}
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to insert the collection fields", e);
+		}
+
+	}
+
+	private void updateCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode)
+	{
+		try
+		{
+			Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
+			while (collectionDescriptorIterator.hasNext())
+			{
+				CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
+				CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
+				Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
+				ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
+				collectionConverter.updateCollection(session, objectNode, collectionDescriptor, manageableCollection);
+			}
+		}
+		catch (Exception e)
+		{
+			throw new PersistenceException("Impossible to store the bean fields", e);
+		}
+
+	}
+
+	private void storeSimpleFields(Object object, ClassDescriptor classDescriptor, Node objectNode) 
+	               throws PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException, 
+	                      RepositoryException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
+	{
+
+
+			Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
+			while (fieldDescriptorIterator.hasNext())
+			{
+				FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
+				String fieldName = fieldDescriptor.getFieldName();
+				String jcrName = fieldDescriptor.getJcrName();
+
+				// Check if the node property is "autocreated"
+				boolean autoCreated = false;
+
+				if (objectNode.hasProperty(jcrName))
+				{
+					autoCreated = objectNode.getProperty(jcrName).getDefinition().isAutoCreated();
+				}
+
+				// All auto created JCR properties are ignored
+				if (!autoCreated)
+				{
+					Object fieldValue = PropertyUtils.getNestedProperty(object, fieldName);
+
+					AtomicTypeConverter converter = (AtomicTypeConverter) atomicTypeConverters.get(PropertyUtils.getPropertyType(object, fieldName));
+					Value value = converter.getValue(fieldValue);
+					// Check if mandatory property are not null
+					this.checkMandatoryProperty(objectNode, fieldDescriptor, value);
+
+					objectNode.setProperty(jcrName, value);
+				}
+
+			}
+
+	}
+
+	private CollectionConverter getCollectionConverter(CollectionDescriptor collectionDescriptor) 
+	                            throws ClassNotFoundException, NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException
+	{
+
+		String className = collectionDescriptor.getCollectionConverterClassName();
+		if (className == null)
+		{
+			return new DefaultCollectionConverterImpl(this.atomicTypeConverters, this, this.mapper);
+		}
+		else
+		{
+			Class converterClass = Class.forName(className);
+			Object[] param =
+			{ this.atomicTypeConverters, this, this.mapper };
+			return (CollectionConverter) ConstructorUtils.invokeConstructor(converterClass, param);
+		}
+
+	}
+
+	private void checkMandatoryProperty(Node objectNode, FieldDescriptor fieldDescriptor, Value value) throws RepositoryException
+	{
+		PropertyDefinition[] propertyDefinitions = objectNode.getPrimaryNodeType().getDeclaredPropertyDefinitions();
+		for (int i = 0; i < propertyDefinitions.length; i++)
+		{
+			PropertyDefinition definition = propertyDefinitions[i];
+			if (definition.getName().equals(fieldDescriptor.getJcrName()) && definition.isMandatory() && definition.isAutoCreated() == false && value == null)
+			{
+				throw new PersistenceException("Class of type:" + fieldDescriptor.getClassDescriptor().getClassName() + " has property: " + fieldDescriptor.getFieldName()
+						+ " declared as JCR property: " + fieldDescriptor.getJcrName() + " This property is mandatory but property in bean has value null");
+			}
+		}
+	}
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java Mon Oct 17 12:07:21 2005
@@ -28,8 +28,7 @@
  */
 public interface Filter
 {
-    
-	public Class getFilterClass();
+
 	
     /**
      * Set the filter scope. The scope is an Node path specifying where to search in the content tree.
@@ -84,9 +83,7 @@
 	
 	public void addJCRExpression(String jcrExpression) throws IncorrectAtomicTypeException;
 	
+    public Class getFilterClass();	
 	
-	
-	
-
 
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java Mon Oct 17 12:07:21 2005
@@ -26,12 +26,28 @@
 public interface Query
 {
 		
-	
+	/**
+	 * Set the filter to use with this query 
+	 * @param filter The filter to use
+	 */
 	public void setFilter(Filter filter);
 	
+	/**
+	 * 
+	 * @return The filter used for this query
+	 */
 	public Filter getFilter();
 	
+	/**
+	 * Order the object found (ascending) 
+	 * @param fieldNameAttribute the name of the field used to sort the search result
+	 */
 	public void addOrderByAscending(String fieldNameAttribute);
+	
+	/**
+	 * Order the object found (descending) 
+	 * @param fieldNameAttribute the name of the field used to sort the search result
+	 */
 	
 	public void addOrderByDescending(String fieldNameAttribute);
 

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java?rev=325963&r1=325962&r2=325963&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java Mon Oct 17 12:07:21 2005
@@ -17,7 +17,7 @@
 
 package org.apache.portals.graffito.jcr.query;
 
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+
 
 /**
  * The query manager is used to instantiate query objects and execute query based on the object model. 
@@ -28,11 +28,26 @@
  */
 public interface QueryManager
 {
-	 public Filter createFilter(Class classQuery) throws JcrMappingException;
+	/**
+	 * Create a new empty filter
+	 * @param classQuery The class used to search
+	 * @return a new instantiated filter object
+	 */
+	 public Filter createFilter(Class classQuery);
 	 
-     public Query createQuery(Filter filter)  throws JcrMappingException;
+	 /**
+	  * Create a new empty query 
+	  * @param filter the filter used by the query
+	  * @return a new instantiated query object
+	  */
+     public Query createQuery(Filter filter); 
      
-     public String buildJCRExpression(Query query) throws JcrMappingException;
+     /**
+      * Build a JCR search expression from a Query
+      * @param query the query matching to the JCR search expression
+      * @return a JCR XPATH search expression 
+      */
+     public String buildJCRExpression(Query query); 
      
        
 }



Mime
View raw message