Class OpendapServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, org.springframework.beans.factory.InitializingBean

    @Controller
    @RequestMapping("/dods")
    public class OpendapServlet
    extends AbstractServlet
    implements org.springframework.beans.factory.InitializingBean
    THREDDS opendap server.
    See Also:
    Serialized Form
    • Field Detail

      • log

        public static org.slf4j.Logger log
    • Constructor Detail

      • OpendapServlet

        public OpendapServlet()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • getServerVersion

        public String getServerVersion()
        Description copied from class: AbstractServlet
        This function must be implemented locally for each OPeNDAP server. It should return a String containing the OPeNDAP Server Version...
        Specified by:
        getServerVersion in class AbstractServlet
        Returns:
        The Server Version String
      • getLastModified

        protected long getLastModified​(javax.servlet.http.HttpServletRequest req)
        Overrides:
        getLastModified in class javax.servlet.http.HttpServlet
      • doGet

        @RequestMapping(value="**",
                        method=GET)
        public void doGet​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
        Description copied from class: AbstractServlet
        Handles incoming requests from clients. Parses the request and determines what kind of OPeNDAP response the client is requesting. If the request is understood, then the appropriate handler method is called, otherwise an error is returned to the client.

        This method is the entry point for AbstractServlet.

        Overrides:
        doGet in class AbstractServlet
        Parameters:
        request - The client's HttpServletRequest request object.
        response - The server's HttpServletResponse response object.
        See Also:
        ReqState
      • doGetASC

        public void doGetASC​(ReqState rs)
                      throws Exception
        Description copied from class: AbstractServlet
        Default handler for OPeNDAP ascii data requests. Returns the request data as a comma delimited ascii file. Note that this means that the more complex OPeNDAP structures such as Grids get flattened... Modified 2/8/07 jcaron to not make a DConnect2 call to itself
        Overrides:
        doGetASC in class AbstractServlet
        Parameters:
        rs - the decoded Request State
        Throws:
        Exception
      • doGetDAS

        public void doGetDAS​(ReqState rs)
                      throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's DAS request. Operates on the assumption that the DAS information is cached on a disk local to the server. If you don't like that, then you better override it in your server :)

        Once the DAS has been parsed it is sent to the requesting client.

        Overrides:
        doGetDAS in class AbstractServlet
        Parameters:
        rs - The ReqState of this client request. Contains all kinds of important stuff.
        Throws:
        Exception
        See Also:
        ReqState
      • doGetDDS

        public void doGetDDS​(ReqState rs)
                      throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's DDS request. Requires the getDDS() method implemented by each server localization effort.

        Once the DDS has been parsed and constrained it is sent to the requesting client.

        Overrides:
        doGetDDS in class AbstractServlet
        Parameters:
        rs - The ReqState of this client request. Contains all kinds of important stuff.
        Throws:
        Exception
        See Also:
        ReqState
      • doGetDDX

        public void doGetDDX​(ReqState rs)
                      throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's DDS request. Requires the getDDS() method implemented by each server localization effort.

        Once the DDS has been parsed and constrained it is sent to the requesting client.

        Overrides:
        doGetDDX in class AbstractServlet
        Parameters:
        rs - The ReqState of this client request. Contains all kinds of important stuff.
        Throws:
        Exception
        See Also:
        ReqState
      • doGetBLOB

        public void doGetBLOB​(ReqState rs)
                       throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's data request. Requires the getDDS() method implemented by each server localization effort.

        Once the DDS has been parsed, the data is read (using the class in the localized server factory etc.), compared to the constraint expression, and then sent to the client.

        Overrides:
        doGetBLOB in class AbstractServlet
        Parameters:
        rs - The ReqState of this client request. Contains all kinds of important stuff.
        Throws:
        Exception
        See Also:
        ReqState
      • doGetDAP2Data

        public void doGetDAP2Data​(ReqState rs)
                           throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's data request. Requires the getDDS() method implemented by each server localization effort.

        Once the DDS has been parsed, the data is read (using the class in the localized server factory etc.), compared to the constraint expression, and then sent to the client.

        Overrides:
        doGetDAP2Data in class AbstractServlet
        Parameters:
        rs - The ReqState of this client request.
        Throws:
        Exception
      • doGetVER

        public void doGetVER​(ReqState rs)
                      throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's version request.

        Returns a plain text document with server version and OPeNDAP core version #'s

        Overrides:
        doGetVER in class AbstractServlet
        Parameters:
        rs - The client's ReqState
        Throws:
        Exception
      • doGetDIR

        public void doGetDIR​(ReqState rs)
                      throws Exception
        Description copied from class: AbstractServlet
        Default handler for the client's directory request.

        Returns an html document to the client showing (a possibly pseudo) listing of the datasets available on the server in a directory listing format.

        The bulk of this code resides in the class opendap.servlet.GetDirHandler and documentation may be found there.

        Overrides:
        doGetDIR in class AbstractServlet
        Parameters:
        rs - The client's ReqState
        Throws:
        Exception
        See Also:
        GetDirHandler
      • doGetHTML

        public void doGetHTML​(ReqState rs)
                       throws Exception
        Description copied from class: AbstractServlet
        Default handler for OPeNDAP .html requests. Returns the OPeNDAP Web Interface (aka The Interface From Hell) to the client.

        The bulk of this code resides in the class opendap.servlet.GetHTMLInterfaceHandler and documentation may be found there.

        Overrides:
        doGetHTML in class AbstractServlet
        Parameters:
        rs - The client's ReqState
        Throws:
        Exception
        See Also:
        GetHTMLInterfaceHandler
      • getServerName

        public String getServerName()
        Description copied from class: AbstractServlet

        In this (default) implementation of the getServerName() method we just get the name of the servlet and pass it back. If something different is required, override this method when implementing the getDDS() and getServerVersion() methods.

        This is typically used by the getINFO() method to figure out if there is information specific to this server residing in the info directory that needs to be returned to the client as part of the .info rs.getResponse().

        Overrides:
        getServerName in class AbstractServlet
        Returns:
        A string containing the name of the servlet class that is running.
      • printBadURLPage

        protected void printBadURLPage​(PrintWriter pw)
        Prints the Bad URL Page page to the passed PrintWriter
        Overrides:
        printBadURLPage in class AbstractServlet
        Parameters:
        pw - PrintWriter stream to which to dump the bad URL page.
      • getRequestState

        protected ReqState getRequestState​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
        Overrides:
        getRequestState in class AbstractServlet
        Returns:
        the request state
      • getDataset

        protected GuardedDataset getDataset​(ReqState preq)
                                     throws Exception
        Description copied from class: AbstractServlet
        This method must be implemented locally for each OPeNDAP server. The local implementation of this method is the key piece for connecting any localized data types that are derived from the opendap.server types back into the running servlet.

        This method should do the following:

        • Make a new ServerFactory (aka BaseTypeFactory) for the dataset requested.
        • Instantiate a ServerDDS using the ServerFactory and populate it (this could be accomplished by just opening a (cached?) DDS in a file and parsing it)
        • Return this freshly minted ServerDDS object (to the servlet code where it is used.)
        Specified by:
        getDataset in class AbstractServlet
        Parameters:
        preq - The ReqState object for this particular client request.
        Returns:
        A GuardedDataset object cintaininb the parsed DAS and DDS.
        Throws:
        Exception
      • parseExceptionHandler

        public void parseExceptionHandler​(opendap.dap.parsers.ParseException pe,
                                          javax.servlet.http.HttpServletResponse response)
        Description copied from class: AbstractServlet
        Turns a ParseException into a OPeNDAP DAP2 error and sends it to the client.
        Overrides:
        parseExceptionHandler in class AbstractServlet
        Parameters:
        pe - The ParseException that caused the problem.
        response - The HttpServletResponse for the client.
      • dap2ExceptionHandler

        public void dap2ExceptionHandler​(opendap.dap.DAP2Exception de,
                                         ReqState rs)