incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r465355 - in /incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr: mapper/impl/DigesterMapperImpl.java persistence/impl/PersistenceManagerImpl.java
Date Wed, 18 Oct 2006 19:59:21 GMT
Author: clombart
Date: Wed Oct 18 12:59:21 2006
New Revision: 465355

URL: http://svn.apache.org/viewvc?view=rev&rev=465355
Log:
Review methods in DigesterMapperImpl (see GRFT-109).
Return an exception instead of a null value.

Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java?view=diff&rev=465355&r1=465354&r2=465355
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
Wed Oct 18 12:59:21 2006
@@ -25,6 +25,7 @@
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.exception.IncorrectPersistentClassException;
 import org.apache.portals.graffito.jcr.exception.InitMapperException;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
@@ -270,14 +271,22 @@
     * @see org.apache.portals.graffito.jcr.mapper.Mapper#getClassDescriptorByClass(java.lang.Class)
     */
    public ClassDescriptor getClassDescriptorByClass(Class clazz) {
-       return mappingDescriptor.getClassDescriptorByName(clazz.getName());
+	   ClassDescriptor descriptor = mappingDescriptor.getClassDescriptorByName(clazz.getName());
+	   if (descriptor==null) {
+			throw new IncorrectPersistentClassException("Class of type: " + clazz.getName() + " has
no descriptor.");
+	   }
+       return descriptor ; 
    }
    
    /**
    * @see org.apache.portals.graffito.jcr.mapper.Mapper#getClassDescriptorByNodeType(String)
    */
   public ClassDescriptor getClassDescriptorByNodeType(String jcrNodeType) {
-      return mappingDescriptor.getClassDescriptorByNodeType(jcrNodeType);
+	  ClassDescriptor descriptor = mappingDescriptor.getClassDescriptorByNodeType(jcrNodeType);
+	   if (descriptor==null) {
+			throw new IncorrectPersistentClassException("Node type: " + jcrNodeType + " has no descriptor.");
+	   }
+      return descriptor ;      
   }
    
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java?view=diff&rev=465355&r1=465354&r2=465355
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
Wed Oct 18 12:59:21 2006
@@ -40,6 +40,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.portals.graffito.jcr.exception.IllegalUnlockException;
+import org.apache.portals.graffito.jcr.exception.IncorrectPersistentClassException;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
 import org.apache.portals.graffito.jcr.exception.LockedException;
 import org.apache.portals.graffito.jcr.exception.PersistenceException;
@@ -427,13 +428,17 @@
      * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#isPersistent(java.lang.Class)
      */
     public boolean isPersistent(final Class clazz) {
-        boolean isPersistent = false;
-        ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(clazz);
-        if (classDescriptor != null) {
-            isPersistent = true;
+        
+        try 
+        {
+    	    ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(clazz);
+    	    return true;
+        }
+        catch(IncorrectPersistentClassException e)
+        {
+        	return false;
         }
 
-        return isPersistent;
     }
 
     /**



Mime
View raw message