You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by gh...@apache.org on 2020/09/11 10:04:55 UTC

[sling-org-apache-sling-api] branch feature/SLING-9662-Introduce-Resource-Mapping-SPI-v2 updated (8d0fc53 -> 2325681)

This is an automated email from the ASF dual-hosted git repository.

ghenzler pushed a change to branch feature/SLING-9662-Introduce-Resource-Mapping-SPI-v2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git.


 discard 8d0fc53  SLING-9662 Javadoc, avoid increasing version of package org.apache.sling.api.resource
     new 2325681  SLING-9662 Javadoc, avoid increasing version of package org.apache.sling.api.resource

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (8d0fc53)
            \
             N -- N -- N   refs/heads/feature/SLING-9662-Introduce-Resource-Mapping-SPI-v2 (2325681)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/sling/api/resource/uri/ResourceUriBuilder.java  | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)


[sling-org-apache-sling-api] 01/01: SLING-9662 Javadoc, avoid increasing version of package org.apache.sling.api.resource

Posted by gh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ghenzler pushed a commit to branch feature/SLING-9662-Introduce-Resource-Mapping-SPI-v2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git

commit 2325681b27413d23c8aa841278aaa6e168104cf0
Author: georg.henzler <ge...@netcentric.biz>
AuthorDate: Fri Sep 11 11:57:39 2020 +0200

    SLING-9662 Javadoc, avoid increasing version of package
    org.apache.sling.api.resource
---
 .../resource/mapping/PathToUriMappingService.java  | 15 +++++++------
 .../apache/sling/api/resource/package-info.java    |  2 +-
 .../sling/api/resource/uri/ResourceUriBuilder.java | 25 +++++++++++++++-------
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/apache/sling/api/resource/mapping/PathToUriMappingService.java b/src/main/java/org/apache/sling/api/resource/mapping/PathToUriMappingService.java
index 8134699..0defbc3 100644
--- a/src/main/java/org/apache/sling/api/resource/mapping/PathToUriMappingService.java
+++ b/src/main/java/org/apache/sling/api/resource/mapping/PathToUriMappingService.java
@@ -54,16 +54,17 @@ public interface PathToUriMappingService {
         Map<String, ResourceUri> getIntermediateMappings();
     }
 
-    /** Resolves a path relative to the given request.
+    /** Maps a path to a URI
      * 
      * @param request
-     * @param path
-     * @return a @{link PathToUriMappingService.Result} */
-    Result resolve(@Nullable HttpServletRequest request, @NotNull String path);
-
-    /** @param request
      * @param resourcePath
      * @return a @{link PathToUriMappingService.Result} */
-    Result map(@Nullable HttpServletRequest request, @NotNull String resourcePath);
+    Result map(@Nullable HttpServletRequest exampleRequest, @NotNull String resourcePath);
 
+    /** Resolves a path relative to the given request.
+     * 
+     * @param request
+     * @param path
+     * @return a @{link PathToUriMappingService.Result} */
+    Result resolve(@Nullable HttpServletRequest request, @Nullable String path);
 }
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/api/resource/package-info.java b/src/main/java/org/apache/sling/api/resource/package-info.java
index ac05b61..7bd85e6 100644
--- a/src/main/java/org/apache/sling/api/resource/package-info.java
+++ b/src/main/java/org/apache/sling/api/resource/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("2.13.0")
+@Version("2.12.2")
 package org.apache.sling.api.resource;
 
 import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/api/resource/uri/ResourceUriBuilder.java b/src/main/java/org/apache/sling/api/resource/uri/ResourceUriBuilder.java
index bc9c4c6..4dd3b65 100644
--- a/src/main/java/org/apache/sling/api/resource/uri/ResourceUriBuilder.java
+++ b/src/main/java/org/apache/sling/api/resource/uri/ResourceUriBuilder.java
@@ -34,6 +34,8 @@ import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.request.RequestPathInfo;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 public class ResourceUriBuilder {
 
@@ -90,7 +92,9 @@ public class ResourceUriBuilder {
      * @param requestPathInfo
      * @return a ResourceUriBuilder */
     public static ResourceUriBuilder createFrom(RequestPathInfo requestPathInfo) {
+        Resource suffixResource = requestPathInfo.getSuffixResource();
         return create()
+                .setResourceResolver(suffixResource != null ? suffixResource.getResourceResolver() : null)
                 .setResourcePath(requestPathInfo.getResourcePath())
                 .setSelectors(requestPathInfo.getSelectors())
                 .setExtension(requestPathInfo.getExtension())
@@ -106,14 +110,17 @@ public class ResourceUriBuilder {
                 .setResourceResolver(request.getResourceResolver())
                 .setScheme(request.getScheme())
                 .setHost(request.getServerName())
-                .setPort(request.getServerPort());
+                .setPort(request.getServerPort())
+                .setQuery(request.getQueryString());
     }
 
-    /** Creates a builder from a URI.
+    /** Creates a builder from an arbitrary URI.
      * 
-     * @param uri
+     * @param uri the uri to transform to a ResourceUri
+     * @param resourceResolver a resource resolver is needed to decide up to what part the path is the resource path (that decision is only
+     *            possible by checking against the underlying repository). If null is passed in, the shortest viable resource path is used.
      * @return a ResourceUriBuilder */
-    public static ResourceUriBuilder createFrom(URI uri, ResourceResolver resourceResolver) {
+    public static ResourceUriBuilder createFrom(@NotNull URI uri, @Nullable ResourceResolver resourceResolver) {
         String path = uri.getPath();
         boolean pathExists = !StringUtils.isBlank(path);
         boolean schemeSpecificRelevant = !pathExists && uri.getQuery() == null;
@@ -131,15 +138,17 @@ public class ResourceUriBuilder {
 
     /** Creates a builder from an arbitrary URI string.
      * 
-     * @param resourceUriStr
+     * @param uriStr to uri string to parse
+     * @param resourceResolver a resource resolver is needed to decide up to what part the path is the resource path (that decision is only
+     *            possible by checking against the underlying repository). If null is passed in, the shortest viable resource path is used.
      * @return a ResourceUriBuilder */
-    public static ResourceUriBuilder parse(String resourceUriStr, ResourceResolver resourceResolver) {
+    public static ResourceUriBuilder parse(@NotNull String uriStr, @Nullable ResourceResolver resourceResolver) {
         URI uri;
         try {
-            uri = new URI(resourceUriStr);
+            uri = new URI(uriStr);
             return createFrom(uri, resourceResolver);
         } catch (URISyntaxException e) {
-            throw new IllegalArgumentException("Invalid URI " + resourceUriStr + ": " + e.getMessage(), e);
+            throw new IllegalArgumentException("Invalid URI " + uriStr + ": " + e.getMessage(), e);
         }
     }