You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2007/11/26 18:13:55 UTC
svn commit: r598348 -
/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
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;
}