|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--dods.servlet.DODSServlet
DODSServlet is the base servlet class for all DODS servers. (Well, all DODS servers running as java servlets) Default handlers for all of the acceptable DODS client requests are here.
Each of the request handlers appears as an adjunct method to the doGet() method of the base servlet class.
This is an abstract class because it is left to the individual server development efforts to write the getDDS() and getServerVersion() methods. The getDDS() method is intended to be where the server specific DODS server data types are used via their associated class factory.
This code relies on the javax.servlet.ServletConfig
interface (in particular the getInitParameter() method)
to retrieve the name of a .ini file containing information
about where to find extensive configuration information used by
the servlet. Alternate methods for establishing this functionality
can be arranged by overloading the method loadIniFile()
The servlet should be started in the servlet engine with the following initParameters set:
For the old jswdk servlet engine:
dts.code=dods.servers.test.dts dts.initparams=iniFilePath=/usr/dods/dts,iniFileName=dts.iniFor the tomcat servlet engine:
<servlet>
<servlet-name>
dts
</servlet-name>
<servlet-class>
dods.servers.test.dts
</servlet-class>
<init-param>
<param-name>iniFilePath</param-name>
<param-value>/usr/dods/dts</param-value>
</init-param>
<init-param>
<param-name>iniFileName</param-name>
<param-value>dts.ini</param-value>
</init-param>
</servlet>
Assuming, of course, that the .ini file is located in /usr/dods/dts
and is named dts.ini. For example .ini files look in the subdirectory
Java-DODS/.ini (where Java-DODS is the top of the distribution).
Also, the method processDodsURL() could be overloaded
if some kind of special processing of the incoming request is needed
to ascertain the DODS URL information.
#getDDS(String),
#loadIniFile(),
processDodsURL(HttpServletRequest),
Serialized Form| Constructor Summary | |
DODSServlet()
|
|
| Method Summary | |
void |
anyExceptionHandler(java.lang.Throwable e,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Sends an error to the client. |
void |
badURL(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sends an html document to the client explaining that they have used a poorly formed URL and then the help page... |
void |
dodsExceptionHandler(DODSException de,
javax.servlet.http.HttpServletResponse response)
Sends a DODS error to the client. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handles incoming requests from clients. |
void |
doGetASC(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for DODS ascii data requests. |
void |
doGetCatalog(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Default handler for DODS catalog.xml requests. |
void |
doGetDAS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for the client's DAS request. |
void |
doGetDDS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for the client's DDS request. |
void |
doGetDIR(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for the client's directory request. |
void |
doGetDODS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for the client's data request. |
void |
doGetHELP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Default handler for the client's help request. |
void |
doGetHTML(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for DODS .html requests. |
void |
doGetINFO(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
Default handler for DODS info requests. |
void |
doGetStatus(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Default handler for DODS status requests; not publically available, used only for debugging |
void |
doGetVER(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Default handler for the client's version request. |
protected DAS |
getDAS(requestState rs)
In this (default) implementation of the getDAS() method a locally cached DAS is retrieved and parsed. |
protected abstract GuardedDataset |
getDataset(requestState rs)
This method must be implemented locally for each DODS server. |
java.lang.String |
getServerName()
In this (default) implementation of the getServerName() method we just get the name of the servlet and pass it back. |
abstract java.lang.String |
getServerVersion()
This function must be implemented locally for each DODS server. |
void |
init()
Intitializes the servlet. |
protected boolean |
isTheClientCompressed(javax.servlet.http.HttpServletRequest request)
Evaluates a request object to determine if the client that sent the request accepts compressed return documents. |
java.io.DataInputStream |
openCachedDAS(requestState rs)
Opens a DAS cached on local disk. |
java.io.DataInputStream |
openCachedDDS(requestState rs)
Opens a DDS cached on local disk. |
void |
parseExceptionHandler(ParseException pe,
javax.servlet.http.HttpServletResponse response)
Turns a ParseException into a DODS error and sends it to the client. |
protected void |
printCatalog(java.io.PrintWriter os)
|
protected void |
printStatus(java.io.PrintWriter os)
|
void |
probeRequest(javax.servlet.http.HttpServletRequest request)
This is a bit of instrumentation that I kept around to let me look at the state of the incoming HttpServletRequest from the client. |
protected requestState |
processDodsURL(javax.servlet.http.HttpServletRequest request)
Processes an incoming HttpServletRequest and from it sets the
cached values for:
dataSet The data set name.(Accessible using
setDataSet()
and getDataSet())
CE The constraint expression.(Accessible using
setCE()
and getCE())
requestSuffix The request suffix, used by DODS to indicate
the type of response desired by the client. |
void |
sendDODSError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String clientMsg,
java.lang.String serverMsg)
Sends a DODS error (type UNKNOWN ERROR) to the client and displays a message on the server console. |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DODSServlet()
| Method Detail |
public abstract java.lang.String getServerVersion()
protected abstract GuardedDataset getDataset(requestState rs)
throws DODSException,
java.io.IOException,
ParseException
This method should do the following:
DODSException
java.io.IOException
ParseExceptionServerDDS,
sqlServerFactory,
test_ServerFactory
public void init()
throws javax.servlet.ServletException
init in class javax.servlet.GenericServletjavax.servlet.ServletException
public void parseExceptionHandler(ParseException pe,
javax.servlet.http.HttpServletResponse response)
pe - The ParseException that caused the problem.response - The HttpServletResponse for the client.
public void dodsExceptionHandler(DODSException de,
javax.servlet.http.HttpServletResponse response)
de - The DODS exception that caused the problem.response - The HttpServletResponse for the client.
public void anyExceptionHandler(java.lang.Throwable e,
javax.servlet.http.HttpServletResponse response,
requestState rs)
response - The HttpServletResponse for the client.
protected DAS getDAS(requestState rs)
throws DODSException,
ParseException
dataSet
DODSException
ParseExceptionDAS
public void sendDODSError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String clientMsg,
java.lang.String serverMsg)
throws java.io.IOException,
javax.servlet.ServletException
request - The client's HttpServletRequest request object.response - The server's HttpServletResponse response object.clientMsg - Error message String to send to the client.serverMsg - Error message String to display on the server console.
java.io.IOException
javax.servlet.ServletException
public java.io.DataInputStream openCachedDDS(requestState rs)
throws DODSException
This method uses the iniFile object cached by
loadIniFile() to determine where to look for the cached
DDS.
DataInputStream from which the DDS can
be read.
DODSException#loadIniFile()
public java.io.DataInputStream openCachedDAS(requestState rs)
throws java.io.FileNotFoundException
This method uses the iniFile object cached by
loadIniFile() to determine where to look for the cached
DDS.
If the DAS cannot be found an error is sent back to the client.
DataInputStream from which the DAS can
be read.
java.io.FileNotFoundException#loadIniFile()
public void doGetDAS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
Once the DAS has been parsed it is sent to the requesting client.
request - The client's HttpServletRequest request object.response - The server's HttpServletResponse response object.
java.io.IOException
javax.servlet.ServletException
public void doGetDDS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
Once the DDS has been parsed and constrained it is sent to the requesting client.
request - The client's HttpServletRequest request object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletException
public void doGetDODS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
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.
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletException
public void doGetDIR(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
The bulk of this code resides in the class dods.servlet.dodsDIR and documentation may be found there.
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptiondodsDIR
public void doGetVER(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
Returns a plain text document with server version and DODS core version #'s
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletException
public void doGetHELP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
Returns an html page of help info for the server
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletException
public void badURL(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletException
public void doGetASC(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
The bulk of this code resides in the class dods.servlet.dodsASCII and documentation may be found there.
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptiondodsASCII
public void doGetINFO(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
The bulk of this code resides in the class dods.servlet.dodsINFO and documentation may be found there.
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptiondodsINFO
public void doGetHTML(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
requestState rs)
throws java.io.IOException,
javax.servlet.ServletException
The bulk of this code resides in the class dods.servlet.dodsHTML and documentation may be found there.
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptiondodsHTML
public void doGetCatalog(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptiondodsHTML
protected void printCatalog(java.io.PrintWriter os)
throws java.io.IOException
java.io.IOException
public void doGetStatus(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
request - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptiondodsHTML
protected void printStatus(java.io.PrintWriter os)
throws java.io.IOException
java.io.IOExceptionpublic void probeRequest(javax.servlet.http.HttpServletRequest request)
HttpServletRequest from the client.
This method calls the get* methods of the request and prints
the results to standard out.
request - The HttpServletRequest object to probe.protected boolean isTheClientCompressed(javax.servlet.http.HttpServletRequest request)
request - The HttpServletRequest sent by the client
in question.
protected requestState processDodsURL(javax.servlet.http.HttpServletRequest request)
HttpServletRequest and from it sets the
cached values for:
setDataSet()
and getDataSet()) setCE()
and getCE()) setRequestSuffix()
and getRequestSuffix())
request - The HttpServletRequest sent by the client
in question.#getDataSet(),
#setDataSet(String),
#getCE(),
#setCE(String),
#getRequestSuffix(),
#setRequestSuffix(String)public java.lang.String getServerName()
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 response.
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
This method is the entry point for DODSServlet. It uses
the methods processDodsURL to extract the DODS URL
information from the incoming client request. This DODS URL information
is cached and made accessible through get and set methods.
After processDodsURL is called loadIniFile()
is called to load configuration information from a .ini file,
If the standard behaviour of the servlet (extracting the DODS URL
information from the client request, or loading the .ini file) then
you should overload processDodsURL and loadIniFile()
. We don't recommend overloading doGet() beacuse
the logic contained there may change in our core and cause your server
to behave unpredictably when future releases are installed.
doGet in class javax.servlet.http.HttpServletrequest - The client's HttpServletRequest request
object.response - The server's HttpServletResponse response
object.
java.io.IOException
javax.servlet.ServletExceptionprocessDodsURL(HttpServletRequest),
#getDataSet(),
#setDataSet(String),
#getCE(),
#setCE(String),
#getRequestSuffix(),
#setRequestSuffix(String),
#loadIniFile()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||