use of com.day.cq.wcm.api.reference.Reference in project acs-aem-commons by Adobe-Consulting-Services.
the class PagesReferenceProvider method findReferences.
@Override
public List<Reference> findReferences(Resource resource) {
List<Reference> references = new ArrayList<Reference>();
ResourceResolver resolver = resource.getResourceResolver();
PageManager pageManager = resolver.adaptTo(PageManager.class);
Set<Page> pages = new HashSet<Page>();
search(resource, pages, pageManager);
for (Page page : pages) {
Resource contentResource = page.getContentResource();
if (contentResource != null && !contentResource.getPath().equals(resource.getPath())) {
references.add(getReference(page));
}
}
return references;
}
use of com.day.cq.wcm.api.reference.Reference in project acs-aem-commons by Adobe-Consulting-Services.
the class DesignReferenceProvider method findReferences.
@Override
public List<Reference> findReferences(Resource resource) {
ResourceResolver resourceResolver = resource.getResourceResolver();
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Designer designer = resourceResolver.adaptTo(Designer.class);
Page page = pageManager.getContainingPage(resource);
if (page == null) {
return Collections.emptyList();
}
Design design = designer.getDesign(page);
if (design == null) {
return Collections.emptyList();
}
return Collections.singletonList(new Reference(TYPE_DESIGN_PAGE, String.format("%s (Design)", design.getId()), design.getContentResource(), getLastModified(design)));
}
use of com.day.cq.wcm.api.reference.Reference in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class CaConfigReferenceProviderTest method testDisabled.
@Test
void testDisabled() {
Resource resource = context.resourceResolver().getResource(TEST_CA_COMPONENT);
CaConfigReferenceProvider referenceProvider = context.registerInjectActivateService(new CaConfigReferenceProvider(), "enabled", false);
List<Reference> references = referenceProvider.findReferences(resource);
assertTrue(references.isEmpty());
}
use of com.day.cq.wcm.api.reference.Reference in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class CaConfigReferenceProviderTest method testNoReferences.
@Test
void testNoReferences() {
Resource resource = context.resourceResolver().getResource(TEST_NO_CA_COMPONENT);
assertNotNull(resource);
List<Reference> references = caConfigReferenceProvider.findReferences(resource);
assertEquals(0, references.size());
}
use of com.day.cq.wcm.api.reference.Reference in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class CaConfigReferenceProviderTest method testFindReferences.
@Test
void testFindReferences() {
Resource resource = context.resourceResolver().getResource(TEST_CA_COMPONENT);
assertNotNull(resource);
List<Reference> references = caConfigReferenceProvider.findReferences(resource);
assertEquals(2, references.size());
Reference reference = getReference(references, HtmlPageItemsConfig.class);
assertNotNull(reference);
Resource expectedReferenceRes = context.resourceResolver().getResource(SLING_CONFIGS_ROOT + "/" + HtmlPageItemsConfig.class.getName());
assertEquals("caconfig", reference.getType());
if (expectedReferenceRes != null) {
assertEquals(expectedReferenceRes.getPath(), reference.getResource().getPath());
}
assertEquals(1602683813696L, reference.getLastModified());
reference = getReference(references, DataLayerConfig.class);
assertNotNull(reference);
assertEquals(1623074213696L, reference.getLastModified());
}
Aggregations