You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by cl...@apache.org on 2007/08/06 22:36:01 UTC

svn commit: r563260 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation: ./ manager/ mapper/

Author: clombart
Date: Mon Aug  6 13:36:00 2007
New Revision: 563260

URL: http://svn.apache.org/viewvc?view=rev&rev=563260
Log:
continue to work on the annotation support - Mainly : 
1/ Add Bean annotation. 
2/ Review other annotation in order to have the same name used in the xml mapping. 
3/ Drop AnnoterObjectContentManagerImpl. We can use the ObjectContentManagerImpl with the annotation mapper. 

Added:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Bean.java
Removed:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/manager/AnnotatedObjectContentManagerImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/mapper/AnnotationHelper.java
Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Collection.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Field.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Node.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/mapper/AnnotatedObjectMapper.java

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Bean.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Bean.java?view=auto&rev=563260
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Bean.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Bean.java Mon Aug  6 13:36:00 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import org.apache.jackrabbit.ocm.manager.beanconverter.impl.DefaultBeanConverterImpl;
+
+/**
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ * 
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Bean {
+
+	String jcrName() default "";
+    boolean proxy() default false;	 
+    Class converter() default DefaultBeanConverterImpl.class;    
+    boolean autoInsert() default true;
+    boolean autoRetrieve() default true;
+    boolean autoUpdate() default true;
+    
+    // The folling annotation props are used to create jcr node type. 
+    // There are not necessary for the mapping bean strategies. 
+    String jcrType() default "";    
+    boolean jcrAutoCreated() default false;
+    boolean jcrMandatory() default false;        
+    String jcrOnParentVersion() default "COPY";    
+    boolean jcrProtected() default false; 
+    boolean jcrSameNameSiblings() default false; 
+            
+	       
+
+
+}

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Collection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Collection.java?view=diff&rev=563260&r1=563259&r2=563260
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Collection.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Collection.java Mon Aug  6 13:36:00 2007
@@ -20,6 +20,7 @@
 import java.lang.annotation.RetentionPolicy;
 
 import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.DefaultCollectionConverterImpl;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
 
 /**
  * Allows the annotation of getting methods to show that they reflect a child node in JCR
@@ -30,8 +31,10 @@
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Collection {
 
-    String name() default "*";
+	Class converter() default DefaultCollectionConverterImpl.class;
 
+    String jcrName() default ""; 
+    
     boolean sameNameSiblings() default false;
 
     boolean autoCreate() default false;
@@ -44,13 +47,11 @@
 
     boolean autoInsert() default true;
 
-    boolean autoRetrieve() default false;
+    boolean autoRetrieve() default true;
 
     boolean autoUpdate() default true;
 
-    Class type();
-
-    Class converter() default DefaultCollectionConverterImpl.class;
+    Class type();    
     
     boolean proxy() default false;
     

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Field.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Field.java?view=diff&rev=563260&r1=563259&r2=563260
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Field.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Field.java Mon Aug  6 13:36:00 2007
@@ -27,23 +27,33 @@
  */
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Field {
+    
+    String jcrName() default "";    
 
     boolean id() default false;
-
-    String jcrName() default ""; 
     
-    boolean mandatory() default false;
-
     boolean path() default false;
-
-    String onParentVersion() default "COPY";
-
-    boolean autoCreated() default false;
-
-    boolean protect() default false;
-
-    boolean mutiple() default false;
-
-    Class requiredType() default String.class;
-
+    
+    boolean uuid() default false;
+    
+    // Use Object.class as default value 
+    // because it is not possible to have a default null value in annotation field
+    Class converter() default Object.class;
+    
+    String jcrDefaultValue() default "";
+    
+    String jcrValueConstraints() default ""; 
+    
+    String jcrType() default ""; 
+    
+    boolean jcrAutoCreated() default false;     
+    
+    boolean jcrMandatory() default false;    
+    
+    String jcrOnParentVersion() default "COPY";
+    
+    boolean jcrProtected() default false;
+    
+    boolean jcrMultiple () default false;
+    
 }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Node.java?view=diff&rev=563260&r1=563259&r2=563260
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Node.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/Node.java Mon Aug  6 13:36:00 2007
@@ -27,19 +27,17 @@
  */
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Node {
-
-    String requiredPrimaryTypes() default "{http://www.jcp.org/jcr/nt/1.0}base";
-
-    String declaringNodeType() default "";
-
-    String namespace() default "http://jackrabbit.apache.org/ocm";
-
-    String prefix() default "ocm";
-
-    boolean allowSameNameSiblings() default false;
-
-    String name() default "";
-
-    boolean mixin() default false;
-
+    
+	String jcrNodeType() default "nt:unstructured";
+	String jcrSuperTypes() default "";
+	String jcrMixinTypes() default "";
+    // Define the extend setting in the mapping descriptor - Provide less flexibility if we use the java instrospection	
+	String extend() default "";
+
+	// Define the abstract setting in the mapping descriptor - Provide less flexibility if we use the java instrospection
+	boolean isAbstract() default false; 
+	
+	// Discriminator is used when an object hierarchy tree is mapped into the same jcr node type
+	// TODO : try to drop it from the mapping strategy. it should be hidden in the persistence manager impl. 
+	boolean discriminator() default true;
 }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/mapper/AnnotatedObjectMapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/mapper/AnnotatedObjectMapper.java?view=diff&rev=563260&r1=563259&r2=563260
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/mapper/AnnotatedObjectMapper.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/annotation/src/main/java/org/apache/jackrabbit/ocm/annotation/mapper/AnnotatedObjectMapper.java Mon Aug  6 13:36:00 2007
@@ -20,7 +20,6 @@
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -29,25 +28,26 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
-import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
+import org.apache.jackrabbit.ocm.annotation.Bean;
 import org.apache.jackrabbit.ocm.annotation.Collection;
 import org.apache.jackrabbit.ocm.annotation.Field;
+import org.apache.jackrabbit.ocm.annotation.Node;
+import org.apache.jackrabbit.ocm.exception.IncorrectPersistentClassException;
 import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
 import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
 import org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor;
 import org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor;
 import org.apache.jackrabbit.ocm.nodemanagement.NodeTypeManager;
-import org.apache.jackrabbit.ocm.nodemanagement.impl.jackrabbit.NodeTypeManagerImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -78,15 +78,14 @@
 	private Map<String, ClassDescriptor> nodeTypeMap = new HashMap<String, ClassDescriptor>();
 
 	public AnnotatedObjectMapper(Session session,
-			List<String> annotatedClassNames) throws ClassNotFoundException {
+			List<String> annotatedClassNames, 
+			NodeTypeManager nodeTypeManager ) throws ClassNotFoundException {
 		this.annotatedClassNames = annotatedClassNames;
 		try {
 			List<ClassDescriptor> classDescriptorsRequiringRegistration = buildClassDescriptors(session);
 			registerNamespaces(session);
 			registerNodeTypes(session);
 
-			NodeTypeManager nodeTypeManager = new NodeTypeManagerImpl();
-
 			if (!classDescriptorsRequiringRegistration.isEmpty()) {
 				log.info("Registering "
 						+ classDescriptorsRequiringRegistration.size()
@@ -124,24 +123,6 @@
 			log.info("Successfully created Jackrabbit OCM namespace.");
 		}
 
-		for (ClassDescriptor descriptor : descriptorMap.values()) {
-			Class<?> clazz;
-			try {
-				clazz = Class.forName(descriptor.getClassName());
-				log.info("Registering Namespace "
-						+ AnnotationHelper.getJcrNode(clazz).namespace()
-						+ " with prefix "
-						+ AnnotationHelper.getJcrNode(clazz).prefix());
-				session.getWorkspace().getNamespaceRegistry()
-						.registerNamespace(
-								AnnotationHelper.getJcrNode(clazz).prefix(),
-								AnnotationHelper.getJcrNode(clazz).namespace());
-			} catch (NamespaceException e) {
-				log.info("Unable to register namespace, " + e.getMessage());
-			} catch (Exception e2) {
-				throw new RuntimeException(e2);
-			}
-		}
 
 	}
 
@@ -199,40 +180,37 @@
 		return classDescriptorsToRegister;
 	}
 
-	private ClassDescriptor buildClassDescriptor(Class clazz)
-			throws ClassNotFoundException {
+	private ClassDescriptor buildClassDescriptor(Class clazz) throws ClassNotFoundException {
+		Node annotationNode =  (Node) clazz.getAnnotation(Node.class);
 		ClassDescriptor descriptor = new ClassDescriptor();
 		descriptor.setClassName(clazz.getName());
-		descriptor.setJcrNodeType(AnnotationHelper.getJcrNodeType(clazz));
-		descriptor.setJcrSuperTypes("nt:base");
+		descriptor.setJcrNodeType(annotationNode.jcrNodeType());
+		descriptor.setJcrSuperTypes(annotationNode.jcrSuperTypes());		
+		descriptor.setJcrMixinTypes(annotationNode.jcrMixinTypes());
+		descriptor.setExtend(annotationNode.extend());		
+		descriptor.setAbstract(annotationNode.isAbstract());
 		descriptor.setInterface(clazz.isInterface());
-
-		// TODO add mixin support
-		// descriptor.setMixin(AnnotationHelper.getJcrNode(clazz).mixin());
-
+		
 		addFieldDescriptors(descriptor, clazz);
+		addBeanDescriptors(descriptor, clazz);
 		addCollectionDescriptors(descriptor, clazz);
 		return descriptor;
 	}
 
-	private void addCollectionDescriptors(ClassDescriptor descriptor,
-			Class clazz) {
+	private void addCollectionDescriptors(ClassDescriptor descriptor,Class clazz) {
 		BeanInfo beanInfo;
 		try {
 			beanInfo = Introspector.getBeanInfo(clazz);
 		} catch (IntrospectionException e) {
 			throw new RuntimeException(e);
 		}
-		PropertyDescriptor[] propertyDescriptors = beanInfo
-				.getPropertyDescriptors();
+		PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
 		for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
-			Collection jcrChildNode = propertyDescriptor.getReadMethod()
-					.getAnnotation(Collection.class);
+			Collection jcrChildNode = propertyDescriptor.getReadMethod().getAnnotation(Collection.class);
 			if (jcrChildNode != null) {
 				Class targetClass = jcrChildNode.type();
 				CollectionDescriptor collectionDescriptor = new CollectionDescriptor();
-				ClassDescriptor classDescriptor = descriptorMap
-						.get(targetClass);
+				ClassDescriptor classDescriptor = descriptorMap.get(targetClass);
 
 				if (classDescriptor == null)
 					throw new RuntimeException(
@@ -240,32 +218,32 @@
 									+ targetClass.getName()
 									+ " as a child node since it has not been registered, ordering perhaps?");
 
-				collectionDescriptor.setJcrName(AnnotationHelper
-						.getJcrNodeType(targetClass));
-				collectionDescriptor.setDefaultPrimaryType(AnnotationHelper
-						.getJcrNodeType(targetClass));
-				collectionDescriptor.setJcrSameNameSiblings(jcrChildNode
-						.sameNameSiblings());
-				collectionDescriptor.setJcrAutoCreated(jcrChildNode
-						.autoCreate());
+				if (jcrChildNode.jcrName() != null && ! jcrChildNode.jcrName().equals(""))
+				{
+				   collectionDescriptor.setJcrName(jcrChildNode.jcrName());
+				}
+				else
+				{
+				   collectionDescriptor.setJcrName(propertyDescriptor.getName());
+				}
+				
+				Node annotationNode = (Node) targetClass.getAnnotation(Node.class);
+				collectionDescriptor.setDefaultPrimaryType(annotationNode.jcrNodeType());
+				collectionDescriptor.setJcrSameNameSiblings(jcrChildNode.sameNameSiblings());
+				collectionDescriptor.setJcrAutoCreated(jcrChildNode.autoCreate());
 				collectionDescriptor.setJcrProtected(jcrChildNode.protect());
-				collectionDescriptor.setJcrOnParentVersion(jcrChildNode
-						.onParentVersion());
+				collectionDescriptor.setJcrOnParentVersion(jcrChildNode.onParentVersion());
 				collectionDescriptor.setJcrMandatory(jcrChildNode.mandatory());
 				collectionDescriptor.setAutoInsert(jcrChildNode.autoInsert());
-				collectionDescriptor.setAutoRetrieve(jcrChildNode
-						.autoRetrieve());
+				collectionDescriptor.setAutoRetrieve(jcrChildNode.autoRetrieve());
 				collectionDescriptor.setAutoUpdate(jcrChildNode.autoUpdate());
-				collectionDescriptor.setCollectionClassName(propertyDescriptor
-						.getReadMethod().getReturnType().getName());
+				collectionDescriptor.setCollectionClassName(propertyDescriptor.getReadMethod().getReturnType().getName());
 				collectionDescriptor.setElementClassName(targetClass.getName());
 				collectionDescriptor.setCollectionConverter(jcrChildNode.converter().getName());
 				collectionDescriptor.setFieldName(propertyDescriptor.getName());
 
-				collectionDescriptor.setJcrNodeType(AnnotationHelper
-						.getJcrNodeType(targetClass));
-				collectionDescriptor.setJcrSameNameSiblings(jcrChildNode
-						.sameNameSiblings());
+				collectionDescriptor.setJcrNodeType(annotationNode.jcrNodeType());
+				collectionDescriptor.setJcrSameNameSiblings(jcrChildNode.sameNameSiblings());
 				collectionDescriptor.setProxy(jcrChildNode.proxy());
 
 				descriptor.addCollectionDescriptor(collectionDescriptor);
@@ -274,6 +252,48 @@
 
 	}
 
+	
+	private void addBeanDescriptors(ClassDescriptor descriptor,Class clazz) {
+		BeanInfo beanInfo;
+		try {
+			beanInfo = Introspector.getBeanInfo(clazz);
+		} catch (IntrospectionException e) {
+			throw new RuntimeException(e);
+		}
+		PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+		for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+			Bean jcrChildNode = propertyDescriptor.getReadMethod().getAnnotation(Bean.class);
+			if (jcrChildNode != null) {
+				
+				BeanDescriptor beanDescriptor = new BeanDescriptor();
+				beanDescriptor.setFieldName(propertyDescriptor.getName());
+				if (jcrChildNode.jcrName() != null && ! jcrChildNode.jcrName().equals(""))
+				{
+				   beanDescriptor.setJcrName(jcrChildNode.jcrName());
+				}
+				else
+				{
+					beanDescriptor.setJcrName(propertyDescriptor.getName());
+				}
+				
+				beanDescriptor.setProxy(jcrChildNode.proxy());				
+				beanDescriptor.setConverter(jcrChildNode.converter().getName());
+				beanDescriptor.setAutoInsert(jcrChildNode.autoInsert());
+				beanDescriptor.setAutoRetrieve(jcrChildNode.autoRetrieve());
+				beanDescriptor.setAutoUpdate(jcrChildNode.autoUpdate());
+				beanDescriptor.setJcrNodeType(jcrChildNode.jcrType());
+				beanDescriptor.setJcrAutoCreated(jcrChildNode.jcrAutoCreated());
+				beanDescriptor.setJcrMandatory(jcrChildNode.jcrMandatory());
+				beanDescriptor.setJcrOnParentVersion(jcrChildNode.jcrOnParentVersion());
+				beanDescriptor.setJcrProtected(jcrChildNode.jcrProtected());			            
+				beanDescriptor.setJcrSameNameSiblings(jcrChildNode.jcrSameNameSiblings());				
+
+				descriptor.addBeanDescriptor(beanDescriptor);
+			}
+		}
+
+	}
+	
 	private void addFieldDescriptors(ClassDescriptor descriptor, Class clazz) {
 		BeanInfo beanInfo;
 		try {
@@ -286,12 +306,8 @@
 		for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
 			Field jcrProperty = propertyDescriptor.getReadMethod().getAnnotation(Field.class);
 			if (jcrProperty != null) {
-				FieldDescriptor fieldDescriptor = new FieldDescriptor();
-				PropertyUtils.getPropertyDescriptors(clazz);
+				FieldDescriptor fieldDescriptor = new FieldDescriptor();				
 				fieldDescriptor.setFieldName(propertyDescriptor.getName());
-				fieldDescriptor.setPath(jcrProperty.path());
-				fieldDescriptor.setId(jcrProperty.id());
-				fieldDescriptor.setFieldType(propertyDescriptor.getReadMethod().getReturnType().getName());
 				if ((jcrProperty.jcrName() != null) && (!jcrProperty.jcrName().equals("")))
 				{
 					fieldDescriptor.setJcrName(jcrProperty.jcrName());	
@@ -300,23 +316,50 @@
 				{
 					fieldDescriptor.setJcrName(propertyDescriptor.getName());	
 				}
+				fieldDescriptor.setId(jcrProperty.id());				
+				fieldDescriptor.setPath(jcrProperty.path());
+				fieldDescriptor.setUuid(jcrProperty.uuid());
+				
+				// It is not possible to set a null value into a annotation attribute.
+				// If the converter == Object.class, it shoudl be considered as null
+				if (! jcrProperty.converter().equals(Object.class))
+				{
+				    fieldDescriptor.setConverter(jcrProperty.converter().getName());
+				}
+				fieldDescriptor.setJcrDefaultValue(jcrProperty.jcrDefaultValue());			
+				fieldDescriptor.setJcrValueConstraints(jcrProperty.jcrDefaultValue());
+				fieldDescriptor.setJcrType(jcrProperty.jcrType());
+				
+				fieldDescriptor.setJcrAutoCreated(jcrProperty.jcrAutoCreated());
+				fieldDescriptor.setJcrMandatory(jcrProperty.jcrMandatory());
+				fieldDescriptor.setJcrOnParentVersion(jcrProperty.jcrOnParentVersion());
+				fieldDescriptor.setJcrProtected(jcrProperty.jcrProtected());
+				fieldDescriptor.setJcrMultiple(jcrProperty.jcrMultiple());
 				
-				fieldDescriptor.setJcrMandatory(jcrProperty.mandatory());
-				fieldDescriptor.setJcrAutoCreated(jcrProperty.autoCreated());
-				fieldDescriptor.setJcrMultiple(jcrProperty.mutiple());
 				//fieldDescriptor.setJcrType(value)
 				descriptor.addFieldDescriptor(fieldDescriptor);
 			}
 		}
 
-	}
+	}    
+    
 
-	public ClassDescriptor getClassDescriptorByClass(Class arg0) {
-		return descriptorMap.get(arg0);
+    	
+	public ClassDescriptor getClassDescriptorByClass(Class clazz) {
+		ClassDescriptor descriptor = (ClassDescriptor) descriptorMap.get(clazz);
+		 if (descriptor==null) {
+				throw new IncorrectPersistentClassException("Class of type: " + clazz.getName() + " has no descriptor.");
+		   }
+	       return descriptor ;
 	}
 
-	public ClassDescriptor getClassDescriptorByNodeType(String arg0) {
-		return nodeTypeMap.get(arg0);
+	public ClassDescriptor getClassDescriptorByNodeType(String jcrNodeType) {
+		ClassDescriptor descriptor =  nodeTypeMap.get(jcrNodeType);
+		 if (descriptor==null) {
+			 throw new IncorrectPersistentClassException("Node type: " + jcrNodeType + " has no descriptor.");
+		   }
+	       return descriptor ;
+		
 	}
 
 	public List<String> getAnnotatedClassNames() {