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


Java Page.getContentResource方法代码示例

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


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

示例1: create

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
public IndexEntry create(String path, @Nonnull ResourceResolver resolver) {
  String[] indexRules = getIndexRules(PRIMARY_TYPE_VALUE);
  if (ArrayUtils.isNotEmpty(indexRules)) {
    PageManager pageManager = resolver.adaptTo(PageManager.class);
    if (pageManager != null) {
      Page page = pageManager.getPage(path);
      if (page != null) {
        IndexEntry ret = new IndexEntry("idx", "page", path);
        Resource res = page.getContentResource();
        if (res != null) {
          ret.addContent(getProperties(res, indexRules));
        }
        return ret;
      }
    }
  }
  else {
    LOG.warn("Could not load indexRules for " + PRIMARY_TYPE_VALUE);
  }
  return null;
}
 
开发者ID:deveth0,项目名称:elasticsearch-aem,代码行数:23,代码来源:PageContentBuilder.java

示例2: 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

示例3: getDataLayerConfig

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Retrieves the DataLayer config for the page or none if it is not
 * configured for that page or any inherited page.
 * 
 * @param page
 *            the page for which to get the data layer configuration
 * @return the DataLayer configuration
 */
public static AEMDataLayerConfig getDataLayerConfig(Page page) {
	if (page != null) {
		log.trace("Finding Digital Data config for {}", page.getPath());
		InheritanceValueMap properties = new HierarchyNodeInheritanceValueMap(page.getContentResource());
		String[] cloudServices = properties.getInherited(PN_CLOUD_SERVICE_CONFIGS, new String[0]);
		for (String cloudService : cloudServices) {
			if (cloudService.startsWith(AEM_DATALAYER_CONFIG_PATH)) {
				Page cloudServicePage = page.getPageManager().getContainingPage(cloudService);
				if (cloudServicePage != null) {
					return cloudServicePage.getContentResource().adaptTo(AEMDataLayerConfig.class);
				} else {
					log.warn("Cloud service not found at {}", cloudService);
				}
			}
		}
		log.warn("No Digital Data config found for {}", page.getPath());
	}
	return null;

}
 
开发者ID:PerficientDigital,项目名称:AEM-DataLayer,代码行数:29,代码来源:AEMDataLayerConfig.java

示例4: getSiteName

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
public String getSiteName() {
    Page page = findRootPage();

    String pageTitle = page.getPageTitle();
    if (StringUtils.isNotBlank(pageTitle)) {
        return pageTitle;
    }

    Resource content = page.getContentResource();
    if (content == null) {
        return null;
    }
    String title = content.getValueMap().get(JcrConstants.JCR_TITLE, String.class);
    if (StringUtils.isBlank(title)) {
        return null;
    }
    return title;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:20,代码来源:SocialMediaHelperImpl.java

示例5: getRelationships

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
public List<ProductRelationship> getRelationships(SlingHttpServletRequest request, CommerceSession session,
                                                  Page currentPage, Product currentProduct)
        throws CommerceException {
    if (!enabled) {
        return null;
    }

    if (session == null) {
        return null;
    }

    if (currentPage != null) {
        InheritanceValueMap properties = new HierarchyNodeInheritanceValueMap(currentPage.getContentResource());
        String commerceProvider = properties.getInherited(CommerceConstants.PN_COMMERCE_PROVIDER, String.class);
        if (commerceProvider != null && !commerceProvider.equals(WeRetailConstants.WE_RETAIL_COMMERCEPROVIDER)) {
            return null;
        }
    }

    return calculateRelationships(request, session, currentPage, currentProduct);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:23,代码来源:AbstractRelationshipsProvider.java

示例6: calculateRelationships

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
protected List<ProductRelationship> calculateRelationships(SlingHttpServletRequest request, CommerceSession session,
                                                           Page currentPage, Product currentProduct)
        throws CommerceException {
    // Add all products of the current cart to context
    final List<Product> contextProducts = new ArrayList<Product>();
    final List<CommerceSession.CartEntry> cartEntries = session.getCartEntries();
    for (CommerceSession.CartEntry entry : cartEntries) {
        contextProducts.add(entry.getProduct());
    }

    // Walk content-pages to find similar products
    ResourceResolver resolver = request.getResourceResolver();
    SimilarProductsCollector collector = new SimilarProductsCollector(resolver, session, RELATIONSHIP_TYPE,
            RELATIONSHIP_TITLE,
            contextProducts);
    final Page root = WeRetailHelper.findRoot(currentPage);
    if (root != null && root.getContentResource() != null) {
        collector.walk(root.getContentResource().getParent());
    }
    return collector.getRelationships();
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:23,代码来源:SimilarToCartRelationshipsProvider.java

示例7: getPageImagePath

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Get image path via a page and component's resource
 *
 * @param page The page to retrieve the image path from
 * @param componentResource The component resource that contains the image path
 * @return pageImagePath
 * @throws Exception
 */
public String getPageImagePath(Page page, Resource componentResource) throws Exception {
    String pageImagePath = BLANK;
    Resource imageResource = page.getContentResource(IMAGE);
    if (null != imageResource) {
        String renditionName = getRenditionName(componentResource);
        pageImagePath = getComponentAssetPath(imageResource, renditionName);
    }
    return pageImagePath;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:18,代码来源:AssetPathServiceImpl.java

示例8: getPageImagePath

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Deprecated
public static String getPageImagePath(Page page, String renditionImage){
    String pageImagePath = "";
    Resource imageResource = page.getContentResource(IMAGE);
    if(null != imageResource){
        pageImagePath = ImageUtils.getImagePath(imageResource, renditionImage);
    }
    return pageImagePath;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:10,代码来源:ImageUtils.java

示例9: getContentResourceWithExistingConentReturnsContentResource

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

示例10: getPages

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Returns all the pages of a sub-tree
 * root - root node to start listing from
 * level - how deep to get into the tree
 */
private List<PagePojo> getPages(Page root, int level, Page currentPage) {
    if (root == null || level == 0) {
        return null;
    }
    List<PagePojo> pages = new ArrayList<PagePojo>();
    Iterator<Page> it = root.listChildren(new PageFilter());

    while (it.hasNext()) {
        Page page = it.next();
        Resource pageContentResource = page.getContentResource();
        ValueMap pageValueMap = pageContentResource.adaptTo(ValueMap.class);
        if (pageValueMap.get(PROP_HIDE_IN_NAV, false)) {
            continue;
        }
        if (REDIRECT_RESOURCE_TYPE.equals(pageContentResource.getResourceType())) {
            page = resolveRedirect(pageValueMap);
        }
        boolean isSelected = (currentPage != null
                                && page != null
                                && currentPage.getPath().contains(page.getPath()));
        List<PagePojo> children = pageValueMap.get(PROP_HIDE_SUB_IN_NAV, false)
                ? new ArrayList<PagePojo>()
                : getPages(page, level - 1, currentPage);


        pages.add(new PagePojo(page, isSelected, children));
    }
    return pages;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:35,代码来源:Header.java

示例11: isRedirectPage

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Check if the current page is a redirect page
 * @param page to check
 * @return true if current page is of type redirect, otherwise false
 */
public static boolean isRedirectPage(Page page) {
    boolean isRedirect = false;
    Resource contentResource = page.getContentResource();
    if (contentResource != null) {
        isRedirect = contentResource.isResourceType(RT_REDIRECT);
    } else {
        log.error("Can't get content resource of page {}", page.getPath());
    }
    return isRedirect;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:16,代码来源:UrlHelper.java

示例12: resolveRedirectPage

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Resolve the page to the redirect page
 * 
 * @param page
 *            to resolve
 * @param pageManager
 *            the page manager
 * @return the redirect target or the given page
 */
public static Page resolveRedirectPage(Page page, PageManager pageManager) {
    Page redirectTarget = page;
    if (isRedirectPage(page)) {
        Resource contentResource = page.getContentResource();
        ValueMap valueMap = contentResource.adaptTo(ValueMap.class);
        String redirectPagePath = valueMap.get(PN_REDIRECT_TARGET, StringUtils.EMPTY);
        Page resolvedPage = pageManager.getPage(redirectPagePath);
        if (resolvedPage != null) {
            redirectTarget = resolvedPage;
        }
    }
    return redirectTarget;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:23,代码来源:UrlHelper.java

示例13: isRoot

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Checks if a page is the root page of the site
 * 
 * @param page
 *            current page to check
 * @return <code>true</code> if the page is the root page of the site, <code>false</code> otherwise.
 */
public static boolean isRoot(Page page) {
    Resource res = page.getContentResource();
    if (res == null) {
        return false;
    }
    ValueMap vm = res.adaptTo(ValueMap.class);
    return vm.get(PROP_NAV_ROOT, false);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:16,代码来源:WeRetailHelper.java


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