incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r598348 - /incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
Date Mon, 26 Nov 2007 17:13:55 GMT
Author: bdelacretaz
Date: Mon Nov 26 09:13:55 2007
New Revision: 598348

URL: http://svn.apache.org/viewvc?rev=598348&view=rev
Log:
SLING-92 : do not throw exceptions on invalid JCR path, declare that as a "resource not found"
situation. Useful for microjax which uses /* to mean "create resource here".

Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java?rev=598348&r1=598347&r2=598348&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
Mon Nov 26 09:13:55 2007
@@ -299,17 +299,31 @@
         throw new SlingException("Session has already been closed");
     }
 
-    /** Creates a JcrNodeResource with the given path if existing */
+    /** Creates a JcrNodeResource object with the given path if existing */
     protected Resource getResource(Session session, String path)
             throws RepositoryException {
-        if (session.itemExists(path)) {
+        
+        boolean exists = false;
+        try {
+            exists = session.itemExists(path);
+        } catch(RepositoryException re) {
+            // usually means an invalid path, consider this
+            // as "resource not found". Invalid paths are used
+            // for example by the MicrojaxPostServlet where a path
+            // ending in /* means "create a new resource here"
+            if(log.isDebugEnabled()) {
+                log.debug("RepositoryException while looking for Item at path '" + path +
"' - ignoring exception: " + re);
+            }
+        }
+
+        if(exists) {
             Resource result = new JcrNodeResource(session, path);
             result.getResourceMetadata().put(ResourceMetadata.RESOLUTION_PATH,
                 path);
             log.info("Found Resource at path '{}'", path);
             return result;
         }
-
+    
         log.info("Path '{}' does not resolve to an Item", path);
         return null;
     }



Mime
View raw message