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


Java Resource.getResourceResolver方法代码示例

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


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

示例1: process

import org.apache.sling.api.resource.Resource; //导入方法依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, TemplateContentModel contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        Resource resource = request.getResource();
        if (resource != null) {
            ResourceResolver resourceResolver = resource.getResourceResolver();
            PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
            String pathRefListContentKeyName = getPathRefListKeyName(resource);
            if (contentModel.has(pathRefListContentKeyName)) {
                String pathRef = contentModel.getAsString(pathRefListContentKeyName);

                Collection<Map<String, Object>> pathList = new ArrayList<>();
                if (pathRef != null) {
                    Page page = pageManager.getContainingPage(pathRef);
                    int depth = LIST_DEFAULT_DEPTH;
                    String depthListContentKeyName = getDepthKeyName(resource);
                    if (contentModel.has(depthListContentKeyName)) {
                        depth =  Integer.parseInt(contentModel.getAsString(depthListContentKeyName));
                    }
                    if (null != page) {
                        String currentPage = contentModel.getAsString(PAGE + DOT + PATH);
                        boolean removeCurrentPage = false;
                        if (contentModel.has(REMOVE_CURRENT_PAGE_PATH_CONFIG_KEY) &&
                                contentModel.getAsString(REMOVE_CURRENT_PAGE_PATH_CONFIG_KEY).equals(TRUE)){
                            removeCurrentPage = true;
                        }
                        pathList = extractPathList(page, depth, currentPage, removeCurrentPage);
                    }
                }
                contentModel.set(LIST_PROPERTIES_KEY + DOT + PAGEREFS_CONTENT_KEY_NAME, pathList);
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:39,代码来源:AddTraversedPageReferencesContextProcessor.java

示例2: findContainingComponent

import org.apache.sling.api.resource.Resource; //导入方法依赖的package包/类
/**
 * Takes resource and returns component
 *
 * @param resource The resource to fetch the component from
 * @return null or component
 */
public static Component findContainingComponent(final Resource resource) {
    ResourceResolver resourceResolver = resource.getResourceResolver();
    ComponentManager componentManager = resourceResolver.adaptTo(ComponentManager.class);
    Resource componentResource = findParentAs(resource, NT_COMPONENT);
    if (componentResource != null) {
        String componentPath = componentResource.getPath();
        if (StringUtils.isNotBlank(componentPath)) {
            return componentManager.getComponent(componentPath);
        }
    }
    return null;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:19,代码来源:ResourceUtils.java

示例3: getDamAssetResource

import org.apache.sling.api.resource.Resource; //导入方法依赖的package包/类
/**
 * Looks for a fileReference property on the resource sent as argument and returns the DAM resource referenced.
 * @param resource a resource with a fileReference property.
 * @return the DAM asset resource referenced or null if the path stored in fileReference is invalid or the
 * fileReference property doesn't exist.
 */
public static Resource getDamAssetResource(Resource resource) {
    Resource damAssetResource = null;
    if(null != resource) {
        ResourceResolver resourceResolver = resource.getResourceResolver();
        String fileReference = ResourceUtils.getPropertyAsString(resource, FILE_REFERENCE);
        if(StringUtils.isNotEmpty(fileReference)) {
            damAssetResource = resourceResolver.getResource(fileReference);
        }
    }
    return damAssetResource;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:18,代码来源:ImageUtils.java

示例4: constructCategories

import org.apache.sling.api.resource.Resource; //导入方法依赖的package包/类
private void constructCategories(Resource pageContentResource) throws IOException {
    categories = Lists.newArrayList();
    final ResourceResolver resourceResolver = pageContentResource.getResourceResolver();
    final Resource patternsPathResource = resourceResolver.getResource(patternsPath);
    final Iterator<Resource> appsIterator = patternsPathResource.listChildren();
    while (appsIterator.hasNext()) {
        final PatternCategoryModel category = patternCategoryFactory.createCategory(appsIterator.next(), patternsPath, patternId);
        if (category != null && category.isValid()) {
            categories.add(category);
        }
    }
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:13,代码来源:PatternLabPageModel.java

示例5: JcrQueryIterator

import org.apache.sling.api.resource.Resource; //导入方法依赖的package包/类
public JcrQueryIterator(List<SelectorSegment> segments, Resource root, JcrTypeResolver typeResolver) {
	JcrQueryBuilder builder = new JcrQueryBuilder(typeResolver);
	query = builder.buildQuery(segments, root.getPath());
	resolver = root.getResourceResolver();
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:6,代码来源:JcrQueryIterator.java

示例6: findContainingPage

import org.apache.sling.api.resource.Resource; //导入方法依赖的package包/类
/**
 * Takes resource and returns page
 *
 * @param resource The resource to adapt into page
 * @return page
 */
public static Page findContainingPage(final Resource resource) {
    ResourceResolver resourceResolver = resource.getResourceResolver();
    final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
    return pageManager.getContainingPage(resource);
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:12,代码来源:ResourceUtils.java


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