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


Java Mode类代码示例

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


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

示例1: process

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        Configuration config = configurationProvider.getFor(request.getResource().getResourceType());
        Collection<String> propsWithJSONValues = config.asStrings(XK_DESERIALIZE_JSON_PROPS_CP, Mode.MERGE);

        for(String propName : propsWithJSONValues) {
            if(contentModel.has(propName)) {
                String jsonString = contentModel.getAsString(propName);
                if(JSONValue.isValidJson(jsonString)) {
                    Object value = JSONValue.parse(jsonString);
                    contentModel.set(propName, value);
                }
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:22,代码来源:DeserializeJSONPropertyValuesContextProcessor.java

示例2: valuesFor

import danta.api.configuration.Mode; //导入依赖的package包/类
private Collection<Value> valuesFor(String paramName, Mode mode)
        throws Exception {

    Collection<Value> values = Collections.emptyList();

    switch (mode) {
        case INHERIT:
            values = getInherited(paramName);
            break;
        case MERGE:
            values = getMerged(paramName);
            break;
        case COMBINE:
            values = getCombined(paramName);
            break;
        case SHALLOW:
            values = getShallow(paramName);
            break;
        default:
            break;
    }
    return values;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:24,代码来源:AEMConfigurationProviderImpl.java

示例3: process

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, TemplateContentModelImpl contentModel)
        throws ProcessException {
    try {
        Resource resource = (Resource) executionContext.get(JAHIA_RESOURCE);
        Configuration configuration = configurationProvider.getFor(resource);
        Collection<String> propsWithJSONValues = configuration.asStrings(XK_DESERIALIZE_JSON_PROPS_CP, Mode.MERGE);

        for(String propName : propsWithJSONValues) {
            if(contentModel.has(propName)) {
                String jsonString = contentModel.getAsString(propName);
                if(JSONValue.isValidJson(jsonString)) {
                    Object value = JSONValue.parse(jsonString);
                    contentModel.set(propName, value);
                }
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:22,代码来源:DeserializeJSONPropertyValuesContextProcessor.java

示例4: process

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, TemplateContentModel contentModel)
        throws ProcessException {
    try {
        Resource resource = (Resource) executionContext.get(JAHIA_RESOURCE);
        Configuration configuration = configurationProvider.getFor(resource);

        Collection<String> listClasses = configuration.asStrings(LIST_CLASSES_CONFIG_PROP, Mode.MERGE);
        contentModel.set(LIST_PROPERTIES_KEY + "." + LIST_CLASSES_PROP, listClasses);
        Collection<String> itemClasses = configuration.asStrings(LIST_ITEM_CLASSES_CONFIG_PROP, Mode.MERGE);
        contentModel.set(LIST_PROPERTIES_KEY + "." + LIST_ITEM_CLASSES_PROP, itemClasses);

    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:17,代码来源:AddItemListConfigsContextProcessor.java

示例5: valuesFor

import danta.api.configuration.Mode; //导入依赖的package包/类
private Collection<Object> valuesFor(String paramName, Mode mode)
        throws Exception {

    Collection<Object> values = Collections.emptyList();

    switch (mode) {
        case INHERIT:
            values = getInherited(paramName);
            break;
        case MERGE:
            values = getMerged(paramName);
            break;
        case COMBINE:
            values = getCombined(paramName);
            break;
        case SHALLOW:
            values = getShallow(paramName);
            break;
        default:
            break;
    }
    return values;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:24,代码来源:JahiaConfigurationProviderImpl.java

示例6: asStrings

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public List<String> asStrings(String paramName, Mode mode) throws Exception {
    Collection<Object> collection = valuesFor(paramName, mode);
    List<String> list = new LinkedList<>();
    for (Object obj : collection) {
        if (obj instanceof JSONArray) {
            JSONArray jsonArray = (JSONArray) obj;
            for (int i = 0; i < jsonArray.size(); i++) {
                Object objFinal = jsonArray.get(i);
                if (objFinal instanceof String) {
                    String value = (String) objFinal;
                    list.add(value);
                }
            }
        }
    }
    return list;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:19,代码来源:JahiaConfigurationProviderImpl.java

示例7: doGet

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    PrintWriter out = response.getWriter();

    try {
        Resource resource = request.getResource();
        if (resource != null && configurationProvider.hasConfig(resource.getResourceType())) {
            JSONObject filteredContentMap = new JSONObject();
            TemplateContentModel templateContentModel = (TemplateContentModel) contentModelFactoryService.getContentModel(request, response);

            boolean clientAccessible =  (Boolean) templateContentModel.get(CONFIG_PROPERTIES_KEY + DOT + XK_CLIENT_ACCESSIBLE_CP);
            if (clientAccessible) {
                // get list of contexts
                Configuration configuration = configurationProvider.getFor(resource.getResourceType());
                Collection<String> props = configuration.asStrings(XK_CLIENT_MODEL_PROPERTIES_CP, Mode.MERGE);
                String[] contexts = props.toArray(new String[0]);

                // get content model json with the XK_CLIENT_MODEL_PROPERTIES_CP contexts
                filteredContentMap = templateContentModel.toJSONObject(contexts);

                // add component id
                String componentContentId = DigestUtils.md5Hex(resource.getPath());
                filteredContentMap.put(XK_CONTENT_ID_CP, componentContentId);
            }
            out.write(JSONObject.toJSONString(filteredContentMap));
        } else {
            out.write(new JSONObject().toJSONString());
        }
    } catch (Exception ew) {
        throw new ServletException(ew);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:34,代码来源:ComponentContentModelToJSONServlet.java

示例8: doGet

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    PrintWriter out = response.getWriter();

    try {
        Resource resource = request.getResource();
        if (resource != null && configurationProvider.hasConfig(resource.getResourceType())) {
            JSONObject filteredContentMap = new JSONObject();
            TemplateContentModel templateContentModel = (TemplateContentModel) contentModelFactoryService.getContentModel(request, response);

            boolean clientAccessible =  (Boolean) templateContentModel.get(CONFIG_PROPERTIES_KEY + DOT + XK_CLIENT_ACCESSIBLE_CP);
            if (clientAccessible) {
                // get list of contexts
                Configuration configuration = configurationProvider.getFor(resource.getResourceType());
                Collection<String> props = configuration.asStrings(XK_CLIENT_MODEL_PROPERTIES_CP, Mode.MERGE);
                String[] contexts = props.toArray(new String[0]);

                // get content model json with the XK_CLIENT_MODEL_PROPERTIES_CP contexts
                filteredContentMap = templateContentModel.toJSONObject(contexts);

                // add component id
                String componentContentId = DigestUtils.md5Hex(resource.getPath());
                filteredContentMap.put(XK_CONTENT_ID_CP, componentContentId);
            }

            // add component list with clientaccessible as true on the resource page
            filteredContentMap.put(PAGE_COMPONENT_RESOURCE_LIST_AN, getComponentList(resource));

            out.write(JSONObject.toJSONString(filteredContentMap));
        } else {
            out.write(new JSONObject().toJSONString());
        }
    } catch (Exception ew) {
        throw new ServletException(ew);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:38,代码来源:PageContentModelToJSONServlet.java

示例9: process

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModel contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        Resource resource = request.getResource();

        Configuration config = configurationProvider.getFor(request.getResource().getResourceType());
        Collection<String> models = config.asStrings(SLING_MODELS_CONFIG_PROPERTY_NAME, Mode.MERGE);

        Object model;
        String modelName = "";
        Map<String, Object> modelData = new HashMap<>();

        for (String modelId : models) {
            Class<?> modelClass= Class.forName(modelId);

            if (modelFactory.isModelClass(modelClass)) {
                model = resource.adaptTo(modelClass);
                modelData = getModelProperties(model);
                modelName =  modelClass.getSimpleName();
                contentModel.set(SLING_MODEL_PROPERTIES_KEY + DOT + modelName, modelData);
            } else {
                log.error("{} is not a Sling Model", modelClass);
            }
        }

    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:32,代码来源:AddSlingModelsPropertiesContextProcessor.java

示例10: process

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        Configuration config = configurationProvider.getFor(request.getResource().getResourceType());
        Map<String, Object> styling = new HashMap<>();
        Collection<String> containerClasses = config.asStrings(XK_CONTAINER_CLASSES_CP, Mode.MERGE);
        if(contentModel.has(PAGE_PROPERTIES_KEY) && contentModel.getAs(PAGE_PROPERTIES_KEY + "." + IS_EDIT_OR_DESIGN_MODE, Boolean.class)) {
            Collection<String> triggers = config.asStrings(XK_PLACEHOLDER_TRIGGERS_CP, Mode.SHALLOW);
            if (triggers != null && !triggers.isEmpty()) {
                boolean displayPlaceholder = true;
                for (String triggerProp : triggers) {
                    String propVal = contentModel.getAsString(triggerProp);
                    if (StringUtils.isNotEmpty(propVal)) {
                        displayPlaceholder = false;
                        break;
                    }
                }
                if (displayPlaceholder) {
                    styling.put(DISPLAY_PLACEHOLDER_STYLING_PROPERTY_NAME, DISPLAY_PLACEHOLDER_CSSN);
                    containerClasses.add(DISPLAY_PLACEHOLDER_CSSN);
                }
            }
        }
        styling.put(CONTAINER_CLASSES_CP, containerClasses);
        StringBuffer stylingString = new StringBuffer();
        for (String className : containerClasses) {
            stylingString.append(className).append(SPACE);
        }
        styling.put(CONTAINER_STYLING_CSSN_AV, stylingString.toString());
        contentModel.set(STYLING_PROPERTIES_KEY, styling);

    } catch (Exception e) {
        throw new ProcessException(e);
    }

}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:39,代码来源:AddStylingContextProcessor.java

示例11: process

import danta.api.configuration.Mode; //导入依赖的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();
        Configuration configuration = configurationProvider.getFor(resource.getResourceType());
        Collection<String> listClasses = configuration.asStrings(LIST_CLASSES_CONFIG_PROP, Mode.MERGE);
        contentModel.set(LIST_PROPERTIES_KEY + "." + LIST_CLASSES_PROP, listClasses);
        Collection<String> itemClasses = configuration.asStrings(LIST_ITEM_CLASSES_CONFIG_PROP, Mode.MERGE);
        contentModel.set(LIST_PROPERTIES_KEY + "." + LIST_ITEM_CLASSES_PROP, itemClasses);
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:16,代码来源:AddItemListConfigsContextProcessor.java

示例12: doExecute

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource,
                              JCRSessionWrapper session, Map<String, List<String>> parameters,
                              URLResolver urlResolver) throws Exception {
    JSONObject jsonObject = new JSONObject();
    final HttpServletResponse response = renderContext.getResponse();

    try {
        TemplateContentModel contentModel = (TemplateContentModel) contentModelFactoryService.getContentModel(
                req, response, renderContext, resource);
        Configuration configuration = configurationProvider.getFor(resource);
        Map<String, Object> config = contentModel.getAs(CONFIG_PROPERTIES_KEY, Map.class);
        boolean clientAccessible = Boolean.valueOf(config.get(XK_CLIENT_ACCESSIBLE_CP) + BLANK);
        if (clientAccessible) {
            Collection<String> props = configuration.asStrings(XK_CLIENT_MODEL_PROPERTIES_CP, Mode.MERGE);
            String[] contexts = props.toArray(new String[props.size()]);

            // Get content model json with the XK_CLIENT_MODEL_PROPERTIES_CP contexts
            jsonObject = contentModel.toJSONObject(contexts);

            // Add component id
            String componentContentId = DigestUtils.md5Hex(resource.getPath());
            jsonObject.put(XK_CONTENT_ID_CP, componentContentId);
        }
    } catch (Exception ew) {
            throw new ServletException(ew);
    }

    response.setContentType(SERVER_RESPONSE_CONTENT_TYPE);
    response.getWriter().write( jsonObject.toString() );

    return ActionResult.OK;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:34,代码来源:ComponentContentModelToJSONActionServlet.java

示例13: process

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModel contentModel)throws ProcessException {
    try {
        Resource resource = (Resource) executionContext.get(JAHIA_RESOURCE);
        HttpServletRequest request = (HttpServletRequest) executionContext.get(HTTP_REQUEST);

        if (resource != null && configurationProvider != null) {

            Configuration configuration = configurationProvider.getFor(resource);
            Map<String, Object> config = contentModel.getAs(CONFIG_PROPERTIES_KEY, Map.class);
            Map<String, Object> filteredContentMap = new TreeMap<>();
            String componentContentId = DigestUtils.md5Hex(resource.getPath());

            boolean clientAccessible = Boolean.valueOf(config.get(XK_CLIENT_ACCESSIBLE_CP) + BLANK);
            if (clientAccessible) {
                filteredContentMap.put(XK_CONTENT_ID_CP, componentContentId);
                Collection<String> props = configuration.asStrings(XK_CLIENT_MODEL_PROPERTIES_CP, Mode.MERGE);
                for (String propName : props) {
                    Object value = contentModel.get(propName);
                    if (value != null) {
                        filteredContentMap.put(propName, value);
                    }
                }
            }
            //request.setAttribute(CLIENT_COMPONENT_CONTENT_MODEL_REQ_AN, filteredContentMap);
        }
    } catch (Exception e) {
        LOG.error(LOG_PRE + " Error : ",e);
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:32,代码来源:GenerateClientComponentContentModelContextProcessor.java

示例14: asString

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public String asString(String paramName, Mode mode)
        throws Exception {
    Collection<Object> collection = valuesFor(paramName, mode);
    if(collection.size() > 0) {
        Object obj = collection.iterator().next();
        if (obj instanceof String) {
            String value = (String) obj;

            return value;
        }
    }

    return BLANK;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:16,代码来源:JahiaConfigurationProviderImpl.java

示例15: asNumbers

import danta.api.configuration.Mode; //导入依赖的package包/类
@Override
public List<Number> asNumbers(String paramName, Mode mode) throws Exception {
    Collection<Object> collection = valuesFor(paramName, mode);
    List<Number> list = new LinkedList<>();
    for (Object obj : collection) {
        if (obj instanceof Number) {
            Number value = (Number) obj;
            list.add(value);
        }
    }
    return list;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:13,代码来源:JahiaConfigurationProviderImpl.java


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