jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-553) Add NameMapper#getValidOakName that never returns null
Date Wed, 16 Jan 2013 14:32:12 GMT

    [ https://issues.apache.org/jira/browse/OAK-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13555074#comment-13555074
] 

Thomas Mueller commented on OAK-553:
------------------------------------

In oak-jcr we have:
17: getOakPathOrThrowNotFound
5: getOakNameOrThrow
4: getOakPathKeepIndexOrThrowNotFound
1: getOakPathOrNull (in hasPermission)

In oak-core:
11 NodeUtil.getOakName (throws IllegalArgumentException) 
   (5 via setName, 6 via setNames)

NamePathMapperImpl.getOakPath has incomplete error handling
("// TODO error handling?") and also returns null

About different exceptions:

2 RepositoryException
1 ValueFormatException

in the 3 other cases I think RepositoryException would be fine/better as well, because currently
they throw the "wrong" exception in my view:

1 AccessControlException("No such privilege " + privilegeName)
1 AccessControlException("Unsupported restriction: " + jcrName);
1 NamespaceException("Invalid privilege name " + privilegeName)

In any case I would prefer if we rename getOakName (possibly returning null) to getOakNameOrNull.
Because that way we completely avoid the edge cases / bugs in the future. And if that's fine
with everybody, we could change getOakName to getOakNameOrThrow (throws RepositoryException).
                
> Add NameMapper#getValidOakName that never returns null
> ------------------------------------------------------
>
>                 Key: OAK-553
>                 URL: https://issues.apache.org/jira/browse/OAK-553
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: angela
>
> we keep adding methods that convert a jcrName into an oak-name
> and throw an exception if the value returned by NameMapper#getOakName is
> null. instead of duplicating code i would like to add a second flavor
> of the method that throws if the the jcrName cannot be resolved to an oak
> name.
> i even suspect that most usages of the getOakName call that don't throw
> in case of null-value are susceptible to NPE. but we can still review those
> and possible replace them with the save method call.
> proposed patch for the interface:
> {code}
> /**
>      * Returns the Oak name for the specified JCR name. In contrast to
>      * {@link #getOakName(String)} this method will throw a {@code NamespaceException}
>      * if the JCR name is invalid and cannot be resolved.
>      *
>      * @param jcrName The JCR name to be converted.
>      * @return A valid Oak name.
>      * @throws NamespaceException If the JCR name cannot be resolved.
>      */
>     @Nonnull
>     String getValidOakName(@Nonnull String jcrName) throws NamespaceException;
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message