本文整理汇总了Java中com.day.cq.wcm.api.Page.getTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java Page.getTemplate方法的具体用法?Java Page.getTemplate怎么用?Java Page.getTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.day.cq.wcm.api.Page
的用法示例。
在下文中一共展示了Page.getTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSearchContentResource
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private Resource getSearchContentResource(SlingHttpServletRequest request, Page currentPage) {
Resource searchContentResource = null;
RequestPathInfo requestPathInfo = request.getRequestPathInfo();
Resource resource = request.getResource();
String relativeContentResource = requestPathInfo.getSuffix();
if (StringUtils.startsWith(relativeContentResource, "/")) {
relativeContentResource = StringUtils.substring(relativeContentResource, 1);
}
if (StringUtils.isNotEmpty(relativeContentResource)) {
searchContentResource = resource.getChild(relativeContentResource);
if (searchContentResource == null) {
PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
if (pageManager != null) {
Template template = currentPage.getTemplate();
if (template != null) {
Resource templateResource = request.getResourceResolver().getResource(template.getPath());
if (templateResource != null) {
searchContentResource = templateResource.getChild(NN_STRUCTURE + "/" + relativeContentResource);
}
}
}
}
}
return searchContentResource;
}
示例2: getTemplateWithTemplatePropertyReturnsTemplate
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void getTemplateWithTemplatePropertyReturnsTemplate() throws Exception {
Page target = aPage("/content/test/ko", ResourceProperty.TEMPLATE, "/libs/foobar/pages/page");
Template actual = target.getTemplate();
assertThat(client.getResourceResolver().getResource(actual.getPath()), resourceExistsAt("/libs/foobar/pages/page"));
}
示例3: getAdapter
import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <AdapterType> AdapterType getAdapter(Object o, Class<AdapterType> aClass) {
if (aClass == ContentPolicyMapping.class && o instanceof Resource) {
Resource resource = (Resource) o;
ValueMap valueMap = resource.getValueMap();
String policyPath = valueMap.get("cq:policy", StringUtils.EMPTY);
Resource policyMappingResource = null;
if (StringUtils.isNotEmpty(policyPath)) {
policyMappingResource = resource;
} else {
PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
if (pageManager != null) {
Page page = pageManager.getContainingPage(resource);
if (page != null) {
Template template = page.getTemplate();
if (template != null && page.getPath().startsWith(template.getPath() + "/")) {
// in template; resolve relative to policies node
policyPath = template.getPath() + "/policies/" + resource.getPath().replace(template.getPath
() + "/structure/", "");
policyMappingResource = resource.getResourceResolver().getResource(policyPath);
}
}
}
}
if (policyMappingResource != null) {
return (AdapterType) new MockContentPolicyMapping(policyMappingResource);
}
}
return null;
}