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
public abstract class NodeTreeServlet extends AbstractServiceServlet
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NodeTreeServlet.DefaultTreeNodeStrategy
static class
NodeTreeServlet.LabelType
the possible tree name optionsstatic class
NodeTreeServlet.NodeParameters
the structure for parsing property values from JSON using Gsonstatic interface
NodeTreeServlet.TreeNodeStrategy
class
NodeTreeServlet.TreeOperation
creates 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.AbstractServiceServlet
DATE_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 Summary
Constructors Constructor Description NodeTreeServlet()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addVirtualContent(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType)
static String
getContentTypeKey(NodeTreeServlet.TreeNodeStrategy strategy, ResourceHandle resource, String prefix)
static String
getFileTypeKey(ResourceHandle resource, String prefix)
NodeTreeServlet.NodeParameters
getFormParameters(org.apache.sling.api.SlingHttpServletRequest request)
static String
getMimeTypeKey(ResourceHandle resource, String prefix)
static @NotNull String
getMimeTypeKey(String mimeType)
protected 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.String
getNodeLabel(ResourceHandle resource, NodeTreeServlet.LabelType labelType)
static String
getPrimaryTypeKey(ResourceHandle resource)
static String
getResourceTypeKey(ResourceHandle resource, String prefix)
String
getSortName(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 sortingvoid
writeJsonNode(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual)
void
writeJsonNodeData(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual)
String
writeNodeIdentifiers(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual)
void
writeNodeJcrState(com.google.gson.stream.JsonWriter writer, ResourceHandle resource)
void
writeNodeTreeType(com.google.gson.stream.JsonWriter writer, ResourceFilter filter, ResourceHandle resource, boolean isVirtual)
-
Methods inherited from class com.composum.sling.core.servlet.AbstractServiceServlet
deactivate, 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.SlingAllMethodsServlet
getAllowedRequestMethods, isMethodValid, mayService
-
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doGeneric, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
-
-
-
-
Method Detail
-
getNodeFilter
protected 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.
-
prepareTreeItems
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 sorting
-
writeJsonNode
public void writeJsonNode(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual) throws IOException
- Throws:
IOException
-
writeJsonNodeData
public void writeJsonNodeData(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual) throws IOException
- Throws:
IOException
-
writeNodeTreeType
public void writeNodeTreeType(com.google.gson.stream.JsonWriter writer, ResourceFilter filter, ResourceHandle resource, boolean isVirtual) throws IOException
- Throws:
IOException
-
addVirtualContent
public void addVirtualContent(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType) throws IOException
- Throws:
IOException
-
getSortName
public String getSortName(org.apache.sling.api.resource.Resource resource)
-
getNodeLabel
public String getNodeLabel(ResourceHandle resource, NodeTreeServlet.LabelType labelType)
-
writeNodeIdentifiers
public String writeNodeIdentifiers(com.google.gson.stream.JsonWriter writer, NodeTreeServlet.TreeNodeStrategy nodeStrategy, ResourceHandle resource, NodeTreeServlet.LabelType labelType, boolean isVirtual) throws IOException
- Throws:
IOException
-
writeNodeJcrState
public void writeNodeJcrState(com.google.gson.stream.JsonWriter writer, ResourceHandle resource) throws IOException
- Throws:
IOException
-
getFormParameters
public NodeTreeServlet.NodeParameters getFormParameters(org.apache.sling.api.SlingHttpServletRequest request)
-
getContentTypeKey
public static String getContentTypeKey(NodeTreeServlet.TreeNodeStrategy strategy, ResourceHandle resource, String prefix)
-
getPrimaryTypeKey
public static String getPrimaryTypeKey(ResourceHandle resource)
-
getResourceTypeKey
public static String getResourceTypeKey(ResourceHandle resource, String prefix)
-
getFileTypeKey
public static String getFileTypeKey(ResourceHandle resource, String prefix)
-
getMimeTypeKey
public static String getMimeTypeKey(ResourceHandle resource, String prefix)
-
-