Package com.composum.sling.core.servlet
Class AbstractServiceServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
-
- org.apache.sling.api.servlets.SlingAllMethodsServlet
-
- com.composum.sling.core.servlet.AbstractServiceServlet
-
- All Implemented Interfaces:
RestrictedService,Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
ComponentsServlet,JobControlServlet,NodeTreeServlet,PackageServlet,PropertyServlet,SceneServlet,SecurityServlet,SetupServlet,SystemServlet,TranslationServlet,UserManagementServlet,VersionServlet
public abstract class AbstractServiceServlet extends org.apache.sling.api.servlets.SlingAllMethodsServlet implements RestrictedService
A basic class for all '/bin/{service}/path/to/resource' servlets.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDATE_FORMATstatic StringPARAM_BEFOREstatic StringPARAM_CMDstatic StringPARAM_FILEstatic StringPARAM_FILTERstatic StringPARAM_IDstatic StringPARAM_INDEXstatic StringPARAM_JCR_CONTENTstatic StringPARAM_LABELstatic StringPARAM_MIME_TYPEstatic StringPARAM_NAMEstatic StringPARAM_PATHstatic StringPARAM_QUERYstatic StringPARAM_RESOURCE_TYPEstatic StringPARAM_TITLEstatic StringPARAM_TYPEstatic StringPARAM_URLstatic StringPARAM_VALUEstatic StringPARAM_VERSION
-
Constructor Summary
Constructors Constructor Description AbstractServiceServlet()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddeactivate()protected voiddoDelete(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)protected voiddoGet(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)protected voiddoPost(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)protected voiddoPut(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)static <T> TgetJsonObject(String input, Class<T> type)static <T> TgetJsonObject(org.apache.sling.api.SlingHttpServletRequest request, Class<T> type)static <T> TgetJsonObject(org.apache.sling.api.SlingHttpServletRequest request, Class<T> type, com.google.gson.InstanceCreator<T> instanceCreator)protected abstract @NotNull ServletOperationSet<?,?>getOperations()Each servlet implementation must provide access to its operation set for request delegation.static StringgetPath(org.apache.sling.api.SlingHttpServletRequest request)static @NotNull ResourceHandlegetResource(org.apache.sling.api.SlingHttpServletRequest request)Retrieves the resource using the suffix from the request.protected ServiceRestrictionsgetRestrictions()ServiceRestrictions.KeygetServiceKey()protected booleanisEnabled(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, ServiceRestrictions.Permission needed)protected voidjsonAnswerItemExists(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)static voidjsonValue(com.google.gson.stream.JsonWriter writer, Object value)protected ServiceRestrictions.PermissionmethodDeletePermission(@NotNull org.apache.sling.api.SlingHttpServletRequest request)protected ServiceRestrictions.PermissionmethodGetPermission(@NotNull org.apache.sling.api.SlingHttpServletRequest request)protected ServiceRestrictions.PermissionmethodPostPermission(@NotNull org.apache.sling.api.SlingHttpServletRequest request)protected ServiceRestrictions.PermissionmethodPutPermission(@NotNull org.apache.sling.api.SlingHttpServletRequest request)static voidsetNoCacheHeaders(@NotNull org.apache.sling.api.SlingHttpServletResponse response)static @NotNull ResourceHandletryToUseRawSuffix(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull ResourceHandle resource)-
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
-
-
-
-
Field Detail
-
PARAM_FILE
public static final String PARAM_FILE
- See Also:
- Constant Field Values
-
PARAM_CMD
public static final String PARAM_CMD
- See Also:
- Constant Field Values
-
PARAM_FILTER
public static final String PARAM_FILTER
- See Also:
- Constant Field Values
-
PARAM_ID
public static final String PARAM_ID
- See Also:
- Constant Field Values
-
PARAM_INDEX
public static final String PARAM_INDEX
- See Also:
- Constant Field Values
-
PARAM_JCR_CONTENT
public static final String PARAM_JCR_CONTENT
- See Also:
- Constant Field Values
-
PARAM_LABEL
public static final String PARAM_LABEL
- See Also:
- Constant Field Values
-
PARAM_MIME_TYPE
public static final String PARAM_MIME_TYPE
- See Also:
- Constant Field Values
-
PARAM_NAME
public static final String PARAM_NAME
- See Also:
- Constant Field Values
-
PARAM_PATH
public static final String PARAM_PATH
- See Also:
- Constant Field Values
-
PARAM_BEFORE
public static final String PARAM_BEFORE
- See Also:
- Constant Field Values
-
PARAM_QUERY
public static final String PARAM_QUERY
- See Also:
- Constant Field Values
-
PARAM_RESOURCE_TYPE
public static final String PARAM_RESOURCE_TYPE
- See Also:
- Constant Field Values
-
PARAM_TITLE
public static final String PARAM_TITLE
- See Also:
- Constant Field Values
-
PARAM_TYPE
public static final String PARAM_TYPE
- See Also:
- Constant Field Values
-
PARAM_URL
public static final String PARAM_URL
- See Also:
- Constant Field Values
-
PARAM_VALUE
public static final String PARAM_VALUE
- See Also:
- Constant Field Values
-
PARAM_VERSION
public static final String PARAM_VERSION
- See Also:
- Constant Field Values
-
DATE_FORMAT
public static final String DATE_FORMAT
- See Also:
- Constant Field Values
-
-
Method Detail
-
deactivate
protected void deactivate()
-
getRestrictions
protected ServiceRestrictions getRestrictions()
-
getServiceKey
public ServiceRestrictions.Key getServiceKey()
- Specified by:
getServiceKeyin interfaceRestrictedService
-
isEnabled
protected boolean isEnabled(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, @NotNull ServiceRestrictions.Permission needed)
-
methodGetPermission
@NotNull protected ServiceRestrictions.Permission methodGetPermission(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request)
-
methodPostPermission
@NotNull protected ServiceRestrictions.Permission methodPostPermission(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request)
-
methodPutPermission
@NotNull protected ServiceRestrictions.Permission methodPutPermission(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request)
-
methodDeletePermission
@NotNull protected ServiceRestrictions.Permission methodDeletePermission(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request)
-
getOperations
@NotNull protected abstract @NotNull ServletOperationSet<?,?> getOperations()
Each servlet implementation must provide access to its operation set for request delegation.
-
doGet
protected void doGet(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
doGetin classorg.apache.sling.api.servlets.SlingSafeMethodsServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doPost
protected void doPost(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
doPostin classorg.apache.sling.api.servlets.SlingAllMethodsServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doPut
protected void doPut(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
doPutin classorg.apache.sling.api.servlets.SlingAllMethodsServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doDelete
protected void doDelete(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
doDeletein classorg.apache.sling.api.servlets.SlingAllMethodsServlet- Throws:
javax.servlet.ServletExceptionIOException
-
setNoCacheHeaders
public static void setNoCacheHeaders(@NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response)
-
getResource
@NotNull public static @NotNull ResourceHandle getResource(org.apache.sling.api.SlingHttpServletRequest request)
Retrieves the resource using the suffix from the request.- Parameters:
request- the sling request with the resource path in the suffix- Returns:
- the resource (NOT
null; returns a handle with an invalid resource if not resolvable)
-
getPath
public static String getPath(org.apache.sling.api.SlingHttpServletRequest request)
-
tryToUseRawSuffix
@NotNull public static @NotNull ResourceHandle tryToUseRawSuffix(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull ResourceHandle resource)
- Returns:
- the given resource if valid, otherwise the resource referenced by the raw suffix (no XSS filter) if such a resource is available - to support select and rename of nodes with invalid names (node repair)
-
jsonAnswerItemExists
protected void jsonAnswerItemExists(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response) throws IOException- Throws:
IOException
-
jsonValue
public static void jsonValue(com.google.gson.stream.JsonWriter writer, Object value) throws IOException- Throws:
IOException
-
getJsonObject
public static <T> T getJsonObject(org.apache.sling.api.SlingHttpServletRequest request, Class<T> type) throws IOException- Throws:
IOException
-
getJsonObject
public static <T> T getJsonObject(org.apache.sling.api.SlingHttpServletRequest request, Class<T> type, com.google.gson.InstanceCreator<T> instanceCreator) throws IOException- Throws:
IOException
-
-