This is an automated email from the ASF dual-hosted git repository. diru pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit ea67dfde29d5b9bc038d3a83e6221a92a734fa8c Author: Dirk Rudolph <[email protected]> AuthorDate: Wed Jun 9 10:37:47 2021 +0200 rename sitemapRoot to sling:sitemapRoot --- sitemap/README.md | 2 +- .../java/org/apache/sling/sitemap/SitemapService.java | 2 +- .../sitemap/impl/SitemapGeneratorExecutorTest.java | 3 ++- .../sling/sitemap/impl/SitemapSchedulerTest.java | 9 +++++---- .../impl/SitemapServiceImplSchedulingTest.java | 5 +++-- .../sling/sitemap/impl/SitemapServiceImplTest.java | 17 +++++++++-------- .../apache/sling/sitemap/impl/SitemapServletTest.java | 4 +++- .../apache/sling/sitemap/impl/SitemapStorageTest.java | 19 ++++++++++--------- .../apache/sling/sitemap/impl/SitemapUtilTest.java | 19 ++++++++++--------- .../ResourceTreeSitemapGeneratorTest/sitetree.json | 2 +- 10 files changed, 45 insertions(+), 37 deletions(-) diff --git a/sitemap/README.md b/sitemap/README.md index a7fb288..6123049 100644 --- a/sitemap/README.md +++ b/sitemap/README.md @@ -36,7 +36,7 @@ generation of sitemaps. On-demand generated sitemaps use the request session. ### Content Model In order to serve a sitemap, a resource must be marked as sitemap root resource. This is done by adding -a `sitemapRoot = true` property either to the resource, or it's `jcr:content` child. +a `sling:sitemapRoot = true` property either to the resource, or it's `jcr:content` child. When multiple resources in a resource tree are marked as as sitemap roots, the on closest to the repository root is considered to top level sitemap root and serves a sitemap-index additionally to the sitemap. diff --git a/sitemap/src/main/java/org/apache/sling/sitemap/SitemapService.java b/sitemap/src/main/java/org/apache/sling/sitemap/SitemapService.java index a5aa2b9..70cb219 100644 --- a/sitemap/src/main/java/org/apache/sling/sitemap/SitemapService.java +++ b/sitemap/src/main/java/org/apache/sling/sitemap/SitemapService.java @@ -31,7 +31,7 @@ import java.util.Collection; @ProviderType public interface SitemapService { - String PROPERTY_SITEMAP_ROOT = "sitemapRoot"; + String PROPERTY_SITEMAP_ROOT = "sling:sitemapRoot"; /** * Calls all registered SitemapSchedulers to schedule (re)generation for all sitemap roots and names. diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java index d000c35..7c2c123 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java @@ -24,6 +24,7 @@ import org.apache.sling.event.jobs.JobManager; import org.apache.sling.event.jobs.consumer.JobExecutionContext; import org.apache.sling.serviceusermapping.ServiceUserMapped; import org.apache.sling.sitemap.SitemapException; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.sitemap.builder.Sitemap; import org.apache.sling.sitemap.impl.builder.extensions.ExtensionProviderManager; @@ -80,7 +81,7 @@ public class SitemapGeneratorExecutorTest { @BeforeEach public void setup() { rootResource = context.create().resource("/content/site/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); storageRoot = context.create().resource("/var/sitemaps"); diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java index 1fda6b2..2c9c69e 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java @@ -24,6 +24,7 @@ import org.apache.sling.api.resource.Resource; import org.apache.sling.event.jobs.Job; import org.apache.sling.event.jobs.JobManager; import org.apache.sling.serviceusermapping.ServiceUserMapped; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.testing.mock.jcr.MockJcr; import org.apache.sling.testing.mock.sling.ResourceResolverType; @@ -71,10 +72,10 @@ public class SitemapSchedulerTest { @BeforeEach public void setup() { rootDe = context.create().resource("/content/site/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE)); + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE)); rootEn = context.create().resource("/content/site/en"); rootEnContent = context.create().resource("/content/site/en/jcr:content", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE)); + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE)); context.registerService(ServiceUserMapped.class, serviceUser, "subServiceName", "sitemap-reader"); context.registerService(JobManager.class, jobManager); @@ -98,7 +99,7 @@ public class SitemapSchedulerTest { // given MockJcr.setQueryResult( context.resourceResolver().adaptTo(Session.class), - "/jcr:root/content//*[@sitemapRoot=true]", + "/jcr:root/content//*[@" + SitemapService.PROPERTY_SITEMAP_ROOT + "=true]", Query.XPATH, ImmutableList.of( rootDe.adaptTo(Node.class), @@ -127,7 +128,7 @@ public class SitemapSchedulerTest { // given MockJcr.setQueryResult( context.resourceResolver().adaptTo(Session.class), - "/jcr:root/content//*[@sitemapRoot=true]", + "/jcr:root/content//*[@" + SitemapService.PROPERTY_SITEMAP_ROOT + "=true]", Query.XPATH, Collections.singletonList(rootDe.adaptTo(Node.class)) ); diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java index c495344..8cfe513 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java @@ -21,6 +21,7 @@ package org.apache.sling.sitemap.impl; import org.apache.sling.api.resource.Resource; import org.apache.sling.event.jobs.JobManager; import org.apache.sling.serviceusermapping.ServiceUserMapped; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.testing.mock.sling.junit5.SlingContext; import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension; @@ -58,10 +59,10 @@ public class SitemapServiceImplSchedulingTest { @BeforeEach public void setup() { root1 = context.create().resource("/content/site/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); root2 = context.create().resource("/content/microsite/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); context.registerService(ServiceUserMapped.class, serviceUser, "subServiceName", "sitemap-writer"); diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java index 3b188f4..100d376 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java @@ -24,6 +24,7 @@ import org.apache.sling.event.jobs.Job; import org.apache.sling.event.jobs.JobManager; import org.apache.sling.serviceusermapping.ServiceUserMapped; import org.apache.sling.sitemap.SitemapInfo; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.testing.mock.jcr.MockJcr; import org.apache.sling.testing.mock.sling.ResourceResolverType; @@ -84,19 +85,19 @@ public class SitemapServiceImplTest { @BeforeEach public void setup() { deRoot = context.create().resource("/content/site/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); enRoot = context.create().resource("/content/site/en", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); enFaqs = context.create().resource("/content/site/en/fags", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); enNews = context.create().resource("/content/site/en/news", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); frRoot = context.create().resource("/content/site/fr", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); noRoot = context.create().resource("/content/site/nothing"); @@ -147,7 +148,7 @@ public class SitemapServiceImplTest { MockJcr.setQueryResult( context.resourceResolver().adaptTo(Session.class), - "/jcr:root/content/site/en//*[@sitemapRoot=true]", + "/jcr:root/content/site/en//*[@" + SitemapService.PROPERTY_SITEMAP_ROOT + "=true]", Query.XPATH, Arrays.asList(enRoot.adaptTo(Node.class), enFaqs.adaptTo(Node.class)) ); @@ -173,7 +174,7 @@ public class SitemapServiceImplTest { MockJcr.setQueryResult( context.resourceResolver().adaptTo(Session.class), - "/jcr:root/content/site/en//*[@sitemapRoot=true]", + "/jcr:root/content/site/en//*[@" + SitemapService.PROPERTY_SITEMAP_ROOT + "=true]", Query.XPATH, Arrays.asList(enRoot.adaptTo(Node.class), enFaqs.adaptTo(Node.class)) ); @@ -221,7 +222,7 @@ public class SitemapServiceImplTest { MockJcr.setQueryResult( context.resourceResolver().adaptTo(Session.class), - "/jcr:root/content/site/en//*[@sitemapRoot=true]", + "/jcr:root/content/site/en//*[@" + SitemapService.PROPERTY_SITEMAP_ROOT + "=true]", Query.XPATH, Arrays.asList(enRoot.adaptTo(Node.class), enNews.adaptTo(Node.class)) ); diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java index bc678ae..5b6543c 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java @@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableSet; import org.apache.sling.api.resource.Resource; import org.apache.sling.event.jobs.JobManager; import org.apache.sling.serviceusermapping.ServiceUserMapped; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.TestResourceTreeSitemapGenerator; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.sitemap.impl.builder.SitemapImplTest; @@ -92,7 +93,8 @@ public class SitemapServletTest { @BeforeEach public void setup() { root = context.create().resource("/content/site/de"); - context.create().resource("/content/site/de/jcr:content", Collections.singletonMap("sitemapRoot", Boolean.TRUE)); + context.create().resource("/content/site/de/jcr:content", Collections.singletonMap( + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE)); context.registerService(ServiceUserMapped.class, serviceUser, "subServiceName", "sitemap-writer"); context.registerService(SitemapGenerator.class, generator); diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java index 3603a69..57264e9 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java @@ -24,6 +24,7 @@ import org.apache.sling.api.resource.ModifiableValueMap; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ValueMap; import org.apache.sling.serviceusermapping.ServiceUserMapped; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.testing.mock.sling.junit5.SlingContext; import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension; @@ -79,7 +80,7 @@ public class SitemapStorageTest { public void testConsecutiveWriteOfStateUpdatesContent() throws IOException { // given Resource root = context.create().resource("/content/site/de", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -113,7 +114,7 @@ public class SitemapStorageTest { public void testStateExpires() throws InterruptedException, IOException { // given Resource root = context.create().resource("/content/site/de", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -129,7 +130,7 @@ public class SitemapStorageTest { public void testListSitemapsReturnsOnlySitemaps() throws IOException { // given Resource root = context.create().resource("/content/site/de", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -148,7 +149,7 @@ public class SitemapStorageTest { public void testCleanupExpiredStates() throws Exception { // given Resource root = context.create().resource("/content/site/de", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -170,7 +171,7 @@ public class SitemapStorageTest { // given Resource newRoot = context.create().resource("/content/site/ch"); Resource initialRoot = context.create().resource("/content/site/ch/de-ch", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -180,7 +181,7 @@ public class SitemapStorageTest { assertNotNull(context.resourceResolver().getResource("/var/sitemaps/content/site/ch/de-ch/sitemap.xml")); // and when - newRoot.adaptTo(ModifiableValueMap.class).put("sitemapRoot", Boolean.TRUE); + newRoot.adaptTo(ModifiableValueMap.class).put(SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE); context.resourceResolver().commit(); subject.run(); @@ -192,10 +193,10 @@ public class SitemapStorageTest { public void testCleanupObsoleteSitemapsAfterNestedSitemapRootChanged() throws Exception { // given Resource root = context.create().resource("/content/site/de", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); Resource news = context.create().resource("/content/site/de/news", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -207,7 +208,7 @@ public class SitemapStorageTest { assertNotNull(context.resourceResolver().getResource("/var/sitemaps/content/site/de/news-sitemap.xml")); // and when - news.adaptTo(ModifiableValueMap.class).put("sitemapRoot", Boolean.FALSE); + news.adaptTo(ModifiableValueMap.class).put(SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.FALSE); context.resourceResolver().commit(); subject.run(); diff --git a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapUtilTest.java b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapUtilTest.java index a6eaa48..df6130b 100644 --- a/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapUtilTest.java +++ b/sitemap/src/test/java/org/apache/sling/sitemap/impl/SitemapUtilTest.java @@ -20,6 +20,7 @@ package org.apache.sling.sitemap.impl; import com.google.common.collect.ImmutableMap; import org.apache.sling.api.resource.Resource; +import org.apache.sling.sitemap.SitemapService; import org.apache.sling.sitemap.generator.SitemapGenerator; import org.apache.sling.testing.mock.sling.junit5.SlingContext; import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension; @@ -46,7 +47,7 @@ public class SitemapUtilTest { public void testSingleRootSitemapName() { // given Resource root = context.create().resource("/content/site/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -62,13 +63,13 @@ public class SitemapUtilTest { public void testMultiRootSitemapName() { // given context.create().resource("/content/site/de", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); Resource secondLevelRoot = context.create().resource("/content/site/de/faqs", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); Resource thirdLevelRoot = context.create().resource("/content/site/de/faqs/many", ImmutableMap.of( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when @@ -89,17 +90,17 @@ public class SitemapUtilTest { public void testSitemapResolutionFromFileName() { // given Resource root = context.create().resource("/content/site/de", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); Resource news = context.create().resource("/content/site/de/news", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); - Resource products = context.create().resource("/content/site/de/products"); + context.create().resource("/content/site/de/products"); Resource productPage = context.create().resource("/content/site/de/products/product-page", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); Resource product = context.create().resource("/content/site/de/products/product", Collections.singletonMap( - "sitemapRoot", Boolean.TRUE + SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE )); // when diff --git a/sitemap/src/test/resources/ResourceTreeSitemapGeneratorTest/sitetree.json b/sitemap/src/test/resources/ResourceTreeSitemapGeneratorTest/sitetree.json index 3b45693..ecf0d1c 100644 --- a/sitemap/src/test/resources/ResourceTreeSitemapGeneratorTest/sitetree.json +++ b/sitemap/src/test/resources/ResourceTreeSitemapGeneratorTest/sitetree.json @@ -2,7 +2,7 @@ "jcr:primaryType": "nt:unstructured", "jcr:content": { "jcr:primaryType": "nt:unstructured", - "sitemapRoot": true + "sling:sitemapRoot": true }, "child1": { "jcr:primaryType": "nt:unstructured",
