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


Java SlingScriptHelper类代码示例

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


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

示例1: activate

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
@Override
@SuppressWarnings("checkstyle:parametername")
public void activate() throws Exception {
    SlingScriptHelper sling = getSlingScriptHelper();
    User user = sling.getRequest().getResourceResolver().adaptTo(User.class);
    ProcessDefinitionFactory[] allDefinitionFactories = sling.getServices(ProcessDefinitionFactory.class, null);
    definitions = Stream.of(allDefinitionFactories)
            .filter(o-> o.isAllowed(user))
            .collect(Collectors.toMap(ProcessDefinitionFactory::getName, o -> o, (a,b)->a, TreeMap::new));
    String processDefinitionName = get("processDefinition", String.class);
    if (StringUtils.isEmpty(processDefinitionName)) {
        processDefinitionName = getRequest().getParameter("processDefinition");
    }
    if (StringUtils.isNotEmpty(processDefinitionName) && definitions.containsKey(processDefinitionName)) {
        Class clazz = definitions.get(processDefinitionName).createProcessDefinition().getClass();
        fieldComponents = AnnotatedFieldDeserializer.getFormFields(clazz, sling);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:19,代码来源:AvailableProcessDefinitions.java

示例2: getFormFields

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
public static Map<String, FieldComponent> getFormFields(Class source, SlingScriptHelper sling) {
    return FieldUtils.getFieldsListWithAnnotation(source, FormField.class)
            .stream()
            .collect(Collectors.toMap(Field::getName, f -> {
                FormField fieldDefinition = f.getAnnotation(FormField.class);
                FieldComponent component;
                try {
                    component = fieldDefinition.component().newInstance();
                    component.setup(f.getName(), f, fieldDefinition, sling);
                    return component;
                } catch (InstantiationException | IllegalAccessException ex) {
                    log.error("Unable to instantiate field component for " + f.getName(), ex);
                }
                return null;
            }, (a, b) -> a, LinkedHashMap::new));
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:AnnotatedFieldDeserializer.java

示例3: createFrom

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
public static RenderContext createFrom(Bindings bindings, SlingScriptHelper slingScriptHelper) {
    final ScriptContext scriptContext = new SimpleScriptContext();
    scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
    final RenderContext renderContext = new RenderContextImpl(scriptContext, slingScriptHelper);
    renderContext.getBindings().putAll(bindings);
    return renderContext;
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:8,代码来源:RenderContextImpl.java

示例4: init

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
@Override
public void init(Bindings bindings) {
    final PrintWriter out = (PrintWriter) bindings.get(OUT_BINDING);
    final SlingHttpServletRequest request = (SlingHttpServletRequest) bindings.get(REQUEST_BINDING);
    final String template = (String) bindings.get(PatternLabConstants.TEMPLATE_PROPERTY);
    final String path = (String) bindings.get(PatternLabConstants.PATH_PROPERTY);
    final String data = (String) bindings.get(PatternLabConstants.DATA_PROPERTY);
    final SlingScriptHelper slingScriptHelper = (SlingScriptHelper) bindings.get(SLING_BINDING);
    final Map<String, Object> patternData = retrievePatternData(request, data);
    renderPattern(template, path, patternData, bindings, slingScriptHelper, out);
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:12,代码来源:RenderPatternUse.java

示例5: renderPattern

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
private void renderPattern(String template, String path, Map<String, Object> patternData, Bindings bindings, SlingScriptHelper slingScriptHelper,
                           PrintWriter out) {
    final RenderContext renderContext = RenderContextImpl.createFrom(bindings, slingScriptHelper);
    final PatternConfiguration patternConfiguration = PatternConfiguration.extractFromPatternData(patternData);
    final RenderUnit renderUnit = StringUtils.isNotBlank(template) ?
            new TemplateCallRenderUnit(path, template, patternData, patternConfiguration) :
            new IncludePatternRenderUnit(path, patternConfiguration);
    renderUnit.render(out, renderContext, bindings);
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:10,代码来源:RenderPatternUse.java

示例6: activate

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
/**
 * Initialization of the component.
 *
 * Reads the resource, gets the properties and site key.
 *
 * Options for "theme" are:
 * <ul>
 * <li>dark
 * <li>light (default)
 * </ul>
 *
 * Options for "type" are:
 * <ul>
 * <li>audio
 * <li>image (default)
 * </ul>
 *
 * Options for "size" are:
 * <ul>
 * <li>compact
 * <li>normal (default)
 * </ul>
 */
@Override
public void activate() {
    SlingScriptHelper scriptHelper = getSlingScriptHelper();
    RecaptchaService recaptchaService = scriptHelper.getService(RecaptchaService.class);

    if (recaptchaService == null) {
        show = false;
    } else {
        resource = getResource();

        ValueMap properties = resource.adaptTo(ValueMap.class);
        String sizeProperty = properties.get(SIZE_PROPERTY, String.class);
        String themeProperty = properties.get(THEME_PROPERTY, String.class);
        String typeProperty = properties.get(TYPE_PROPERTY, String.class);
        boolean enableProperty = properties.get(ENABLE_PROPERTY, true);

        boolean enableService = recaptchaService.getEnabled();
        siteKey = recaptchaService.getSiteKey();

        if (enableService && enableProperty && StringUtils.isNotBlank(siteKey)) {
            show = true;

            if (THEME_DARK.equals(themeProperty)) {
                theme = themeProperty;
            }

            if (TYPE_AUDIO.equals(typeProperty)) {
                type = typeProperty;
            }

            if (SIZE_COMPACT.equals(sizeProperty)) {
                size = sizeProperty;
            }
        } else {
            show = false;
        }
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:62,代码来源:Recaptcha.java

示例7: activate

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
/**
 * Sightly component initialization.
 */
@Override
public void activate() {
    resource = getResource();
    request = getRequest();
    resolver = getResourceResolver();
    listView = Arrays.asList(request.getRequestPathInfo().getSelectors()).contains(LIST_VIEW_SELECTOR);

    SlingScriptHelper scriptHelper = getSlingScriptHelper();
    linkRewriter = scriptHelper.getService(LinkRewriterService.class);

    getBlog(resource);
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:16,代码来源:BlogView.java

示例8: activate

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
@Override
public void activate() throws Exception {

    try {

        // get basic bindings and classes:
        SlingBindings bindings = (SlingBindings) getRequest().getAttribute(SlingBindings.class.getName());
        SlingScriptHelper sling = bindings.getSling();
        ConfigurationAdmin configAdmin = sling.getService(ConfigurationAdmin.class);

        // AEM Solr Search - Solr Configuration Service
        Configuration config = configAdmin.getConfiguration(SOLR_CONFIG_PID);
        Dictionary props = config.getProperties();

        if (props != null) {
            this.protocol = PropertiesUtil.toString(props.get(SOLR_CONFIG_PROTOCOL), "http");
            this.host = PropertiesUtil.toString(props.get(SOLR_CONFIG_HOST), "localhost");
            this.port = PropertiesUtil.toString(props.get(SOLR_CONFIG_PORT), "8080");
        } else {
            this.protocol = "http";
            this.host = "localhost";
            this.port = "8080";
        }

        // FIXME: this ideally shouldn't be hard coded
        this.updatePath = "/apps/infield/solr/updatehandler";

    } catch (Exception e) {

    }

}
 
开发者ID:infielddigital,项目名称:aem-id-solrindexer,代码行数:33,代码来源:osgi.java

示例9: setup

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
public final void setup(String name, Field javaField, FormField field, SlingScriptHelper sling) {
    this.name = name;
    this.formField = field;
    this.sling = sling;
    this.javaField = javaField;
    componentMetadata.put("name", name);
    componentMetadata.put("fieldLabel", formField.name());
    componentMetadata.put("fieldDescription", formField.description());
    componentMetadata.put("required", formField.required());
    componentMetadata.put("emptyText", formField.hint());
    getOption("default").ifPresent(val->componentMetadata.put("value", val));
    init();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:FieldComponent.java

示例10: syntheticResourceTest

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
@Test
public void syntheticResourceTest() throws DeserializeException {
    SlingHttpServletRequest mockRequest = mock(SlingHttpServletRequest.class);
    SlingScriptHelper mockScriptHelper = mock(SlingScriptHelper.class);
    when(mockScriptHelper.getRequest()).thenReturn(mockRequest);
    Map<String, FieldComponent> form = AnnotatedFieldDeserializer.getFormFields(getClass(), mockScriptHelper);
    assertNotNull(form.get("textComponentTest"));
    Resource fieldResource = form.get("textComponentTest").buildComponentResource();
    assertEquals("granite/ui/components/coral/foundation/form/textfield", fieldResource.getResourceType());
    assertEquals("granite/ui/components/coral/foundation/form/field", fieldResource.getResourceSuperType());
    assertEquals("textComponentTest", fieldResource.getResourceMetadata().get("name"));
    assertEquals("Text component", fieldResource.getResourceMetadata().get("fieldLabel"));
    assertEquals(true, fieldResource.getResourceMetadata().get("required"));
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:15,代码来源:SyntheticFormResourceTest.java

示例11: setPageContext

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
@Override
public void setPageContext(PageContext pageContext) {

	super.setPageContext(pageContext);
	sling = (SlingScriptHelper) pageContext.findAttribute("sling");
	currentNode = (Node) pageContext.findAttribute("currentNode");
	webResourceScriptCache = sling.getService(WebResourceScriptCache.class);
}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:9,代码来源:WebResourceTag.java

示例12: RenderContextImpl

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
private RenderContextImpl(ScriptContext scriptContext, SlingScriptHelper helper) {
    bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
    extensionRegistryService = helper.getService(ExtensionRegistryService.class);
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:5,代码来源:RenderContextImpl.java

示例13: getSlingScriptHelper

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
@Override
public SlingScriptHelper getSlingScriptHelper() {
	return slingScriptHelper();
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:5,代码来源:AemClient.java

示例14: getHelper

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
public SlingScriptHelper getHelper() {
    return sling;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:4,代码来源:FieldComponent.java

示例15: getSlingScriptHelper

import org.apache.sling.api.scripting.SlingScriptHelper; //导入依赖的package包/类
/**
 * Get the Sling script helper instance used by the SlingMock layer.
 *
 * @return script helper instance; never null
 */
SlingScriptHelper getSlingScriptHelper();
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:7,代码来源:IAemClient.java


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