use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class HiddenImplTest method prepareHiddenFieldForTest.
private Field prepareHiddenFieldForTest(String resourcePath) {
MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
request.setResource(resource);
Page currentPage = CONTEXT.pageManager().getPage(CONTAINING_PAGE);
SlingBindings slingBindings = new SlingBindings();
slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
slingBindings.put(SlingBindings.RESOURCE, resource);
slingBindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
request.setAttribute(SlingBindings.class.getName(), slingBindings);
return request.adaptTo(Field.class);
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class BreadcrumbImplTest method setUp.
@Before
public void setUp() throws Exception {
Page page = context.currentPage(CURRENT_PAGE);
slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
slingBindings.put(WCMBindings.CURRENT_PAGE, page);
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class TextImplTest method setUp.
@Before
public void setUp() {
Page page = context.currentPage(CONTAINING_PAGE);
slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
slingBindings.put(WCMBindings.CURRENT_PAGE, page);
context.registerService(FormStructureHelperFactory.class, new FormStructureHelperFactory() {
@Override
public FormStructureHelper getFormStructureHelper(Resource formElement) {
return null;
}
});
FormsHelperStubber.createStub();
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class SocialMediaHelperImpl method findExperienceFragmentSocialVariation.
private ExperienceFragmentSocialVariation findExperienceFragmentSocialVariation() {
Page variantPage = currentPage.getPageManager().getPage(variantPath);
if (variantPage == null)
return null;
ExperienceFragmentSocialVariation socialVariant = variantPage.adaptTo(ExperienceFragmentSocialVariation.class);
return socialVariant;
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ImageImpl method initModel.
@PostConstruct
private void initModel() {
boolean hasContent = false;
if (StringUtils.isNotEmpty(fileReference)) {
int dotIndex;
if ((dotIndex = fileReference.lastIndexOf(DOT)) != -1) {
extension = fileReference.substring(dotIndex + 1);
}
hasContent = true;
} else {
Resource file = resource.getChild(DownloadResource.NN_FILE);
if (file != null) {
extension = mimeTypeService.getExtension(PropertiesUtil.toString(file.getResourceMetadata().get(ResourceMetadata.CONTENT_TYPE), MIME_TYPE_IMAGE_JPEG));
hasContent = true;
}
}
if (hasContent) {
long lastModifiedDate = 0;
if (!wcmmode.isDisabled()) {
ValueMap properties = resource.getValueMap();
Calendar lastModified = properties.get(JcrConstants.JCR_LASTMODIFIED, Calendar.class);
if (lastModified == null) {
lastModified = properties.get(NameConstants.PN_PAGE_LAST_MOD, Calendar.class);
}
if (lastModified != null) {
lastModifiedDate = lastModified.getTimeInMillis();
}
}
if (extension.equalsIgnoreCase("tif") || extension.equalsIgnoreCase("tiff")) {
extension = DEFAULT_EXTENSION;
}
ResourceResolver resourceResolver = request.getResourceResolver();
ContentPolicyManager policyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
ContentPolicy contentPolicy = policyManager.getPolicy(resource);
if (contentPolicy != null) {
disableLazyLoading = contentPolicy.getProperties().get(PN_DESIGN_LAZY_LOADING_ENABLED, false);
}
Set<Integer> supportedRenditionWidths = getSupportedRenditionWidths(contentPolicy);
smartImages = new String[supportedRenditionWidths.size()];
smartSizes = new int[supportedRenditionWidths.size()];
int index = 0;
String escapedResourcePath = Text.escapePath(resource.getPath());
for (Integer width : supportedRenditionWidths) {
smartImages[index] = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT + width + DOT + extension + (!wcmmode.isDisabled() && lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : "");
smartSizes[index] = width;
index++;
}
if (smartSizes.length == 0 || smartSizes.length >= 2) {
src = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT + extension + (!wcmmode.isDisabled() && lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : "");
} else if (smartSizes.length == 1) {
src = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT + smartSizes[0] + DOT + extension + (!wcmmode.isDisabled() && lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : "");
}
if (!isDecorative) {
Page page = pageManager.getPage(linkURL);
if (page != null) {
String vanityURL = page.getVanityUrl();
linkURL = (vanityURL == null ? linkURL + ".html" : vanityURL);
}
} else {
linkURL = null;
alt = null;
}
buildJson();
}
}
Aggregations