jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r636118 - in /jackrabbit/trunk/jackrabbit-ocm/src: main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ test/java/org/apache/jackrabbit/ocm/manager/basic/ test/java/org/apache/jackrabbit/ocm/manager/uuid/
Date Tue, 11 Mar 2008 21:47:04 GMT
Author: clombart
Date: Tue Mar 11 14:47:02 2008
New Revision: 636118

URL: http://svn.apache.org/viewvc?rev=636118&view=rev
Log:
Patch for issues JCR-1381 and JCR-1385 : refresh path and uuid field. 
Path has to be refreshed in the case of the SNS is used.

Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/AnnotationUuidTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/DigesterUuidTest.java

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java?rev=636118&r1=636117&r2=636118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
Tue Mar 11 14:47:02 2008
@@ -219,6 +219,7 @@
 		simpleFieldsHelp.storeSimpleFields(session, object, classDescriptor, objectNode);
 		insertBeanFields(session, object, classDescriptor, objectNode);
 		insertCollectionFields(session, object, classDescriptor, objectNode);
+		simpleFieldsHelp.refreshUuidPath(session, classDescriptor, objectNode, object);
 	}
 
 	/**
@@ -257,6 +258,7 @@
 			simpleFieldsHelp.storeSimpleFields(session, object, classDescriptor, objectNode);
 			updateBeanFields(session, object, classDescriptor, objectNode);
 			updateCollectionFields(session, object, classDescriptor, objectNode);
+			simpleFieldsHelp.refreshUuidPath(session, classDescriptor, objectNode, object);
 		} catch (PathNotFoundException pnfe) {
 			throw new ObjectContentManagerException("Impossible to update the object: " + nodeName
+ " at node : " + parentNode, pnfe);
 		} catch (RepositoryException re) {
@@ -396,8 +398,8 @@
 
             simpleFieldsHelp.retrieveSimpleFields(session, classDescriptor, node, object);
 			retrieveBeanFields(session, classDescriptor, node, path, object, false);
-			retrieveCollectionFields(session, classDescriptor, node, object, false);
-
+			retrieveCollectionFields(session, classDescriptor, node, object, false);			
+			
 			return object;
 		} catch (PathNotFoundException pnfe) {
 			// HINT should never get here

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java?rev=636118&r1=636117&r2=636118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
Tue Mar 11 14:47:02 2008
@@ -130,6 +130,37 @@
 		return initializedBean;
 	}
 
+	public Object refreshUuidPath(Session session, ClassDescriptor classDescriptor, Node node,
Object object)
+	{
+		Object initializedBean = object;
+		try {
+			if (initializedBean == null)
+			{
+				return null;
+			}
+			
+			FieldDescriptor pathField = classDescriptor.getPathFieldDescriptor();
+			if (pathField != null)
+			{
+			    ReflectionUtils.setNestedProperty(initializedBean, pathField.getFieldName(), node.getPath());
+			}
+			
+			FieldDescriptor uuidField = classDescriptor.getUuidFieldDescriptor();
+			if (uuidField != null)
+			{
+				ReflectionUtils.setNestedProperty(initializedBean, uuidField.getFieldName(), node.getUUID());
+			}
+			
+		} catch (ValueFormatException vfe) {
+			throw new ObjectContentManagerException(
+					"Cannot retrieve properties of object " + object + " from node " + node, vfe);
+		} catch (RepositoryException re) {
+			throw new org.apache.jackrabbit.ocm.exception.RepositoryException( "Cannot retrieve properties
of object " + object
+							+ " from node " + node, re);
+		}
+
+		return initializedBean;
+	}
 
 	private Object retrieveSimpleField(ClassDescriptor classDescriptor, Node node, Object initializedBean,
FieldDescriptor fieldDescriptor, String fieldName, String propertyName) throws RepositoryException,
ValueFormatException, PathNotFoundException {
 

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java?rev=636118&r1=636117&r2=636118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java
Tue Mar 11 14:47:02 2008
@@ -197,6 +197,14 @@
 					 a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
 				}
 				ocm.insert(a);
+				if (i==1)
+				{
+				    assertTrue("Invalid Path" , a.getPath().equals("/test") );
+				}
+				else
+				{
+					assertTrue("Invalid Path" , a.getPath().equals("/test" + "[" + i + "]") );
+				}
 				
 				
 			}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java?rev=636118&r1=636117&r2=636118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java
Tue Mar 11 14:47:02 2008
@@ -196,6 +196,14 @@
 					 a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
 				}
 				ocm.insert(a);
+				if (i==1)
+				{
+				    assertTrue("Invalid Path" , a.getPath().equals("/test") );
+				}
+				else
+				{
+					assertTrue("Invalid Path" , a.getPath().equals("/test" + "[" + i + "]") );
+				}
 				
 				
 			}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/AnnotationUuidTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/AnnotationUuidTest.java?rev=636118&r1=636117&r2=636118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/AnnotationUuidTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/AnnotationUuidTest.java
Tue Mar 11 14:47:02 2008
@@ -78,14 +78,16 @@
             a.setPath("/test");
             a.setStringData("testdata");
             ocm.insert(a);
+            String uuidA = a.getUuid();
+            assertNotNull("uuid is null", uuidA);
             ocm.save();
-
+            
             // --------------------------------------------------------------------------------
             // Get the object
             // --------------------------------------------------------------------------------
             a = (A) ocm.getObject( "/test");
             assertNotNull("a is null", a);
-            String uuidA = a.getUuid();
+            uuidA = a.getUuid();
             assertNotNull("uuid is null", uuidA);
             System.out.println("UUID : " + uuidA);
 

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/DigesterUuidTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/DigesterUuidTest.java?rev=636118&r1=636117&r2=636118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/DigesterUuidTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/uuid/DigesterUuidTest.java
Tue Mar 11 14:47:02 2008
@@ -78,6 +78,8 @@
             a.setPath("/test");
             a.setStringData("testdata");
             ocm.insert(a);
+            String uuidA = a.getUuid();
+            assertNotNull("uuid is null", uuidA);
             ocm.save();
 
             // --------------------------------------------------------------------------------
@@ -85,7 +87,7 @@
             // --------------------------------------------------------------------------------
             a = (A) ocm.getObject( "/test");
             assertNotNull("a is null", a);
-            String uuidA = a.getUuid();
+            uuidA = a.getUuid();
             assertNotNull("uuid is null", uuidA);
             System.out.println("UUID : " + uuidA);
 



Mime
View raw message