You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Tobias Bocanegra (JIRA)" <ji...@apache.org> on 2008/01/15 22:21:34 UTC
[jira] Created: (SLING-159) JcrResourceResolverFactoryImpl fails if
suffix contains illegal jcr character
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.
[jira] Commented: (SLING-159) JcrResourceResolverFactoryImpl fails
if suffix contains illegal jcr character
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560509#action_12560509 ]
Felix Meschberger commented on SLING-159:
-----------------------------------------
Implemented the initially proposed workaround in Rev. 613228.
This has to be changed as soon as JCR-1328 has been resolved.
> 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.
[jira] Commented: (SLING-159) JcrResourceResolverFactoryImpl fails
if suffix contains illegal jcr character
Posted by "Tobias Bocanegra (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560384#action_12560384 ]
Tobias Bocanegra commented on SLING-159:
----------------------------------------
the spec is not very clear here. but as a matter of fact, it throws a repo exception if the path is /a/b/c/*.
but i agree that catching the repo exception is a bit strong.
import org.apache.jackrabbit.spi.commons.conversion.PathParser;
try {
PathParser.checkFormat(path)
} catch (MalformedPathException e) {
return false;
}
> 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.
[jira] Issue Comment Edited: (SLING-159)
JcrResourceResolverFactoryImpl fails if suffix contains illegal jcr
character
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560391#action_12560391 ]
fmeschbe edited comment on SLING-159 at 1/18/08 11:11 AM:
-------------------------------------------------------------------
Hmm, I have a not so good guts feeling with this solution.
It even seems that this behaviour has been codified in JSR 170 1.1 and is about to be codified in JSR-283. I reopened a respective issue for JSR-283 [1]
[1] https://jsr-283.dev.java.net/issues/show_bug.cgi?id=58
was (Author: fmeschbe):
-1
I do not have nothing to do with SPI and I do not want to check the path first.
To me the spec is perfectly clear: The path is malformed :-) The PathParser seems to acknowledge that by throwing a MalformedPathException ....
I will create a Jackrabbit JIRA.
> 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.
[jira] Commented: (SLING-159) JcrResourceResolverFactoryImpl fails
if suffix contains illegal jcr character
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Closed: (SLING-159) JcrResourceResolverFactoryImpl fails if
suffix contains illegal jcr character
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-159?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger closed SLING-159.
-----------------------------------
Resolution: Fixed
Fix Version/s: 2.0.0
Assignee: Felix Meschberger
Closing this issue for now, as it seems that JCR-1328 will not be fixed in the expected direction in the short time frame. It even seems, that throwing the exception for illegal names is going to be standardized.
> 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
> Assignee: Felix Meschberger
> Fix For: 2.0.0
>
>
> 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.
[jira] Commented: (SLING-159) JcrResourceResolverFactoryImpl fails
if suffix contains illegal jcr character
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560391#action_12560391 ]
Felix Meschberger commented on SLING-159:
-----------------------------------------
-1
I do not have nothing to do with SPI and I do not want to check the path first.
To me the spec is perfectly clear: The path is malformed :-) The PathParser seems to acknowledge that by throwing a MalformedPathException ....
I will create a Jackrabbit JIRA.
> 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.