Class ServletCall

  • Direct Known Subclasses:
    HttpAPIServletCall

    public abstract class ServletCall
    extends java.lang.Object
    Author:
    Severin Moussel
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.String> parameters
      The parameters of the URL.
      Result of the parsing of the query string : "?a=b&c=d&..."
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ServletCall​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      int countParameters()
      Count the number of parameters passed in the URL
      java.lang.Object deserialize​(byte[] bytes)  
      abstract void doDelete()
      Entry point for DELETE
      abstract void doGet()
      Entry point for GET and SEARCH
      abstract void doPost()
      Entry point for CREATE
      abstract void doPut()
      Entry point for UPDATE
      protected void error​(java.lang.String message, int errorCode)  
      java.util.List<byte[]> getBinaryParameters()  
      javax.servlet.http.HttpSession getHttpSession()
      Get the current call's HttpSession
      java.lang.String getInputStream()
      Read the input stream and set it in a String
      java.lang.String getParameter​(java.lang.String name)
      Get a parameter first value by its name
      java.lang.String getParameter​(java.lang.String name, java.lang.String defaultValue)
      Get a parameter first value by its name
      java.util.List<java.lang.String> getParameterAsList​(java.lang.String name)
      Get a parameter values by its name
      java.util.List<java.lang.String> getParameterAsList​(java.lang.String name, java.lang.String defaultValue)
      Get a parameter values by its name
      java.lang.String getQueryString()  
      java.lang.String getRequestURL()
      Reconstruct the URL the client used to make the request.
      protected java.lang.String getResponseContentType()  
      protected void head​(java.lang.String name, java.lang.String value)
      Write into the output header.
      protected void output​(java.io.File file)
      Output a file
      protected void output​(java.io.InputStream stream)
      Output a stream as a file
      protected void output​(java.io.InputStream stream, java.lang.String filename)
      Output a stream as a file
      protected void output​(java.lang.Object object)
      Write into the output
      protected void output​(java.lang.String string)
      Write into the output
      byte[] serialize​(java.lang.Object obj)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • parameters

        protected java.util.Map<java.lang.String,​java.lang.String> parameters
        The parameters of the URL.
        Result of the parsing of the query string : "?a=b&c=d&..."
    • Constructor Detail

      • ServletCall

        protected ServletCall​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws org.apache.commons.fileupload.FileUploadException,
                              java.io.IOException
        Default constructor.
        Parameters:
        request - The request made to access this servletCall.
        response - The response to return.
        Throws:
        java.io.IOException
        org.apache.commons.fileupload.FileUploadException
    • Method Detail

      • getBinaryParameters

        public java.util.List<byte[]> getBinaryParameters()
        Returns:
        the binaryParameters
      • serialize

        public byte[] serialize​(java.lang.Object obj)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • deserialize

        public java.lang.Object deserialize​(byte[] bytes)
                                     throws java.io.IOException,
                                            java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • getHttpSession

        public javax.servlet.http.HttpSession getHttpSession()
        Get the current call's HttpSession
        Returns:
        This method returns the session from the current call.
      • getQueryString

        public java.lang.String getQueryString()
        See Also:
        HttpServletRequest.getQueryString()
      • getRequestURL

        public final java.lang.String getRequestURL()
        Reconstruct the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
        Returns:
        This method returns the reconstructed URL
      • getInputStream

        public final java.lang.String getInputStream()
        Read the input stream and set it in a String
      • countParameters

        public final int countParameters()
        Count the number of parameters passed in the URL
        Returns:
        This method returns the number of parameters in the URL
      • getParameterAsList

        public final java.util.List<java.lang.String> getParameterAsList​(java.lang.String name)
        Get a parameter values by its name
        Parameters:
        name - The name of the parameter (case sensitive)
        Returns:
        This method returns the values of a parameter as a list of String or null if the parameter isn't defined
      • getParameterAsList

        public final java.util.List<java.lang.String> getParameterAsList​(java.lang.String name,
                                                                         java.lang.String defaultValue)
        Get a parameter values by its name
        Parameters:
        name - The name of the parameter (case sensitive)
        defaultValue - The value to return if the parameter isn't define
        Returns:
        This method returns the values of a parameter as a list of String
      • getParameter

        public final java.lang.String getParameter​(java.lang.String name)
        Get a parameter first value by its name
        Parameters:
        name - The name of the parameter (case sensitive)
        Returns:
        This method returns the first value of a parameter as a String or null if the parameter isn't define
      • getParameter

        public final java.lang.String getParameter​(java.lang.String name,
                                                   java.lang.String defaultValue)
        Get a parameter first value by its name
        Parameters:
        name - The name of the parameter (case sensitive)
        defaultValue - The value to return if the parameter isn't define
        Returns:
        This method returns the first value of a parameter as a String
      • head

        protected final void head​(java.lang.String name,
                                  java.lang.String value)
        Write into the output header.
        Parameters:
        name - The name of the header to write.
        value - The value of the header to write.
      • output

        protected final void output​(java.io.File file)
        Output a file
        Parameters:
        file - The file to output
      • output

        protected void output​(java.io.InputStream stream,
                              java.lang.String filename)
        Output a stream as a file
        Parameters:
        stream - The stream to output
        filename - The name of the file to retrieve with the stream.
      • output

        protected void output​(java.io.InputStream stream)
        Output a stream as a file
        Parameters:
        stream - The stream to output
      • error

        protected void error​(java.lang.String message,
                             int errorCode)
      • output

        protected final void output​(java.lang.String string)
        Write into the output
        Parameters:
        string - The string to output
      • output

        protected final void output​(java.lang.Object object)
        Write into the output
        Parameters:
        object - An object that will be transform into JSon
      • getResponseContentType

        protected java.lang.String getResponseContentType()
      • doGet

        public abstract void doGet()
        Entry point for GET and SEARCH
      • doPost

        public abstract void doPost()
        Entry point for CREATE
      • doPut

        public abstract void doPut()
        Entry point for UPDATE
      • doDelete

        public abstract void doDelete()
        Entry point for DELETE