Class HttpBaseServlet

    • Constructor Summary

      Constructors 
      Constructor Description
      HttpBaseServlet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Redirects all HTTP GET requests to be handled by the doPost method of the extending class.
      void doGetCall​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      void doPostCall​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      protected String getBaseDesignPath​(String language)
      Returns the absolute path to the correct language subfolder within the context's src-loc folder.
      CallableStatement getCallableStatement​(String strSql)
      Returns a prepared callable statement for the specified strSql based on the connection retrieved from the default pool of connections.
      CallableStatement getCallableStatement​(String poolName, String strSql)
      Returns a prepared callable statement for the specified strSql based on the connection retrieved from the poolName.
      CallableStatement getCallableStatement​(Connection conn, String strSql)
      Returns a prepared callable statement for the specified strSql based on the connection conn provided.
      Connection getConnection()
      Retrieves an open autocommit connection from the connection pool managed by this class.
      protected String getPoolStatus()
      Not implemented yet.
      PreparedStatement getPreparedStatement​(String strSql)
      Returns a PreparedStatement object that contains the specified strSql prepared on top of a connection retrieved from a default connection pool.
      PreparedStatement getPreparedStatement​(String poolName, String strSql)
      Returns a PreparedStatement object that contains the specified strSql prepared on top of a connection retrieved from the poolName pool of connections.
      PreparedStatement getPreparedStatement​(Connection conn, String strSql)
      Returns a PreparedStatement object that contains the specified strSql prepared on top of the connection conn passed to the method.
      String getRDBMS()
      Return the bbdd.rdbms property defined within the config/Openbravo.properties configuration file.
      String getServletInfo()  
      Statement getStatement()
      Returns a Statement object for sending SQL statements to the database based on a connection retrieved from the default pool of connections.
      Statement getStatement​(String poolName)
      Returns a Statement object for sending SQL statements to the database based on a connection retrieved from the poolName.
      Statement getStatement​(Connection conn)
      Returns a Statement object for sending SQL statements to the database based on the connection conn provided.
      String getStatus()  
      Connection getTransactionConnection()
      Retrieves an open connection that is not automatically commited from the connection pool managed by this class.
      void init​(javax.servlet.ServletConfig config)
      Loads basic configuration settings that this class and all that extend it require to function properly.
      void initialize​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Initialization of basic servlet variables required by subsequent operations of this class and the ones that extend it.
      void releaseCallableStatement​(CallableStatement callableStatement)
      Closes the prepared callableStatement and releases the connection on top of which this callable statement was prepared.
      void releaseCommitConnection​(Connection conn)
      First commit the connection specified and then store it back into the pool of available connections managed by this class.
      void releasePreparedStatement​(PreparedStatement preparedStatement)
      Closes the preparedStatement and releases the connection on top of which this statement was prepared.
      void releaseRollbackConnection​(Connection conn)
      First rollback the connection specified and then store it back into the pool of available connections managed by this class.
      void releaseStatement​(Statement statement)
      Closes the statement and releases the connection back into the pool.
      void releaseTransactionalPreparedStatement​(PreparedStatement preparedStatement)
      Only closes the preparedStatement since it is probably part of a series of statements that use the same connection.
      void releaseTransactionalStatement​(Statement statement)
      Only closes the statement since it is probably part of a series of statements that use the same connection.
      void service​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      A dispatcher method that calls the initialization upon every request to the servlet before it hands over the final dispatchment to the HttpServlet base class.
      void serviceInitialized​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Called by the HttpSecureAppServlet within its service() method to indirectly call the service() method of the HttpServlet base class because HttpBaseServlet.service() is then replaced by the HttpSecureAppServlets one.
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
    • Field Detail

      • strDireccion

        public static String strDireccion
      • strReplaceWith

        protected String strReplaceWith
      • strReplaceWithFull

        protected String strReplaceWithFull
      • strDefaultServlet

        protected String strDefaultServlet
      • log4j

        protected org.apache.logging.log4j.Logger log4j
    • Constructor Detail

      • HttpBaseServlet

        public HttpBaseServlet()
    • Method Detail

      • init

        public void init​(javax.servlet.ServletConfig config)
        Loads basic configuration settings that this class and all that extend it require to function properly. Also instantiates XmlEngine object. This method is called upon load of the class, which is configured to be loaded upon start of the application server. See also web.xml (load-on-startup).
        Specified by:
        init in interface javax.servlet.Servlet
        Overrides:
        init in class javax.servlet.GenericServlet
      • initialize

        public void initialize​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws IOException,
                               javax.servlet.ServletException
        Initialization of basic servlet variables required by subsequent operations of this class and the ones that extend it. Normally called within the service() method of this class.
        Parameters:
        request - HttpServletRequest object where details of the HTTP request are.
        response - HttpServletResponse object where the response will be written and returned to the user.
        Throws:
        IOException
        javax.servlet.ServletException
      • serviceInitialized

        public void serviceInitialized​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws IOException,
                                       javax.servlet.ServletException
        Called by the HttpSecureAppServlet within its service() method to indirectly call the service() method of the HttpServlet base class because HttpBaseServlet.service() is then replaced by the HttpSecureAppServlets one.
        Parameters:
        request - HttpServletRequest object where details of the HTTP request are.
        response - HttpServletResponse object where the response will be written and returned to the user.
        Throws:
        IOException
        javax.servlet.ServletException
      • service

        public void service​(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response)
                     throws IOException,
                            javax.servlet.ServletException
        A dispatcher method that calls the initialization upon every request to the servlet before it hands over the final dispatchment to the HttpServlet base class.
        Overrides:
        service in class javax.servlet.http.HttpServlet
        Parameters:
        request - HttpServletRequest object where details of the HTTP request are.
        response - HttpServletResponse object where the response will be written and returned to the user.
        Throws:
        IOException
        javax.servlet.ServletException
      • getBaseDesignPath

        protected String getBaseDesignPath​(String language)
        Returns the absolute path to the correct language subfolder within the context's src-loc folder.
        Parameters:
        language - String specifying the language folder required, e.g. es_ES
        Returns:
        String with the absolute path on the local drive.
      • doGet

        public void doGet​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws IOException,
                          javax.servlet.ServletException
        Redirects all HTTP GET requests to be handled by the doPost method of the extending class.
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Parameters:
        request - HttpServletRequest object where details of the HTTP request are.
        response - HttpServletResponse object where the response will be written and returned to the user.
        Throws:
        IOException
        javax.servlet.ServletException
      • doGetCall

        public void doGetCall​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws Exception
        Throws:
        Exception
      • doPostCall

        public void doPostCall​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws Exception
        Throws:
        Exception
      • getRDBMS

        public String getRDBMS()
        Return the bbdd.rdbms property defined within the config/Openbravo.properties configuration file. This property defines the type of the database (ORACLE or POSTGRES).
        Specified by:
        getRDBMS in interface ConnectionProvider
        Returns:
        String containing the database type (ORACLE or POSTGRES).
      • releaseCommitConnection

        public void releaseCommitConnection​(Connection conn)
                                     throws SQLException
        First commit the connection specified and then store it back into the pool of available connections managed by this class.
        Specified by:
        releaseCommitConnection in interface ConnectionProvider
        Parameters:
        conn - The Connection object required to be committed and stored back into the pool.
        Throws:
        SQLException
      • releaseRollbackConnection

        public void releaseRollbackConnection​(Connection conn)
                                       throws SQLException
        First rollback the connection specified and then store it back into the pool of available connections managed by this class.
        Specified by:
        releaseRollbackConnection in interface ConnectionProvider
        Parameters:
        conn - The Connection object required to be rolled back and stored back into the pool.
        Throws:
        SQLException
      • getPreparedStatement

        public PreparedStatement getPreparedStatement​(String poolName,
                                                      String strSql)
                                               throws Exception
        Returns a PreparedStatement object that contains the specified strSql prepared on top of a connection retrieved from the poolName pool of connections.
        Specified by:
        getPreparedStatement in interface ConnectionProvider
        Parameters:
        poolName - The name of the pool to retrieve the connection from.
        strSql - The SQL statement to prepare.
        Returns:
        PreparedStatement object with the strSql prepared.
        Throws:
        Exception
      • getPreparedStatement

        public PreparedStatement getPreparedStatement​(String strSql)
                                               throws Exception
        Returns a PreparedStatement object that contains the specified strSql prepared on top of a connection retrieved from a default connection pool.
        Specified by:
        getPreparedStatement in interface ConnectionProvider
        Parameters:
        strSql - The SQL statement to prepare.
        Returns:
        PreparedStatement object with the strSql prepared.
        Throws:
        Exception
      • getPreparedStatement

        public PreparedStatement getPreparedStatement​(Connection conn,
                                                      String strSql)
                                               throws SQLException
        Returns a PreparedStatement object that contains the specified strSql prepared on top of the connection conn passed to the method.
        Specified by:
        getPreparedStatement in interface ConnectionProvider
        Parameters:
        conn - The Connection object containing the connection.
        strSql - The SQL statement to prepare.
        Returns:
        PreparedStatement object with the strSql prepared.
        Throws:
        SQLException
      • getStatement

        public Statement getStatement​(String poolName)
                               throws Exception
        Returns a Statement object for sending SQL statements to the database based on a connection retrieved from the poolName.
        Specified by:
        getStatement in interface ConnectionProvider
        Parameters:
        poolName - The name of the pool to retrieve the connection from.
        Returns:
        Prepared Statement object requested.
        Throws:
        Exception
      • getStatement

        public Statement getStatement()
                               throws Exception
        Returns a Statement object for sending SQL statements to the database based on a connection retrieved from the default pool of connections.
        Specified by:
        getStatement in interface ConnectionProvider
        Returns:
        Prepared Statement object requested.
        Throws:
        Exception
      • releaseTransactionalStatement

        public void releaseTransactionalStatement​(Statement statement)
                                           throws SQLException
        Only closes the statement since it is probably part of a series of statements that use the same connection. The connection must be then closed manually after all statements have been closed.
        Specified by:
        releaseTransactionalStatement in interface ConnectionProvider
        Parameters:
        statement - Object containing the statement to release.
        Throws:
        SQLException
      • releaseTransactionalPreparedStatement

        public void releaseTransactionalPreparedStatement​(PreparedStatement preparedStatement)
                                                   throws SQLException
        Only closes the preparedStatement since it is probably part of a series of statements that use the same connection. The connection must be then closed manually after all statements have been closed.
        Specified by:
        releaseTransactionalPreparedStatement in interface ConnectionProvider
        Parameters:
        preparedStatement - Object containing the prepared statement to release.
        Throws:
        SQLException
      • getCallableStatement

        public CallableStatement getCallableStatement​(String poolName,
                                                      String strSql)
                                               throws Exception
        Returns a prepared callable statement for the specified strSql based on the connection retrieved from the poolName.
        Specified by:
        getCallableStatement in interface ConnectionProvider
        Parameters:
        poolName - The name of the pool to retrieve the connection from.
        strSql - The callable SQL statement to prepare.
        Returns:
        CallableStatement object with the strSql prepared.
        Throws:
        SQLException
        Exception
      • getCallableStatement

        public CallableStatement getCallableStatement​(String strSql)
                                               throws Exception
        Returns a prepared callable statement for the specified strSql based on the connection retrieved from the default pool of connections.
        Specified by:
        getCallableStatement in interface ConnectionProvider
        Parameters:
        strSql - The callable SQL statement to prepare.
        Returns:
        CallableStatement object with the strSql prepared.
        Throws:
        Exception
      • getCallableStatement

        public CallableStatement getCallableStatement​(Connection conn,
                                                      String strSql)
                                               throws SQLException
        Returns a prepared callable statement for the specified strSql based on the connection conn provided.
        Specified by:
        getCallableStatement in interface ConnectionProvider
        Parameters:
        conn - The Connection object containing the connection.
        strSql - The callable SQL statement to prepare.
        Returns:
        CallableStatement object with the strSql prepared.
        Throws:
        SQLException
      • releaseCallableStatement

        public void releaseCallableStatement​(CallableStatement callableStatement)
                                      throws SQLException
        Closes the prepared callableStatement and releases the connection on top of which this callable statement was prepared.
        Specified by:
        releaseCallableStatement in interface ConnectionProvider
        Parameters:
        callableStatement - Object containing prepared callable statement to release.
        Throws:
        SQLException
      • getPoolStatus

        protected String getPoolStatus()
        Not implemented yet.
        Returns:
        String with "Status unavailable" or "Not implemented yet"
      • getServletInfo

        public String getServletInfo()
        Specified by:
        getServletInfo in interface javax.servlet.Servlet
        Overrides:
        getServletInfo in class javax.servlet.GenericServlet