You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2008/01/18 14:17:34 UTC
[jira] Commented: (SLING-159) JcrResourceResolverFactoryImpl fails
if suffix contains illegal jcr character
[ https://issues.apache.org/jira/browse/SLING-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560370#action_12560370 ]
Felix Meschberger commented on SLING-159:
-----------------------------------------
First of all, I do not like to get a RepositoryException in this case ! A more descriptive exception would be more helpfull.
Second: Reading the API spec for Session.itemExists(String path), I would not expect an exception at all in this case:
/**
* Returns <code>true</code> if an item exists at <code>absPath</code>; otherwise returns <code>false</code>.
* Also returns <code>false</code> if the specified <code>absPath</code> is malformed.
*
* @param absPath an absolute path
* @return <code>true</code> if an item exists at <code>absPath</code>; otherwise returns <code>false</code>.
* @throws RepositoryException if an error occurs.
*/
public boolean itemExists(String absPath) throws RepositoryException;
If this is correct, I assume a path like "/xyt/abc/*" to be malformed and hence just cause false to be returned.
Because the RepositoryException may be any exception, I could not even handle (some connection issues ?). So I would rather keep getting kicked out of the loop if such an exception would occurr here.
> JcrResourceResolverFactoryImpl fails if suffix contains illegal jcr character
> -----------------------------------------------------------------------------
>
> Key: SLING-159
> URL: https://issues.apache.org/jira/browse/SLING-159
> Project: Sling
> Issue Type: Bug
> Components: Resource
> Reporter: Tobias Bocanegra
>
> eg request to /content/test.html/* throws RepositoryException because the * is not
> a valid jcr name character:
> javax.jcr.RepositoryException: invalid path:/content/test.html/*: '/content/test.html/*' is not a valid path. '*' not a valid name character.: '/content/test.html/*' is not a valid path. '*' not a valid name character.
> at com.day.crx.core.SessionImpl.itemExists(SessionImpl.java:808)
> at org.apache.sling.jcr.api.internal.PooledSession.itemExists(PooledSession.java:235)
> at org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.itemReallyExists(JcrResourceResolverFactoryImpl.java:316)
> ...
> Suggest to catch the exception and return false in this case:
> Index: src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
> ===================================================================
> --- src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (revision 612138)
> +++ src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (working copy)
> @@ -313,7 +313,11 @@
> // assume this session has more access rights than the client Session
> String workSpace = clientSession.getWorkspace().getName();
> Session adminSession = getAdminSession(workSpace);
> - return adminSession.itemExists(path);
> + try {
> + return adminSession.itemExists(path);
> + } catch (RepositoryException e) {
> + return false;
> + }
> }
> (another solution would be to explicitly check the path for illegal characters prior to call itemExists. this way it can be distinguished from other repository exceptions.)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.