当前位置: 首页>>代码示例>>Java>>正文


Java Page.adaptTo方法代码示例

本文整理汇总了Java中com.day.cq.wcm.api.Page.adaptTo方法的典型用法代码示例。如果您正苦于以下问题:Java Page.adaptTo方法的具体用法?Java Page.adaptTo怎么用?Java Page.adaptTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.day.cq.wcm.api.Page的用法示例。


在下文中一共展示了Page.adaptTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pageExistsAt

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
public static Matcher<Page> pageExistsAt(String path) {
	return new TypeSafeMatcher<Page>() {
		
		@Override
		protected boolean matchesSafely(Page actual) {
			if (actual == null || actual.getContentResource() == null) {
				return false;
			}
			Resource resource = actual.adaptTo(Resource.class);
			ValueMap content  = actual.getContentResource().adaptTo(ValueMap.class);
			return resource != null
			       && !resource.isResourceType(Resource.RESOURCE_TYPE_NON_EXISTING)
			       && ResourceType.PAGE_CONTENT_TYPE.getName().equals(actual.getProperties().get(ResourceProperty.PRIMARY_TYPE))
			       && StringUtils.isNotBlank(actual.getTemplate().getPath())
			       && path.endsWith(content.get(ResourceProperty.TITLE).toString())
			       && path.equals(resource.getPath());
			
		}
		
		@Override
		public void describeTo(Description description) {
			description.appendText(MessageFormat.format("Page with valid jcr:resourceType at {0} should exist.", path));
		}
	};
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:26,代码来源:AemMatchers.java

示例2: aPageWithParents

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
public Resource aPageWithParents(String path, Object... properties) throws Exception {
	Resource result = null;
	Page     page   = client.getPageManager().getPage(path);
	if (page != null) {
		return page.adaptTo(Resource.class);
	}
	
	PathIterator it = new PathIterator(path);
	it.first(); // root
	while (it.hasNext()) {
		String curPath = it.next();
		if (Arrays.asList("/content", "/libs", "/apps").contains(curPath)) {
			continue;
		}
		result = client.getResourceResolver().getResource(curPath);
		if (result == null) {
			if (it.hasNext()) {
				result = client.getContentBuilder().page(curPath, PageType.DEFAULT_TEMPLATE.getTemplate().getName(), new HashMap<>()).adaptTo(Resource.class);
			} else {
				Properties pairs    = new Properties(properties);
				String     template = toStringValue(pairs.remove(TEMPLATE));
				if (StringUtils.isEmpty(template)) {
					template = PageType.DEFAULT_TEMPLATE.getTemplate().getName();
				}
				if (client.getResourceResolver().getResource(template) == null) {
					client.getContentBuilder().resource(template, Collections.singletonMap(PRIMARY_TYPE, ResourceType.TEMPLATE_TYPE));
				}
				result = client.getContentBuilder().page(curPath, template, pairs.toMap()).adaptTo(Resource.class);
			}
		}
	}
	if (result == null) {
		throw new RuntimeException(MessageFormat.format("Cannot create result at '{0}'", result));
	}
	return result;
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:38,代码来源:Pages.java

示例3: adaptToWithValueMapReturnsPagesProperties

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void adaptToWithValueMapReturnsPagesProperties() throws Exception {
	Page target = aPage("/content/ko");
	
	ValueMap actual = target.adaptTo(ValueMap.class);
	
	// jcr:created, jcr:createdBy are added
	assertEquals(target.getProperties().size(), actual.size() + 2);
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:10,代码来源:PageTest.java

示例4: adaptToWithValueMapReturnsPagesProperties

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void adaptToWithValueMapReturnsPagesProperties() throws Exception {
	Page target = aPage("/content/ko");
	
	ValueMap actual = target.adaptTo(ValueMap.class);
	
	// cq:Template, jcr:title are removed
	assertEquals(target.getProperties().size(), actual.size() + 2);
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:10,代码来源:MockPageTest.java

示例5: adaptToWithValueMapPreservePrimaryTypeProperty

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void adaptToWithValueMapPreservePrimaryTypeProperty() throws Exception {
	Page target = aPage("/content/ko");
	
	ValueMap actual = target.adaptTo(ValueMap.class);
	
	assertEquals(ResourceType.PAGE_TYPE, actual.get(ResourceProperty.PRIMARY_TYPE));
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:9,代码来源:MockPageTest.java

示例6: adaptToWithResourceReturnsPagesResource

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void adaptToWithResourceReturnsPagesResource() throws Exception {
	Page target = aPage("/content/test");
	
	Resource actual = target.adaptTo(Resource.class);
	
	assertEquals(client.getResourceResolver().getResource("/content/test").getPath(), actual.getPath());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:9,代码来源:PageTestDriver.java

示例7: findExperienceFragmentSocialVariation

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private ExperienceFragmentSocialVariation findExperienceFragmentSocialVariation() {
    Page variantPage = currentPage.getPageManager().getPage(variantPath);
    if (variantPage == null)
        return null;

    ExperienceFragmentSocialVariation socialVariant = variantPage.adaptTo(ExperienceFragmentSocialVariation.class);
    return socialVariant;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:9,代码来源:SocialMediaHelperImpl.java


注:本文中的com.day.cq.wcm.api.Page.adaptTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。