本文整理汇总了Java中com.day.cq.wcm.api.Page.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java Page.getPath方法的具体用法?Java Page.getPath怎么用?Java Page.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.day.cq.wcm.api.Page
的用法示例。
在下文中一共展示了Page.getPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocalizedPage
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
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;
}
示例2: extractPathList
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
* Takes page, filter, depth, the current page path, and extracts a list of children paths
*
* @param page The page to extract the list of children paths from
* @param filter The filter
* @param depth The depth to recurse on
* @param currentPage The path of the current page to flag is_current_page
* @return extractedPaths This is a Collection of Map of Page Object
*/
public static Collection<Map<String, Object>> extractPathList(Page page, Filter<Page> filter, int depth, String currentPage) {
Collection<Map<String, Object>> pathList = new ArrayList<>();
Iterator<Page> children = page.listChildren(filter);
if (depth > 0) {
while (children.hasNext()) {
Page child = children.next();
Map<String, Object> currentPath = new HashMap<>();
Collection<Map<String, Object>> childPaths = extractPathList(child, filter, depth - 1, currentPage);
String path = child.getPath();
currentPath.put(PATH_DETAILS_LIST_PATH_PROPERTY_NAME, path);
currentPath.put(PATH_DETAILS_LIST_PATHS_PROPERTY_NAME, childPaths);
if (path.equals(currentPage)) {
currentPath.put(IS_CURRENT_PAGE,true);
}
pathList.add(currentPath);
}
}
return pathList;
}
示例3: extractPathListCP
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
* Takes page, filter, depth, the current page path, excluded path, and extracts a list of children paths except the excluded path
*
* @param page The page to extract the list of children paths from
* @param filter The filter
* @param depth The depth to recurse on
* @param currentPage The path of the current page to flag is_current_page
* @param removeCurrentPage The path to be excluded
* @return extractedPaths This is a Collection of Map of Page Object
*/
public static Collection<Map<String, Object>> extractPathListCP(Page page, Filter<Page> filter, int depth, String currentPage, boolean removeCurrentPage) {
Collection<Map<String, Object>> pathList = new ArrayList<>();
Iterator<Page> children = page.listChildren(filter);
if (depth > 0) {
while (children.hasNext()) {
Page child = children.next();
Map<String, Object> currentPath = new HashMap<>();
Collection<Map<String, Object>> childPaths = extractPathList(child, filter, depth - 1, currentPage);
String path = child.getPath();
if (!path.equals(currentPage)) {
currentPath.put(PATH_DETAILS_LIST_PATH_PROPERTY_NAME, path);
currentPath.put(PATH_DETAILS_LIST_PATHS_PROPERTY_NAME, childPaths);
pathList.add(currentPath);
} else if (!removeCurrentPage) {
currentPath.put(PATH_DETAILS_LIST_PATH_PROPERTY_NAME, path);
currentPath.put(PATH_DETAILS_LIST_PATHS_PROPERTY_NAME, childPaths);
currentPath.put(IS_CURRENT_PAGE, true);
pathList.add(currentPath);
}
}
}
return pathList;
}
示例4: getThumbnailUrl
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private String getThumbnailUrl(Page page, int width, int height) {
String ck = "";
ValueMap metadata = page.getProperties(PN_IMAGE_FILE_JCR_CONTENT);
if (metadata != null) {
Calendar imageLastModified = metadata.get(JcrConstants.JCR_LASTMODIFIED, Calendar.class);
Calendar pageLastModified = page.getLastModified();
if (pageLastModified != null && pageLastModified.after(imageLastModified)) {
ck += pageLastModified.getTimeInMillis() / 1000;
} else if (imageLastModified != null) {
ck += imageLastModified.getTimeInMillis() / 1000;
} else if (pageLastModified != null) {
ck += pageLastModified.getTimeInMillis() / 1000;
}
}
return page.getPath() + ".thumb." + width + "." + height + ".png?ck=" + ck;
}
示例5: renderContent
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private String renderContent(SlingHttpServletRequest request, SlingHttpServletResponse response, String contentPath)
throws ServletException, IOException {
// We wrap the original POST request in a GET and wrap the response in a string buffer
GetRequestWrapper requestWrapper = new GetRequestWrapper(request);
BufferingResponseWrapper responseWrapper = new BufferingResponseWrapper(response);
RequestDispatcherOptions options = new RequestDispatcherOptions();
options.setReplaceSelectors("");
Page currentPage = request.getResource().adaptTo(Page.class);
Page root = WeRetailHelper.findRoot(currentPage);
String path = CONTENT_WE_RETAIL_DEFAULT + contentPath; // Fallback if root is not found
if (root != null) {
path = root.getPath() + contentPath;
}
request.getRequestDispatcher(path, options).include(requestWrapper, responseWrapper);
return responseWrapper.toStrippedOutput();
}
示例6: getResults
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private List<ListItem> getResults(SlingHttpServletRequest request, Resource searchResource, Page currentPage) {
ValueMap valueMap = searchResource.getValueMap();
ValueMap contentPolicyMap = getContentPolicyProperties(searchResource, request.getResource());
int searchTermMinimumLength = valueMap.get(Search.PN_SEARCH_TERM_MINIMUM_LENGTH, contentPolicyMap.get(Search
.PN_SEARCH_TERM_MINIMUM_LENGTH, SearchImpl.PROP_SEARCH_TERM_MINIMUM_LENGTH_DEFAULT));
int resultsSize = valueMap.get(Search.PN_RESULTS_SIZE, contentPolicyMap.get(Search.PN_RESULTS_SIZE,
SearchImpl.PROP_RESULTS_SIZE_DEFAULT));
String searchRootPagePath = getSearchRootPagePath(searchResource, currentPage, contentPolicyMap);
if (StringUtils.isEmpty(searchRootPagePath)) {
searchRootPagePath = currentPage.getPath();
}
List<ListItem> results = new ArrayList<>();
String fulltext = request.getParameter(PARAM_FULLTEXT);
if (fulltext == null || fulltext.length() < searchTermMinimumLength) {
return results;
}
long resultsOffset = 0;
if (request.getParameter(PARAM_RESULTS_OFFSET) != null) {
resultsOffset = Long.parseLong(request.getParameter(PARAM_RESULTS_OFFSET));
}
Map<String, String> predicatesMap = new HashMap<>();
predicatesMap.put(PREDICATE_FULLTEXT, fulltext);
predicatesMap.put(PREDICATE_PATH, searchRootPagePath);
predicatesMap.put(PREDICATE_TYPE, NameConstants.NT_PAGE);
PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
ResourceResolver resourceResolver = request.getResource().getResourceResolver();
Query query = queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
if (resultsSize != 0) {
query.setHitsPerPage(resultsSize);
}
if (resultsOffset != 0) {
query.setStart(resultsOffset);
}
SearchResult searchResult = query.getResult();
List<Hit> hits = searchResult.getHits();
if (hits != null) {
for (Hit hit : hits) {
try {
Resource hitRes = hit.getResource();
Page page = getPage(hitRes);
if (page != null) {
results.add(new PageListItemImpl(request, page));
}
} catch (RepositoryException e) {
LOGGER.error("Unable to retrieve search results for query.", e);
}
}
}
return results;
}
示例7: activate
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
public void activate() throws Exception {
Resource resource = getResource();
ResourceResolver resolver = getResourceResolver();
SlingHttpServletRequest request = getRequest();
SlingHttpServletResponse response = getResponse();
PageManager pageManager = getPageManager();
Page productPage = pageManager.getContainingPage(resource.getPath());
Product currentProduct = CommerceHelper.findCurrentProduct(productPage);
if(currentProduct == null) {
exists = false;
return;
}
ImageResource imageResource = currentProduct.getImage();
if (imageResource == null) {
exists = false;
return;
}
exists = true;
CommerceService commerceService = resource.adaptTo(CommerceService.class);
CommerceSession commerceSession = commerceService.login(request, response);
Product pimProduct = currentProduct.getPIMProduct();
image = imageResource.getPath();
name = pimProduct.getTitle();
description = pimProduct.getDescription();
price = commerceSession.getProductPrice(pimProduct);
path = productPage.getPath();
filters = getProductFilters(pimProduct, commerceSession);
}
示例8: getSearchRootPagePath
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private String getSearchRootPagePath(Resource searchResource, Page currentPage, ValueMap contentPolicyMap) {
String searchRootPagePath = null;
ValueMap valueMap = searchResource.getValueMap();
String searchRoot = valueMap.get(Search.PN_SEARCH_ROOT, contentPolicyMap.get(Search.PN_SEARCH_ROOT, String.class));
PageManager pageManager = currentPage.getPageManager();
if (StringUtils.isNotEmpty(searchRoot) && pageManager != null) {
Page rootPage = pageManager.getPage(searchRoot);
if (rootPage != null) {
Page searchRootLanguageRoot = languageManager.getLanguageRoot(rootPage.getContentResource());
Page currentPageLanguageRoot = languageManager.getLanguageRoot(currentPage.getContentResource());
RangeIterator liveCopiesIterator = null;
try {
liveCopiesIterator = relationshipManager.getLiveRelationships(currentPage.adaptTo(Resource.class), null, null);
} catch (WCMException e) {
// ignore it
}
if (searchRootLanguageRoot != null && currentPageLanguageRoot != null && !searchRootLanguageRoot.equals
(currentPageLanguageRoot)) {
// check if there's a language copy of the search root
Page languageCopySearchRoot = pageManager.getPage(ResourceUtil.normalize(currentPageLanguageRoot.getPath() + "/" +
getRelativePath(searchRootLanguageRoot, rootPage)));
if (languageCopySearchRoot != null) {
rootPage = languageCopySearchRoot;
}
} else if (liveCopiesIterator != null) {
while (liveCopiesIterator.hasNext()) {
LiveRelationship relationship = (LiveRelationship) liveCopiesIterator.next();
if (currentPage.getPath().startsWith(relationship.getTargetPath() + "/")) {
Page liveCopySearchRoot = pageManager.getPage(relationship.getTargetPath());
if (liveCopySearchRoot != null) {
rootPage = liveCopySearchRoot;
break;
}
}
}
}
searchRootPagePath = rootPage.getPath();
}
}
return searchRootPagePath;
}
示例9: getPagePath
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
public String getPagePath() {
PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
Page page = pageManager.getContainingPage(resource);
return (page != null ? page.getPath() : null);
}
示例10: getURL
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
* Given a {@link Page}, this method returns the correct URL, taking into account that the provided {@code page} might provide a
* vanity URL.
*
* @param request the current request, used to determine the server's context path
* @param page the page
* @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 Page page) {
String vanityURL = page.getVanityUrl();
return StringUtils.isEmpty(vanityURL) ? request.getContextPath() + page.getPath() + ".html" : request.getContextPath() + vanityURL;
}