Class BaseActionHandler

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()  
      protected abstract org.codehaus.jettison.json.JSONObject execute​(Map<String,​Object> parameters, String content)
      Needs to be implemented by a subclass.
      protected Map<String,​Object> extractParametersFromRequest​(javax.servlet.http.HttpServletRequest request)
      Utility function used by execute() that lets us extend the part where we extract the list of parameters of the request and returns it as a Map<String, Object>
      protected String extractRequestContent​(javax.servlet.http.HttpServletRequest request, Map<String,​Object> requestParameters)
      Utility function used by execute() that lets us extend the part where the request contents are extracted from the request payload.
      protected Map<String,​String> fixRequestMap​(Map<String,​Object> parameters, org.codehaus.jettison.json.JSONObject context)
      Fixes the request map adding an "context" key to include context info in order to make it available to be evaluated by FilterExpression
      protected void writeResponse​(Map<String,​Object> parameters, org.codehaus.jettison.json.JSONObject result, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Utility function used by execute() that, given the request, the response of the execute(parameters, content) execution and the parameters, writes the response object to be sent back to the client.
    • Constructor Detail

      • BaseActionHandler

        public BaseActionHandler()
    • Method Detail

      • extractParametersFromRequest

        protected Map<String,​Object> extractParametersFromRequest​(javax.servlet.http.HttpServletRequest request)
        Utility function used by execute() that lets us extend the part where we extract the list of parameters of the request and returns it as a Map<String, Object>
        Parameters:
        request - The request
        Returns:
        A map with key the name of the parameter and an Object as the value
      • extractRequestContent

        protected String extractRequestContent​(javax.servlet.http.HttpServletRequest request,
                                               Map<String,​Object> requestParameters)
                                        throws IOException
        Utility function used by execute() that lets us extend the part where the request contents are extracted from the request payload.
        Parameters:
        request - The request
        requestParameters - The map of parameters extracted from the request
        Returns:
        The request content as an String
        Throws:
        IOException - when there is an error reading the request InputStream
      • writeResponse

        protected void writeResponse​(Map<String,​Object> parameters,
                                     org.codehaus.jettison.json.JSONObject result,
                                     javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response)
                              throws IOException
        Utility function used by execute() that, given the request, the response of the execute(parameters, content) execution and the parameters, writes the response object to be sent back to the client.
        Parameters:
        parameters - The list of parameters of the request generated by extractParametersFromRequest()
        result - The result returned by execute(parameters, content)
        request - The request
        response - The response object to be sent back to the client
        Throws:
        IOException - if there is an error writing the response object
      • fixRequestMap

        protected Map<String,​String> fixRequestMap​(Map<String,​Object> parameters,
                                                         org.codehaus.jettison.json.JSONObject context)
        Fixes the request map adding an "context" key to include context info in order to make it available to be evaluated by FilterExpression
      • execute

        protected abstract org.codehaus.jettison.json.JSONObject execute​(Map<String,​Object> parameters,
                                                                         String content)
        Needs to be implemented by a subclass.
        Parameters:
        parameters - the parameters obtained from the request. Note that the request object and the session object are also present in this map, resp. as the constants KernelConstants.HTTP_REQUEST and KernelConstants.HTTP_SESSION.
        content - the request content (if any)
        Returns:
        the return should be a JSONObject, this is passed back to the caller on the client.