cziegeler commented on a change in pull request #10:
URL: 
https://github.com/apache/sling-org-apache-sling-engine/pull/10#discussion_r498025085



##########
File path: src/main/java/org/apache/sling/engine/impl/request/RequestData.java
##########
@@ -237,19 +237,17 @@ public Resource initResource(ResourceResolver 
resourceResolver) {
         requestProgressTracker.startTimer("ResourceResolution");
         final SlingHttpServletRequest request = getSlingRequest();
 
-        StringBuffer requestURL = servletRequest.getRequestURL();
-        String path = request.getPathInfo();
-        if (requestURL.indexOf(";") > -1 && !path.contains(";")) {
-            final String decodedURL;
-            try {
-                decodedURL = URLDecoder.decode(requestURL.toString(), "UTF-8");
-            } catch (UnsupportedEncodingException e) {
-                throw new AssertionError("UTF-8 encoding is not supported");
-            }
-            path = path.concat(decodedURL.substring(decodedURL.indexOf(';')));
+        // Set by o.a.s.auth.core bundle
+        SlingUri slingUri = (SlingUri) 
request.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_URI);
+        if (slingUri == null) {
+            throw new IllegalStateException(
+                    "SlingUri not available as attribute of request (expected 
to be set in bundle o.a.s.auth.core)");
         }
+        // ensure slingUri is bound to correct resource resolver
+        slingUri = slingUri.adjust(b -> 
b.setResourceResolver(resourceResolver));
+        request.setAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_URI, 
slingUri);

Review comment:
       I would rather remove the attribute, so its not leaking any further

##########
File path: src/main/java/org/apache/sling/engine/impl/request/RequestData.java
##########
@@ -237,19 +237,17 @@ public Resource initResource(ResourceResolver 
resourceResolver) {
         requestProgressTracker.startTimer("ResourceResolution");
         final SlingHttpServletRequest request = getSlingRequest();
 
-        StringBuffer requestURL = servletRequest.getRequestURL();
-        String path = request.getPathInfo();
-        if (requestURL.indexOf(";") > -1 && !path.contains(";")) {
-            final String decodedURL;
-            try {
-                decodedURL = URLDecoder.decode(requestURL.toString(), "UTF-8");
-            } catch (UnsupportedEncodingException e) {
-                throw new AssertionError("UTF-8 encoding is not supported");
-            }
-            path = path.concat(decodedURL.substring(decodedURL.indexOf(';')));
+        // Set by o.a.s.auth.core bundle
+        SlingUri slingUri = (SlingUri) 
request.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_URI);
+        if (slingUri == null) {
+            throw new IllegalStateException(
+                    "SlingUri not available as attribute of request (expected 
to be set in bundle o.a.s.auth.core)");
         }
+        // ensure slingUri is bound to correct resource resolver
+        slingUri = slingUri.adjust(b -> 
b.setResourceResolver(resourceResolver));
+        request.setAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_URI, 
slingUri);
 
-        Resource resource = resourceResolver.resolve(request, path);
+        Resource resource = resourceResolver.resolve(request, 
slingUri.getPath());

Review comment:
       I think this is where we need a new method in the resource resolver, uri 
mapping has already been applied.
   Or we can use getResource() - as slingUri has already done that part (using 
a service user) - only if null is returned, we can invoke resolve()

##########
File path: src/main/java/org/apache/sling/engine/impl/request/RequestData.java
##########
@@ -262,10 +260,14 @@ public Resource initResource(ResourceResolver 
resourceResolver) {
     public void initServlet(final Resource resource,
             final ServletResolver sr) {
         // the resource and the request path info, will never be null
-        RequestPathInfo requestPathInfo = new SlingRequestPathInfo(resource);
-        ContentData contentData = setContent(resource, requestPathInfo);
-
-           requestProgressTracker.log("Resource Path Info: {0}", 
requestPathInfo);
+        SlingUri slingUri = (SlingUri) 
getSlingRequest().getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_URI);

Review comment:
       I think the uri should rather be parsed in as an argument to this method 
than relying on request attributes




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to