@Test void testGetAllowedComponentsForNestedNestedParsys() { String linklist = CONTENT_ROOT_PATH + "/page-1/jcr:content/content/2colContainer/linklist/links"; Set<String> allowedComponents = underTest.getAllowedComponents(linklist, context.resourceResolver()); assertNotNull(allowedComponents, "Allowed component for parsys cannot be null"); assertTrue(allowedComponents.contains("dummy/components/linkItem"), "Component 'linkItem' must be allowed in " + linklist + "."); assertFalse(allowedComponents.contains("dummy/components/comp1"), "Component 'comp1' should not be allowed in " + linklist + "."); assertFalse(allowedComponents.contains("dummy/components/nestedComp1"), "Component 'nestedComp1' must be allowed in " + linklist + "."); }
@Override public @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver) { PageManager pageManager = AdaptTo.notNull(resolver, PageManager.class); Page page = pageManager.getContainingPage(resourcePath); if (page == null && StringUtils.contains(resourcePath, "/" + JcrConstants.JCR_CONTENT)) { page = pageManager.getPage(StringUtils.substringBefore(resourcePath, "/" + JcrConstants.JCR_CONTENT)); } if (page == null) { return ImmutableSet.of(); } String relativePath = StringUtils.substringAfter(resourcePath, page.getPath() + "/"); return getAllowedComponents(page, relativePath, null, resolver); }
AllowedComponentsProviderImpl implements AllowedComponentsProvider { @Override public @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver) { PageManager pageManager = AdaptTo.notNull(resolver, PageManager.class); Page page = pageManager.getContainingPage(resourcePath); if (page == null && StringUtils.contains(resourcePath, "/" + JcrConstants.JCR_CONTENT)) { page = pageManager.getPage(StringUtils.substringBefore(resourcePath, "/" + JcrConstants.JCR_CONTENT)); } if (page == null) { return ImmutableSet.of(); } String relativePath = StringUtils.substringAfter(resourcePath, page.getPath() + "/"); return getAllowedComponents(page, relativePath, null, resolver); } }
AllowedComponentsProviderImpl implements AllowedComponentsProvider { @Override public @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver) { PageManager pageManager = AdaptTo.notNull(resolver, PageManager.class); Page page = pageManager.getContainingPage(resourcePath); if (page == null && StringUtils.contains(resourcePath, "/" + JcrConstants.JCR_CONTENT)) { page = pageManager.getPage(StringUtils.substringBefore(resourcePath, "/" + JcrConstants.JCR_CONTENT)); } if (page == null) { return ImmutableSet.of(); } String relativePath = StringUtils.substringAfter(resourcePath, page.getPath() + "/"); return getAllowedComponents(page, relativePath, null, resolver); }  }
AllowedComponentsProviderImpl implements AllowedComponentsProvider { @Override public @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver) { PageManager pageManager = AdaptTo.notNull(resolver, PageManager.class); Page page = pageManager.getContainingPage(resourcePath); if (page == null && StringUtils.contains(resourcePath, "/" + JcrConstants.JCR_CONTENT)) { page = pageManager.getPage(StringUtils.substringBefore(resourcePath, "/" + JcrConstants.JCR_CONTENT)); } if (page == null) { return ImmutableSet.of(); } String relativePath = StringUtils.substringAfter(resourcePath, page.getPath() + "/"); return getAllowedComponents(page, relativePath, null, resolver); }  @Override @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver); @Override @NotNull Set<String> getAllowedComponents(@NotNull Page page, @NotNull String relativeResourcePath,
      @Nullable String resourceType, @NotNull ResourceResolver resolver); @Override @NotNull Set<String> getAllowedComponentsForTemplate(@NotNull String pageComponentPath, @NotNull ResourceResolver resolver); }
AllowedComponentsProviderImpl implements AllowedComponentsProvider { @Override public @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver) { PageManager pageManager = AdaptTo.notNull(resolver, PageManager.class); Page page = pageManager.getContainingPage(resourcePath); if (page == null && StringUtils.contains(resourcePath, "/" + JcrConstants.JCR_CONTENT)) { page = pageManager.getPage(StringUtils.substringBefore(resourcePath, "/" + JcrConstants.JCR_CONTENT)); } if (page == null) { return ImmutableSet.of(); } String relativePath = StringUtils.substringAfter(resourcePath, page.getPath() + "/"); return getAllowedComponents(page, relativePath, null, resolver); }  @Override @NotNull Set<String> getAllowedComponents(@NotNull String resourcePath, @NotNull ResourceResolver resolver); @Override @NotNull Set<String> getAllowedComponents(@NotNull Page page, @NotNull String relativeResourcePath,
      @Nullable String resourceType, @NotNull ResourceResolver resolver); @Override @NotNull Set<String> getAllowedComponentsForTemplate(@NotNull String pageComponentPath, @NotNull ResourceResolver resolver);  }