Class DapRequest
- java.lang.Object
-
- dap4.servlet.DapRequest
-
public class DapRequest extends Object
User requests get cached here so that downstream code can access the details of the request information.Modified by Heimbigner for DAP4.
-
-
Field Summary
Fields Modifier and Type Field Description protected dap4.core.util.ChecksumModechecksummodeprotected DapControllercontrollerprotected Stringdatasetprotected Stringdatasetpathprotected dap4.core.util.ResponseFormatformatprotected dap4.dap4lib.RequestModemodeprotected ByteOrderorderprotected javax.servlet.http.HttpServletRequestrequestprotected static StringRESOURCEDIRNAMEprotected javax.servlet.http.HttpServletResponseresponseprotected static StringWEBINFPATHprotected dap4.core.util.XURIxuri
-
Constructor Summary
Constructors Constructor Description DapRequest(DapController controller, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description dap4.core.util.ChecksumModegetChecksumMode()StringgetDataset()StringgetDatasetPath()dap4.core.util.ResponseFormatgetFormat()dap4.dap4lib.RequestModegetMode()ByteOrdergetOrder()OutputStreamgetOutputStream()Map<String,String>getQueries()javax.servlet.http.HttpServletRequestgetRequest()StringgetResourcePath(String location)Convert a URL path for a dataset into an absolute file pathjavax.servlet.http.HttpServletResponsegetResponse()StringgetServletID()StringgetURL()StringgetWebContentPath(String location)Convert a URL path for a web-content related file into an absolute file pathStringgetWebContentRoot()protected voidparseURI()The goal of parse() is to extract info from the underlying HttpRequest and cache it in this object.StringqueryLookup(String name)voidsetResponseHeader(String name, String value)Set a request header
-
-
-
Field Detail
-
WEBINFPATH
protected static final String WEBINFPATH
- See Also:
- Constant Field Values
-
RESOURCEDIRNAME
protected static final String RESOURCEDIRNAME
- See Also:
- Constant Field Values
-
controller
protected DapController controller
-
request
protected javax.servlet.http.HttpServletRequest request
-
response
protected javax.servlet.http.HttpServletResponse response
-
xuri
protected dap4.core.util.XURI xuri
-
mode
protected dap4.dap4lib.RequestMode mode
-
format
protected dap4.core.util.ResponseFormat format
-
order
protected ByteOrder order
-
checksummode
protected dap4.core.util.ChecksumMode checksummode
-
datasetpath
protected String datasetpath
-
dataset
protected String dataset
-
-
Constructor Detail
-
DapRequest
public DapRequest(DapController controller, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws dap4.core.util.DapException
- Throws:
dap4.core.util.DapException
-
-
Method Detail
-
parseURI
protected void parseURI() throws IOExceptionThe goal of parse() is to extract info from the underlying HttpRequest and cache it in this object.In particular, the incoming URL needs to be decomposed into multiple pieces. Certain assumptions are made: 1. every incoming url is of the form (a) http(s)://host:port/d4ts/ or (b) http(s)://host:port/d4ts/
?query Case a indicates that the front page is to be returned. Case b indicates a request for a dataset (or dsr), and its value is determined by its extensions. The query may be absent. We want to extract the following pieces. 1. (In URI parlance) The scheme plus the authority: http://host:port 3. The return type: depending on the last extension (e.g. ".txt"). 4. The requested value: depending on the next to last extension (e.g. ".dap"). 5. The suffix path specifying the actual dataset: datasetpath with return and request type extensions removed. 6. The url path = servletpath + datasetpath. 7. The query part. - Throws:
IOException
-
getOrder
public ByteOrder getOrder()
-
getChecksumMode
public dap4.core.util.ChecksumMode getChecksumMode()
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()
-
getResponse
public javax.servlet.http.HttpServletResponse getResponse()
-
getWebContentRoot
public String getWebContentRoot() throws dap4.core.util.DapException
- Throws:
dap4.core.util.DapException
-
getServletID
public String getServletID() throws dap4.core.util.DapException
- Throws:
dap4.core.util.DapException
-
getResourcePath
public String getResourcePath(String location) throws dap4.core.util.DapException
Convert a URL path for a dataset into an absolute file path- Parameters:
location- suffix of url path- Returns:
- path in a string builder so caller can extend.
- Throws:
IOExceptiondap4.core.util.DapException
-
getWebContentPath
public String getWebContentPath(String location) throws dap4.core.util.DapException
Convert a URL path for a web-content related file into an absolute file path- Parameters:
location- suffix of url path- Returns:
- path in a string builder so caller can extend.
- Throws:
IOExceptiondap4.core.util.DapException
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Throws:
IOException
-
getURL
public String getURL()
-
getDatasetPath
public String getDatasetPath()
-
getDataset
public String getDataset()
-
getMode
public dap4.dap4lib.RequestMode getMode()
-
getFormat
public dap4.core.util.ResponseFormat getFormat()
-
setResponseHeader
public void setResponseHeader(String name, String value)
Set a request header- Parameters:
name- the header namevalue- the header value
-
-