• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java WCMUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.day.cq.wcm.commons.WCMUtils的典型用法代码示例。如果您正苦于以下问题:Java WCMUtils类的具体用法?Java WCMUtils怎么用?Java WCMUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WCMUtils类属于com.day.cq.wcm.commons包,在下文中一共展示了WCMUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: visit

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
@Override
protected void visit(Resource resource) {
    final ValueMap properties = resource.adaptTo(ValueMap.class);
    final String[] resourceViews = properties.get(WCMViewsFilter.PN_WCM_VIEWS, String[].class);

    if (ArrayUtils.isNotEmpty(resourceViews)) {
        this.views.addAll(Arrays.asList(resourceViews));
    }

    final Component component = WCMUtils.getComponent(resource);
    if (component != null) {
        final String[] componentViews = component.getProperties().get(WCMViewsFilter.PN_WCM_VIEWS, String[].class);

        if (ArrayUtils.isNotEmpty(componentViews)) {
            this.views.addAll(Arrays.asList(componentViews));
        }
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:19,代码来源:WCMViewsServlet.java


示例2: getComponentViews

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
/**
 * Get the WCM Views for the component; Looks at both the content resource for the special wcmViews property
 * and looks up to the resourceType's cq:Component properties for wcmViews.
 *
 * @param request the request
 * @return the WCM Views for the component
 */
private List<String> getComponentViews(final SlingHttpServletRequest request) {
    final Set<String> views = new HashSet<String>();
    final Resource resource = request.getResource();

    if (resource == null) {
        return new ArrayList<String>(views);
    }

    final Component component = WCMUtils.getComponent(resource);
    final ValueMap properties = resource.adaptTo(ValueMap.class);

    if (component != null) {
        views.addAll(Arrays.asList(component.getProperties().get(PN_WCM_VIEWS, new String[]{})));
    }

    if (properties != null) {
        views.addAll(Arrays.asList(properties.get(PN_WCM_VIEWS, new String[]{})));
    }

    return new ArrayList<String>(views);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:29,代码来源:WCMViewsFilter.java


示例3: process

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);

        ComponentContext componentContext = WCMUtils.getComponentContext(request);
        TemplateManager templateManager = request.getResourceResolver().adaptTo(TemplateManager.class);

        if (templateManager != null) {
            TemplatedContainer templatedContainer = new TemplatedContainer(templateManager, componentContext);

            if (templatedContainer.hasStructureSupport()) {
                List<Resource> structureResources = templatedContainer.getStructureResources();
                Map<String, Object> structureResourcesMap = new HashMap<>();

                for (Resource resource: structureResources) {
                    Map<String, String> resourceProperties = new HashMap<>();
                    resourceProperties.put("type", resource.getResourceType());
                    resourceProperties.put("path", resource.getPath());

                    structureResourcesMap.put(resource.getName(), resourceProperties);
                }
                contentModel.set(CONTENT + DOT + STRUCTURE_RESOURCES, structureResourcesMap);
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:31,代码来源:AddStructureResourcesContextProcessor.java


示例4: execute

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
@Override
public CharSequence execute(final Object valueObj)
        throws Exception {

    StringBuffer buffer = new StringBuffer();
    TemplateContentModelImpl contentModel = contentModel();
    SlingHttpServletRequest slingRequest = contentModel.request();

    WCMMode wcmMode = WCMMode.fromRequest(slingRequest);
    ClientLibraryUtil clientLibUtil = new ClientLibraryUtil(htmlLibraryManager, slingRequest);
    clientLibUtil.setOptions(true, true, false, false, false, BLANK);

    if (wcmMode != WCMMode.DISABLED) {
        ComponentContext componentContext = WCMUtils.getComponentContext(slingRequest);
        EditContext editContext = componentContext.getEditContext();
        String dlgPath = null;
        if (editContext != null && editContext.getComponent() != null) {
            dlgPath = editContext.getComponent().getDialogPath();
        }

        if (AuthoringUIMode.fromRequest(slingRequest) == AuthoringUIMode.TOUCH) {
            buffer.append(clientLibUtil.generateClientLibrariesPristine("cq.authoring.page"));
        } else
        if (AuthoringUIMode.fromRequest(slingRequest) == AuthoringUIMode.CLASSIC) {
            buffer.append(clientLibUtil.generateClientLibrariesPristine("cq.wcm.edit"));
            boolean isEditMode = (wcmMode == WCMMode.EDIT) ? true : false;
            String dialogPath = dlgPath == null ? "" : dlgPath;
            buffer.append(this.getJavaScript(slingRequest, isEditMode, dialogPath));
        }
    }

    return new Handlebars.SafeString(buffer);
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:34,代码来源:InitScriptHelperFunction.java


示例5: populatePageUrls

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
protected void populatePageUrls() {
    final String checkoutPageProperty = WCMUtils.getInheritedProperty(currentPage, resourceResolver,
            CommerceConstants.PN_CHECKOUT_PAGE_PATH);
    if (StringUtils.isNotEmpty(checkoutPageProperty)) {
        checkoutPage = resourceResolver.map(request, checkoutPageProperty) + ".html";
    }
    currentPageUrl = resourceResolver.map(request, currentPage.getPath() + ".html");
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:9,代码来源:NavCartModel.java


示例6: populatePageUrls

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
protected void populatePageUrls() {
    String checkoutPageProperty = WCMUtils.getInheritedProperty(currentPage, resourceResolver,
            CommerceConstants.PN_CHECKOUT_PAGE_PATH);
    if (StringUtils.isNotEmpty(checkoutPageProperty)) {
        checkoutPage = resourceResolver.map(request, checkoutPageProperty) + ".html";
    }

    currentPageUrl = resourceResolver.map(request, currentPage.getPath() + ".html");
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:10,代码来源:ShoppingCartModel.java


示例7: populatePages

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
private void populatePages() {
    String cartPageProperty = WCMUtils.getInheritedProperty(currentPage, resourceResolver, CommerceConstants.PN_CART_PAGE_PATH);
    if (StringUtils.isNotEmpty(cartPageProperty)) {
        cartPageUrl = resourceResolver.map(request, cartPageProperty) + ".html";
    } else {
        cartPageUrl = resourceResolver.map(request, currentPage.getPath() + ".html");
    }

    smartListUrl = resourceResolver.map(request, currentPage.getPath() + ".html");
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:11,代码来源:WishlistModel.java


示例8: getComponentContext

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
/**
 * Get the current component context.
 * 
 * @param adaptable a SlingHttpServletRequest
 * @return the ComponentContext if the adaptable was a SlingHttpServletRequest, or null otherwise
 */
private ComponentContext getComponentContext(Object adaptable) {
    if (adaptable instanceof SlingHttpServletRequest) {
        SlingHttpServletRequest request = ((SlingHttpServletRequest) adaptable);

        return WCMUtils.getComponentContext(request);
    }
    // ComponentContext is not reachable from Resource

    return null;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:AemObjectInjector.java


示例9: addBindings

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
@Override
public void addBindings(Bindings bindings) {
    Resource resource = (Resource) bindings.get("resource");
    Component component = WCMUtils.getComponent(resource);
    if (component != null) {
        if (pageRootProvider != null) {
            setSharedProperties(bindings, resource, component);
        } else {
            log.debug("Page Root Provider must be configured for shared component properties to be supported");
        }
        setMergedProperties(bindings, resource);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:SharedComponentPropertiesBindingsValuesProvider.java


示例10: doEndTag

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int doEndTag() throws JspException {
    SlingHttpServletRequest request = TagUtil.getRequest(pageContext);
    Component component = WCMUtils.getComponent(request.getResource());
    if (componentHelper.isEditMode(request)) {
        JspWriter writer = pageContext.getOut();
        String placeholder;

        String bodyContentString = bodyContent != null ? bodyContent.getString() : null;
        if (StringUtils.isNotBlank(bodyContentString)) {
            // use the body content as the default placeholder
            placeholder = Placeholder.getDefaultPlaceholder(request, component, bodyContentString, getDdClass());
        } else {
            String classicUIPlaceholder = componentHelper.generateClassicUIPlaceholder(getAllClassNames(), null);
            placeholder = Placeholder.getDefaultPlaceholder(request, component, classicUIPlaceholder, getDdClass());
        }

        try {
            writer.print(placeholder);
        } catch (IOException e) {
            throw new JspException(e);
        }

    }
    reset();
    return EVAL_PAGE;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:31,代码来源:PlaceholderTag.java


示例11: accepts

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
protected final boolean accepts(final SlingHttpServletRequest request, final SlingHttpServletResponse response) {

        if (!StringUtils.endsWith(request.getRequestURI(), ".html")
                || !StringUtils.contains(response.getContentType(), "html")) {
            // Do not inject around non-HTML requests
            return false;
        }

        final ComponentContext componentContext = WCMUtils.getComponentContext(request);
        if (componentContext == null // ComponentContext is null
                || componentContext.getComponent() == null // Component is null
                || componentContext.isRoot()) { // Suppress on root context
            return false;
        }

        // Check to make sure the suppress key has not been added to the request
        if (this.isComponentErrorHandlingSuppressed(request)) {
            // Suppress key is detected, skip handling

            return false;
        }

        // Check to make sure the SlingRequest's resource isn't in the suppress list
        final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
        for (final String suppressedResourceType : suppressedResourceTypes) {
            if (slingRequest.getResource().isResourceType(suppressedResourceType)) {
                return false;
            }
        }

        return true;
    }
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:33,代码来源:ComponentErrorHandlerImpl.java


示例12: HTMLResourceBasedTemplateLoader

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
public HTMLResourceBasedTemplateLoader(Resource resource)
        throws Exception {
    this.resource = resource;
    this.component = WCMUtils.getComponent(resource);
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:6,代码来源:HTMLResourceBasedTemplateLoader.java


示例13: getName

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
public String getName() {
  Page currentPage = WCMUtils.getComponentContext(request).getPage();
  return currentPage.getTitle();

}
 
开发者ID:sinnerschrader,项目名称:aem-react,代码行数:6,代码来源:CityViewModel.java


示例14: getComponentContext

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
private ComponentContext getComponentContext(final SlingHttpServletRequest request) {
  return WCMUtils.getComponentContext(request);
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:4,代码来源:AemObjectInjector.java


示例15: getDDEditBlock

import com.day.cq.wcm.commons.WCMUtils; //导入依赖的package包/类
@SuppressWarnings("squid:S3776")
public String getDDEditBlock(SlingHttpServletRequest request, String name,
        ComponentEditType.Type editType, boolean... isConfigured) {
    if (!isAuthoringMode(request) || conditionAndCheck(isConfigured)) {
        return null;
    }

    final Resource resource = request.getResource();
    final com.day.cq.wcm.api.components.Component component = WCMUtils.getComponent(resource);

    StringBuilder html = new StringBuilder();

    ComponentEditConfig editConfig = component.getEditConfig();
    Map<String, DropTarget> dropTargets = (editConfig != null) ? editConfig.getDropTargets() : null;

    if (dropTargets != null && !dropTargets.isEmpty()) {
        DropTarget dropTarget = null;

        // Find the named Drop Target
        for (final Map.Entry<String, DropTarget> entry : dropTargets.entrySet()) {
            dropTarget = entry.getValue();
            if (StringUtils.equals(name, dropTarget.getName())) {
                break;
            } else {
                dropTarget = null;
            }
        }

        if (dropTarget != null) {
            // If editType has not been specified then intelligently determine the best match
            editType = (editType == null) ? getWCMEditType(dropTarget) : editType;

            String classNames = dropTarget.getId() + " " + editType.getCssClass();
            String placeholderTitle = "Drop Target: " + dropTarget.getName();

            html.append(generateClassicUIPlaceholder(classNames, placeholderTitle));
        }
    }

    return html.toString();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:42,代码来源:ComponentHelperImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EmptyTypeDeclaration类代码示例发布时间:2022-05-22
下一篇:
Java PermissionUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap