Interface ErrorPageHandlerService


  • @ProviderType
    public interface ErrorPageHandlerService
    Error Page Handling Service which facilitates the resolution of errors against authorable pages for discrete content trees. This service is used via the ACS-AEM-Commons error page handler implementation to create author-able error pages.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean doHandle404​(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
      Determine is the request is a 404 and if so handles the request appropriately base on some CQ idiosyncrasies .
      String findErrorPage​(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.resource.Resource errorResource)
      Find the JCR full path to the most appropriate Error Page
      String getErrorPageName​(org.apache.sling.api.SlingHttpServletRequest request)
      Get the Error Page's name (all lowercase) that should be used to render the page for this error.
      String getException​(org.apache.sling.api.SlingHttpServletRequest request)
      Returns the Exception Message (Stacktrace) from the Request
      String getRequestProgress​(org.apache.sling.api.SlingHttpServletRequest request)
      Returns a String representation of the RequestProgress trace
      int getStatusCode​(org.apache.sling.api.SlingHttpServletRequest request)
      Get Error Status Code from Request or Default (500) if no status code can be found
      void includeUsingGET​(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, String path)
      Include the path, forcing the request method to be GET.
      boolean isEnabled()
      Determines if this Service is "enabled".
      boolean isVanityDispatchCheckEnabled()
      Determines if Vanity-URL dispatch check is enabled.
      void resetRequestAndResponse​(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, int statusCode)
      Reset response attributes to support printing out a new page (rather than one that potentially errored out).
    • Method Detail

      • isEnabled

        boolean isEnabled()
        Determines if this Service is "enabled". If it has been configured to be "Disabled" the Service still exists however it should not be used. This OSGi Property toggle allows error page handler to be toggled on an off without via OSGi means without throwing Null pointers, etc.
        Returns:
        true is the Service should be considered enabled
      • findErrorPage

        String findErrorPage​(org.apache.sling.api.SlingHttpServletRequest request,
                             org.apache.sling.api.resource.Resource errorResource)
        Find the JCR full path to the most appropriate Error Page
        Parameters:
        request -
        errorResource -
        Returns:
      • getStatusCode

        int getStatusCode​(org.apache.sling.api.SlingHttpServletRequest request)
        Get Error Status Code from Request or Default (500) if no status code can be found
        Parameters:
        request -
        Returns:
      • getErrorPageName

        String getErrorPageName​(org.apache.sling.api.SlingHttpServletRequest request)
        Get the Error Page's name (all lowercase) that should be used to render the page for this error. This looks at the Servlet Sling has already resolved to handle this request (making Sling do all the hard work)!
        Parameters:
        request -
        Returns:
      • doHandle404

        boolean doHandle404​(org.apache.sling.api.SlingHttpServletRequest request,
                            org.apache.sling.api.SlingHttpServletResponse response)
        Determine is the request is a 404 and if so handles the request appropriately base on some CQ idiosyncrasies . Invokes the AEM Login Selector Autheticator on 404'ing requests made by anonymous users.
        Parameters:
        request -
        response -
        Returns:
        true if the error page handler should process the 404; false is the AEM authenticator has been invoked and responsible for processing the request further
      • getException

        String getException​(org.apache.sling.api.SlingHttpServletRequest request)
        Returns the Exception Message (Stacktrace) from the Request
        Parameters:
        request -
        Returns:
      • getRequestProgress

        String getRequestProgress​(org.apache.sling.api.SlingHttpServletRequest request)
        Returns a String representation of the RequestProgress trace
        Parameters:
        request -
        Returns:
      • resetRequestAndResponse

        void resetRequestAndResponse​(org.apache.sling.api.SlingHttpServletRequest request,
                                     org.apache.sling.api.SlingHttpServletResponse response,
                                     int statusCode)
        Reset response attributes to support printing out a new page (rather than one that potentially errored out). This includes clearing clientlib inclusion state, and resetting the response. If the response is committed, and it hasnt been closed by code, check the response AND jsp buffer sizes and ensure they are large enough to NOT force a buffer flush.
        Parameters:
        request -
        response -
        statusCode -
      • includeUsingGET

        void includeUsingGET​(org.apache.sling.api.SlingHttpServletRequest request,
                             org.apache.sling.api.SlingHttpServletResponse response,
                             String path)
        Include the path, forcing the request method to be GET. This method will silently swallow exceptions.
        Parameters:
        request - the request
        response - the response
        path - the path
      • isVanityDispatchCheckEnabled

        boolean isVanityDispatchCheckEnabled()
        Determines if Vanity-URL dispatch check is enabled. When enabled and current request URI is a valid vanity (after performing resource resolver mapping), request will be forwarded.
        Returns:
        true if check is enabled else false