Joerg Hoh created SLING-13018:
---------------------------------

             Summary: URIProvider.toURI() has to throw IAE to signal failure to 
adapt
                 Key: SLING-13018
                 URL: https://issues.apache.org/jira/browse/SLING-13018
             Project: Sling
          Issue Type: Task
          Components: API, JCR
            Reporter: Joerg Hoh



{{JcrNodeResource.convertToPublicURI()}} iterates through a list of registered 
URIProviders to find if an URIProvider can handle this. Unfortunately the 
indication that an URIProvider cannot handle this is by throwing an 
{{IllegalArgumentException}}, which can consume quite some time.

For that I suggest to extend the {{URIProvider}} interface with a new method:

{noformat}
    URI toURIOrNull(@NotNull Resource resource, @NotNull URIProvider.Scope 
scope, @NotNull URIProvider.Operation operation);
{noformat}

which will return null if that URIProvider cannot handle the provided resource. 
If we provide a default implementation, so it will be only a minor version 
update on the package. And it's possible to override it on URIProviders with an 
improved version avoiding the creation of this exception.
Of course it also requires a small change in the JCRNodeResource to use this 
new method.

(In Sling/AEM this code path is used by JS Scripting.)





--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to