/** * @param page Page * @param urlHandler Url handler instance */ UrlBuilderImpl(Page page, UrlHandlerImpl urlHandler) { this.path = page != null ? page.getPath() : null; this.resource = null; this.page = page; this.urlHandler = urlHandler; }
@Override public boolean includes(Page page) { boolean included = false; Iterator<String> pathsToFollowIter = pathsToFollow.iterator(); while (!included && pathsToFollowIter.hasNext()) { String pathToFollow = pathsToFollowIter.next(); included = StringUtils.startsWith(pathToFollow, page.getPath()); } return included; }
/** * @param page Page * @return true if given page is the site root page */ public boolean isRootPage(Page page) { return StringUtils.equals(page.getPath(), getRootPath()); }
protected void addDefaultTemplateEditorClientLib(Resource templateResource, List<String> categories) { if (currentPage.getPath().startsWith(templateResource.getPath())) { categories.add(DEFAULT_TEMPLATE_EDITOR_CLIENTLIB); } }
@Override public String getNotificationId(final Page notificationPage) { final String path = notificationPage.getPath(); final String lastModified = String.valueOf(notificationPage.getLastModified().getTimeInMillis()); return "uid-" + DigestUtils.shaHex(path + lastModified); }
@Override public String getNotificationId(final Page notificationPage) { final String path = notificationPage.getPath(); final String lastModified = String.valueOf(notificationPage.getLastModified().getTimeInMillis()); return "uid-" + DigestUtils.sha1Hex(path + lastModified); }
private Map<String, String> getPageProperties(Page page) { Map<String, String> properties = new HashMap<>(); properties.put(JSON_KEY_NAME, page.getName()); properties.put(JSON_KEY_TITLE, page.getTitle()); properties.put(JSON_KEY_PAGE_TITLE, page.getPageTitle()); properties.put(JSON_KEY_PATH, page.getPath()); properties.put(JSON_KEY_DESCRIPTION, page.getDescription()); return properties; } }
@Override public final void forwardAsGet(final Form form, final Page page, final SlingHttpServletRequest request, final SlingHttpServletResponse response, final RequestDispatcherOptions options) throws ServletException, IOException { options.setForceResourceType(CQ_PAGE_RESOURCE_TYPE); final String path = page.getPath() + FormHelper.EXTENSION; this.forwardAsGet(form, path, request, response, options); }
@Override public final void forwardAsGet(final Form form, final Page page, final SlingHttpServletRequest request, final SlingHttpServletResponse response, final RequestDispatcherOptions options) throws ServletException, IOException { options.setForceResourceType(CQ_PAGE_RESOURCE_TYPE); final String path = page.getPath() + FormHelper.EXTENSION; this.forwardAsGet(form, path, request, response, options); }
@Override public String getURL() { String pagePath = currentPage.getPath(); String extension = request.getRequestPathInfo().getExtension(); String url = externalizer.publishLink(resourceResolver, pagePath) + "." + extension; return url; }
@Override public String getValue(Object obj) { Resource result = (Resource) obj; PageManager pageMgr = result.getResourceResolver().adaptTo(PageManager.class); Page page = pageMgr.getContainingPage(result); return page != null ? page.getPath() : ""; }
/** * Get global properties ValueMap for the current resource. */ protected ValueMap getGlobalProperties(Page pageRoot, Resource resource) { String globalPropsPath = pageRoot.getPath() + "/" + JcrConstants.JCR_CONTENT + "/" + SharedComponentProperties.NN_GLOBAL_COMPONENT_PROPERTIES; Resource globalPropsResource = resource.getResourceResolver().getResource(globalPropsPath); return globalPropsResource != null ? globalPropsResource.getValueMap() : ValueMapDecorator.EMPTY; }
private static String getPagePath(final Page page, final boolean mapped) { final String redirect = page.getProperties().get(REDIRECT_TARGET, ""); final String path = redirect.isEmpty() ? page.getPath() : redirect; final String result; if (mapped) { result = page.adaptTo(Resource.class).getResourceResolver().map(path); } else { result = path; } return result; } }
/** * Get shared properties ValueMap the current resource. */ protected ValueMap getSharedProperties(Page pageRoot, Resource resource) { String sharedPropsPath = pageRoot.getPath() + "/" + JcrConstants.JCR_CONTENT + "/" + SharedComponentProperties.NN_SHARED_COMPONENT_PROPERTIES + "/" + resource.getResourceType(); Resource sharedPropsResource = resource.getResourceResolver().getResource(sharedPropsPath); return sharedPropsResource != null ? sharedPropsResource.getValueMap() : ValueMapDecorator.EMPTY; }
private com.day.cq.wcm.api.reference.Reference toReference(Resource resource, Page configPage, Map<String, ConfigurationMetadata> configurationMetadatas, Set<String> configurationBuckets) { log.trace("Found configuration reference {} for resource {}", configPage.getPath(), resource.getPath()); return new com.day.cq.wcm.api.reference.Reference(getType(), getReferenceName(configPage, configurationMetadatas, configurationBuckets), configPage.adaptTo(Resource.class), getLastModifiedOf(configPage)); }
private void readProperties() { // read edit config properties startIn = properties.get(PN_SEARCH_IN, currentPage.getPath()); sortOrder = SortOrder.fromString(properties.get(PN_SORT_ORDER, SortOrder.ASC.value)); orderBy = OrderBy.fromString(properties.get(PN_ORDER_BY, StringUtils.EMPTY)); // read design config properties showDescription = properties.get(PN_SHOW_DESCRIPTION, currentStyle.get(PN_SHOW_DESCRIPTION, SHOW_DESCRIPTION_DEFAULT)); showModificationDate = properties.get( PN_SHOW_MODIFICATION_DATE, currentStyle.get(PN_SHOW_MODIFICATION_DATE, SHOW_MODIFICATION_DATE_DEFAULT)); linkItems = properties.get(PN_LINK_ITEMS, currentStyle.get(PN_LINK_ITEMS, LINK_ITEMS_DEFAULT)); dateFormatString = properties.get(PN_DATE_FORMAT, currentStyle.get(PN_DATE_FORMAT, PN_DATE_FORMAT_DEFAULT)); }