本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}