private void addPagesFromPropertyValue(String strValue, Set<Page> pages, PageManager pageManager) { if (pattern.matcher(strValue).find()) { for (String path : getAllPathsInAProperty(strValue)) { Page page = pageManager.getContainingPage(path); if (page != null) { pages.add(page); } } } }
Resource pageA; //LiveCopy of Page B; LiveRelationshipManager liveRelationshipManager = resourceResolver.adaptTo(LiveRelationshipManager.class); PageManager pageManager = resourceResolver.adaptTo(PageManager.class); LiveRelationship liveRelationship = liveRelationshipManager.getLiveRelationship(pageA, false); String pageBPath = liveRelationship.getSourcePath(); Page pageB = pageManager.getPage(pageBPath);
private Page getOrCreateLogDir(ResourceResolver resolver) throws WCMException { PageManager pageManager = resolver.adaptTo(PageManager.class); Page historyPage = pageManager.getPage(HISTORY_PATH); if (historyPage == null) { boolean autoCommit = true; historyPage = pageManager .create("/etc/cqsm", "history", "/apps/cqsm/core/templates/historyTemplate", "History", autoCommit); } return historyPage; }
Page page = "pagePath"; ResourceResolver resourceResolver = getResourceResolver(); Resource parent = resourceResolver.resolve(pagePath + "/target"); PageManager pageManager = resourceResolver.adaptTo(PageManager.class); if (parent.getResourceType().equals(Resource.RESOURCE_TYPE_NON_EXISTING) { pageManager.create(pagePath, "target", "SOME_TEMPLATE_NAME", "SOME_TITLE"); } pageManager.copy(pagePath, pagePath + "/target/newPage", null, true, false);
private Page createPage(ResourceResolver resolver, String path, String template) throws PersistenceException { // ensure parent path hierarchy exists - if not create it using pages with structure template String parentPath = ResourceUtil.getParent(path); if (parentPath == null) { throw new RuntimeException("Unable to get parent path from: " + path); } if (resolver.getResource(parentPath) == null) { createPage(resolver, parentPath, getStructurePageTemplate()); } // create path with given template String name = ResourceUtil.getName(path); PageManager pageManager = resolver.adaptTo(PageManager.class); try { return pageManager.create(parentPath, name, StringUtils.defaultString(template), name, true); } catch (WCMException ex) { throw new PersistenceException("Creating page at " + path + " failed.", ex); } }
final Template template = pageManager.getTemplate(templatePath); return pageManager.create(folderPath, nodeName, templatePath, title, false); } else {
final Page page = pageManager.create(shardNode.getPath(), JcrUtil.createValidName(name), WORKFLOW_PACKAGE_TEMPLATE, name, false); final Resource contentResource = page.getContentResource();
private void addPagesFromPropertyValue(String strValue, Set<Page> pages, PageManager pageManager) { if (pattern.matcher(strValue).find()) { for (String path : getAllPathsInAProperty(strValue)) { Page page = pageManager.getContainingPage(path); if (page != null) { pages.add(page); } } } }
/** * Gets site root page of the current site. * @return Site root page for the current site. */ public Page getRootPage() { if (siteRootPage == null) { siteRootPage = pageManager.getPage(getRootPath()); } return siteRootPage; }
private Page getOrCreateLogDir(ResourceResolver resolver) throws WCMException { PageManager pageManager = resolver.adaptTo(PageManager.class); Page historyPage = pageManager.getPage(HISTORY_PATH); if (historyPage == null) { boolean autoCommit = true; historyPage = pageManager .create("/etc/cqsm", "history", "/apps/cqsm/core/templates/historyTemplate", "History", autoCommit); } return historyPage; }
final Page page = pageManager.create(shardNode.getPath(), JcrUtil.createValidName(name), WORKFLOW_PACKAGE_TEMPLATE, name, false); final Resource contentResource = page.getContentResource();
private void populateStaticListItems() { listItems = new ArrayList<>(); String[] pagesPaths = properties.get(PN_PAGES, new String[0]); for (String path : pagesPaths) { Page page = pageManager.getContainingPage(path); if (page != null) { listItems.add(page); } } }
/** * Get page relative to site root. * @param relativePath Path relative to site root * @return Page instance or null if not found */ public Page getRelativePage(String relativePath) { String path = getRootPath(); if (path == null) { return null; } StringBuilder sb = new StringBuilder(path); if (!relativePath.startsWith("/")) { sb.append("/"); } sb.append(relativePath); return pageManager.getPage(sb.toString()); }
@PostConstruct protected void intialize() { this.page = resourceResolver.adaptTo(PageManager.class).getContainingPage(resource); }
/** * If the provided {@code path} identifies a {@link Page}, this method will generate the correct URL for the page. Otherwise the * original {@code String} is returned. * * @param request the current request, used to determine the server's context path * @param pageManager the page manager * @param path the page path * @return the URL of the page identified by the provided {@code path}, or the original {@code path} if this doesn't identify a * {@link Page} */ @Nonnull public static String getURL(@Nonnull SlingHttpServletRequest request, @Nonnull PageManager pageManager, @Nonnull String path) { Page page = pageManager.getPage(path); if (page != null) { return getURL(request, page); } return path; }
private void collectSearchResults(SearchResult result) throws RepositoryException { for (Hit hit : result.getHits()) { Page containingPage = pageManager.getContainingPage(hit.getResource()); if (containingPage != null) { listItems.add(containingPage); } } }
private ExperienceFragmentSocialVariation findExperienceFragmentSocialVariation() { Page variantPage = currentPage.getPageManager().getPage(variantPath); if (variantPage == null) return null; ExperienceFragmentSocialVariation socialVariant = variantPage.adaptTo(ExperienceFragmentSocialVariation.class); return socialVariant; }
private Page getPage(Resource resource) { if (resource != null) { ResourceResolver resourceResolver = resource.getResourceResolver(); PageManager pageManager = resourceResolver.adaptTo(PageManager.class); if (pageManager != null) { return pageManager.getContainingPage(resource); } } return null; } }
private Page getLocalizedPage(Page page, Page languageRoot) { Page localizedPage; String path = languageRoot.getPath(); String relativePath = page.getPath(); if (relativePath.startsWith(path)) { localizedPage = page; } else { String separator = "/"; int i = relativePath.indexOf(separator); int occurrence = StringUtils.countMatches(path, separator) + 1; while (--occurrence > 0 && i != -1) { i = relativePath.indexOf(separator, i + 1); } relativePath = (i > 0) ? relativePath.substring(i) : ""; path = path.concat(relativePath); PageManager pageManager = page.getPageManager(); localizedPage = pageManager.getPage(path); } return localizedPage; } }
private Page getResourcePage(Object adaptable) { PageManager pageManager = getPageManager(adaptable); Resource resource = getResource(adaptable); if (pageManager != null && resource != null) { return pageManager.getContainingPage(resource); } return null; }