Package com.composum.sling.core.servlet
Class NodeTreeServlet
- java.lang.Object
- 
- javax.servlet.GenericServlet
- 
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
- 
- org.apache.sling.api.servlets.SlingAllMethodsServlet
- 
- com.composum.sling.core.servlet.AbstractServiceServlet
- 
- com.composum.sling.core.servlet.NodeTreeServlet
 
 
 
 
 
- 
- All Implemented Interfaces:
- RestrictedService,- Serializable,- javax.servlet.Servlet,- javax.servlet.ServletConfig
 - Direct Known Subclasses:
- NodeServlet
 
 public abstract class NodeTreeServlet extends AbstractServiceServlet - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classNodeTreeServlet.DefaultTreeNodeStrategystatic classNodeTreeServlet.LabelTypethe possible tree name optionsstatic classNodeTreeServlet.NodeParametersthe structure for parsing property values from JSON using Gsonstatic interfaceNodeTreeServlet.TreeNodeStrategyclassNodeTreeServlet.TreeOperationcreates a JSON object for the requested node (requested by the suffix); this JSON response contains the node identifiers, some node type hints and a list of the children of the node; this operation provides the data for a tree implementation which requests the nodes on demand suffix: the path to the node selectors / parameters: - 'label': 'name' or 'title' - selects the value to use for the nodes 'text' attribute URL examples: - http://host/bin/cpm/nodes/node.tree.json/path/to/the/node - http://host/bin/cpm/nodes/node.tree.title.json/path/to/the/node - http://host/bin/cpm/nodes/node.tree.json/path/to/the/node?label=title
 - 
Field Summary- 
Fields inherited from class com.composum.sling.core.servlet.AbstractServiceServletDATE_FORMAT, PARAM_BEFORE, PARAM_CMD, PARAM_FILE, PARAM_FILTER, PARAM_ID, PARAM_INDEX, PARAM_JCR_CONTENT, PARAM_LABEL, PARAM_MIME_TYPE, PARAM_NAME, PARAM_PATH, PARAM_QUERY, PARAM_RESOURCE_TYPE, PARAM_TITLE, PARAM_TYPE, PARAM_URL, PARAM_VALUE, PARAM_VERSION
 
- 
 - 
Constructor SummaryConstructors Constructor Description NodeTreeServlet()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddVirtualContent(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType)static StringgetContentTypeKey(NodeTreeServlet.TreeNodeStrategy strategy, ResourceHandle resource, String prefix)static StringgetFileTypeKey(ResourceHandle resource, String prefix)NodeTreeServlet.NodeParametersgetFormParameters(org.apache.sling.api.SlingHttpServletRequest request)static StringgetMimeTypeKey(ResourceHandle resource, String prefix)static @NotNull StringgetMimeTypeKey(String mimeType)protected abstract ResourceFiltergetNodeFilter(org.apache.sling.api.SlingHttpServletRequest request)Determines the filter to use for node retrieval; scans the request for filter parameter or selector.StringgetNodeLabel(ResourceHandle resource, NodeTreeServlet.LabelType labelType)static StringgetPrimaryTypeKey(ResourceHandle resource)static StringgetResourceTypeKey(ResourceHandle resource, String prefix)StringgetSortName(org.apache.sling.api.resource.Resource resource)protected List<org.apache.sling.api.resource.Resource>prepareTreeItems(ResourceHandle resource, List<org.apache.sling.api.resource.Resource> items)extension hook for additional filters or sortingvoidwriteJsonNode(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual)voidwriteJsonNodeData(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual)StringwriteNodeIdentifiers(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual)voidwriteNodeJcrState(com.google.gson.stream.JsonWriter writer, ResourceHandle resource)voidwriteNodeTreeType(com.google.gson.stream.JsonWriter writer, ResourceFilter filter, ResourceHandle resource, boolean isVirtual)- 
Methods inherited from class com.composum.sling.core.servlet.AbstractServiceServletdeactivate, doDelete, doGet, doPost, doPut, getJsonObject, getJsonObject, getJsonObject, getOperations, getPath, getResource, getRestrictions, getServiceKey, isEnabled, jsonAnswerItemExists, jsonValue, methodDeletePermission, methodGetPermission, methodPostPermission, methodPutPermission, setNoCacheHeaders, tryToUseRawSuffix
 - 
Methods inherited from class org.apache.sling.api.servlets.SlingAllMethodsServletgetAllowedRequestMethods, isMethodValid, mayService
 - 
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServletdoGeneric, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
 
- 
 
- 
- 
- 
Method Detail- 
getNodeFilterprotected abstract ResourceFilter getNodeFilter(org.apache.sling.api.SlingHttpServletRequest request) Determines the filter to use for node retrieval; scans the request for filter parameter or selector.
 - 
prepareTreeItemsprotected List<org.apache.sling.api.resource.Resource> prepareTreeItems(ResourceHandle resource, List<org.apache.sling.api.resource.Resource> items) extension hook for additional filters or sorting
 - 
writeJsonNodepublic void writeJsonNode(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual) throws IOException- Throws:
- IOException
 
 - 
writeJsonNodeDatapublic void writeJsonNodeData(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual) throws IOException- Throws:
- IOException
 
 - 
writeNodeTreeTypepublic void writeNodeTreeType(com.google.gson.stream.JsonWriter writer, ResourceFilter filter, ResourceHandle resource, boolean isVirtual) throws IOException- Throws:
- IOException
 
 - 
addVirtualContentpublic void addVirtualContent(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType) throws IOException- Throws:
- IOException
 
 - 
getSortNamepublic String getSortName(org.apache.sling.api.resource.Resource resource) 
 - 
getNodeLabelpublic String getNodeLabel(ResourceHandle resource, NodeTreeServlet.LabelType labelType) 
 - 
writeNodeIdentifierspublic String writeNodeIdentifiers(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual) throws IOException - Throws:
- IOException
 
 - 
writeNodeJcrStatepublic void writeNodeJcrState(com.google.gson.stream.JsonWriter writer, ResourceHandle resource) throws IOException- Throws:
- IOException
 
 - 
getFormParameterspublic NodeTreeServlet.NodeParameters getFormParameters(org.apache.sling.api.SlingHttpServletRequest request) 
 - 
getContentTypeKeypublic static String getContentTypeKey(NodeTreeServlet.TreeNodeStrategy strategy, ResourceHandle resource, String prefix) 
 - 
getPrimaryTypeKeypublic static String getPrimaryTypeKey(ResourceHandle resource) 
 - 
getResourceTypeKeypublic static String getResourceTypeKey(ResourceHandle resource, String prefix) 
 - 
getFileTypeKeypublic static String getFileTypeKey(ResourceHandle resource, String prefix) 
 - 
getMimeTypeKeypublic static String getMimeTypeKey(ResourceHandle resource, String prefix) 
 
- 
 
-