You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2021/05/28 15:43:16 UTC
[sling-org-apache-sling-resourceresolver] branch master updated
(2108700 -> 6c20308)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git.
from 2108700 Cosmetic: cleanup whitespace
new f9283b8 SLING-10432 - regression: incorrect mapping result for aliased pages
new 6c20308 SLING-10432 - regression: incorrect mapping result for aliased pages
The 2 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:
.../resourceresolver/impl/mapping/ResourceMapperImpl.java | 13 +++++++++++--
.../impl/mapping/ResourceMapperImplTest.java | 14 ++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
[sling-org-apache-sling-resourceresolver] 02/02: SLING-10432 -
regression: incorrect mapping result for aliased pages
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 6c203087a1d989b9bc8fe8d872b629774b79604e
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri May 28 17:32:28 2021 +0200
SLING-10432 - regression: incorrect mapping result for aliased pages
- ensure that the path of the resolved resources does not get added to the aliases list
- try harder to establish a mapping (edge scenario for resolving thee empty path)
- enable the previously ignored test for this issue
---
.../resourceresolver/impl/mapping/ResourceMapperImpl.java | 13 +++++++++++--
.../impl/mapping/ResourceMapperImplTest.java | 2 --
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java
index b44789d..2216331 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java
@@ -164,10 +164,14 @@ public class ResourceMapperImpl implements ResourceMapper {
// vanity paths are prepended to make sure they get returned last
mappings.addAll(0, vanityPaths);
- // 7. apply context path if needed
+ // 7. final effort to make sure we have at least one mapped path
+ if ( mappings.isEmpty() && nonDecoratedResource != null )
+ mappings.add(nonDecoratedResource.getPath());
+
+ // 8. apply context path if needed
mappings.replaceAll(new ApplyContextPath(request));
- // 8. set back the fragment query if needed
+ // 9. set back the fragment query if needed
if ( fragmentQuery != null ) {
mappings.replaceAll(path -> path.concat(fragmentQuery));
}
@@ -218,6 +222,11 @@ public class ResourceMapperImpl implements ResourceMapper {
// and then we have the mapped path to work on
List<String> mappedPaths = pathBuilder.generatePaths();
+ // specifically exclude the resource's path when generating aliases
+ // usually this is removed the invoking method if the path matches an existing
+ // resource, but for non-existing ones this does not work
+ mappedPaths.remove(nonDecoratedResource.getPath());
+
logger.debug("map: Alias mapping resolves to paths {}", mappedPaths);
return mappedPaths;
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
index 9ae3c4f..f0639cb 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
@@ -47,7 +47,6 @@ import org.apache.sling.spi.resource.provider.ResourceProvider;
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -333,7 +332,6 @@ public class ResourceMapperImplTest {
* is the alias itself
*/
@Test
- @Ignore("SLING-10432")
public void mapAliasTarget() {
ExpectedMappings.nonExistingResource("/alias-value")
.singleMapping("/alias-value")
[sling-org-apache-sling-resourceresolver] 01/02: SLING-10432 -
regression: incorrect mapping result for aliased pages
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit f9283b899147b1122e865eefabfb07404e7e9242
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri May 28 15:39:31 2021 +0200
SLING-10432 - regression: incorrect mapping result for aliased pages
Add a failing test(ignored for now)
---
.../impl/mapping/ResourceMapperImplTest.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
index a990eb2..9ae3c4f 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
@@ -47,6 +47,7 @@ import org.apache.sling.spi.resource.provider.ResourceProvider;
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -327,6 +328,21 @@ public class ResourceMapperImplTest {
.verify(resolver, req);
}
+ /**
+ * Validates that the mapping for a non-existing resource that is the target of an alias
+ * is the alias itself
+ */
+ @Test
+ @Ignore("SLING-10432")
+ public void mapAliasTarget() {
+ ExpectedMappings.nonExistingResource("/alias-value")
+ .singleMapping("/alias-value")
+ .singleMappingWithRequest("/app/alias-value")
+ .allMappings("/alias-value")
+ .allMappingsWithRequest("/app/alias-value")
+ .verify(resolver, req);
+ }
+
static class ExpectedMappings {
public static ExpectedMappings existingResource(String path) {