incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1465676 - /sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Date Mon, 08 Apr 2013 16:20:26 GMT
Author: cziegeler
Date: Mon Apr  8 16:20:26 2013
New Revision: 1465676

URL: http://svn.apache.org/r1465676
Log:
SLING-2813 :  Add helper method for creating a path of resources. Add special handling for
problems in a clustered jackrabbit scenario

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=1465676&r1=1465675&r2=1465676&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Mon Apr  8 16:20:26 2013
@@ -565,20 +565,25 @@ public class ResourceUtil {
                         intermediateResourceType,
                         autoCommit);
             }
-            try {
-                rsrc = resolver.create(parentResource, name, resourceProperties);
-                if ( autoCommit ) {
+            if ( autoCommit ) {
+                resolver.refresh();
+            }
+            rsrc = resolver.create(parentResource, name, resourceProperties);
+            if ( autoCommit ) {
+                try {
                     resolver.commit();
                     resolver.refresh();
                     rsrc = resolver.getResource(parentResource, name);
-                }
-            } catch ( final PersistenceException pe ) {
-                // try again - maybe someone else did create the resource in the meantime
-                resolver.refresh();
-                rsrc = resolver.getResource(parentResource, name);
-                if ( rsrc == null ) {
-                    throw pe;
-                }
+                } catch ( final PersistenceException pe ) {
+                    // try again - maybe someone else did create the resource in the meantime
+                    // or we ran into Jackrabbit's stale item exception in a clustered environment
+                    resolver.revert();
+                    resolver.refresh();
+                    rsrc = resolver.getResource(parentResource, name);
+                    if ( rsrc == null ) {
+                        rsrc = resolver.create(parentResource, name, resourceProperties);
+                    }
+            }
             }
         }
         return rsrc;



Mime
View raw message