Class AbstractServiceServlet

    • Constructor Detail

      • AbstractServiceServlet

        public AbstractServiceServlet()
    • Method Detail

      • deactivate

        protected void deactivate()
      • 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:
        doGet in class org.apache.sling.api.servlets.SlingSafeMethodsServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • 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:
        doPost in class org.apache.sling.api.servlets.SlingAllMethodsServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • 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:
        doPut in class org.apache.sling.api.servlets.SlingAllMethodsServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • 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:
        doDelete in class org.apache.sling.api.servlets.SlingAllMethodsServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • 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
      • getJsonObject

        public static <T> T getJsonObject​(String input,
                                          Class<T> type)