@Controller
@RequestMapping(value="/download")
public class ReifyController
extends java.lang.Object
The goal for this controller is to allow external code to have the thredds server materialize a dataset into the file system.
Note that this functionality is not strictly necessary since it could all be done on the client side. Since the server is doing all of the work of converting a dataset to a file, the client does not need to have its own code for this. This means: 1. It is lightweight WRT the client 2. It is language independent
Assumptions: 1. The external code has authenticated to the thredds server using some authentication mechanism such as client-side certificates or tomcat roles.
2. The external code is running on the same machine as the thredds server, or at least has a common file system so that file system writes by thredds are visible to the external code.
Note that in order to support downloading of non-file datasets (e.g. via DAP2 or DAP4) this controller will re-call the server to obtain the output of the request. Experimentation shows this is not a problem. Circularity is tested to ensure the no download loop occurs.
Issues: 1. What file formats are allowed for materialized datasets? - Currently only netcdf-3 (classic) and netcdf-4 (enhanced).
A set of query parameters control the operation of this servlet. Note that all of the query parameter values (but not keys) are assumed to be url-encoded (%xx), so beware. Also, all return values are url-encoded.
Download Request
----------------
Download parameters:
- request=download -- specify the action
- format=netcdf3|netcdfd4 -- specify the download format
- url={a thredds server dataset access url} -- specify the actual dataset.
- target={path of the downloaded file} -- if it already exists, then it
will be overwritten.
Notes:
1. the host, port and servlet prefix of the url will be
ignored and replaced with the "
Return value: download=
Misc Parameters:
- testinfo={testing info} -- for testing purposes
Inquire Request
----------------
Download parameters:
- request=inquire -- Inquire about various parameters
- inquire={semicolon separated arguments} -- Inquire about the default download dir
Return value:
| Modifier and Type | Field and Description |
|---|---|
protected ucar.nc2.write.Nc4Chunking |
chunking |
protected static boolean |
DEBUG |
protected static java.lang.String |
DEFAULTDOWNLOADDIR |
protected static java.lang.String |
DEFAULTREQUESTNAME |
protected static java.lang.String |
DEFAULTSERVLETNAME |
protected java.lang.String |
downloaddir |
protected static java.lang.String |
FILESERVERSERVLET |
protected boolean |
getInitialized |
protected boolean |
initialized |
protected thredds.server.reify.Parameters |
params |
protected javax.servlet.http.HttpServletRequest |
req |
protected java.lang.String |
requestname |
protected javax.servlet.http.HttpServletResponse |
res |
protected java.lang.String |
server |
protected static java.lang.String |
STATUSCODEHEADER |
protected ucar.nc2.write.Nc4Chunking.Strategy |
strategy |
protected TdsContext |
tdsContext |
static TdsContext |
testTdsContext |
protected java.lang.String |
threddsname |
| Constructor and Description |
|---|
ReifyController() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canCopy(java.lang.String truepath,
thredds.server.reify.ReifyUtils.FileFormat targetformat) |
protected java.lang.String |
directAccess(java.lang.String relpath,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
protected void |
download(java.util.Map<java.lang.String,java.lang.String> result) |
protected static java.lang.String |
escapeString(java.lang.String s)
Given a typical string, insert backslashes
before '"' and '\\' characters and control characters.
|
void |
init() |
void |
initGet(javax.servlet.http.HttpServletRequest req)
Invoked on first get so that everything is available,
especially Spring stuff.
|
protected void |
inquire(java.util.Map<java.lang.String,java.lang.String> result) |
protected void |
makeNetcdf3(ucar.nc2.NetcdfFile ncfile,
java.lang.String target) |
protected void |
makeNetcdf4(ucar.nc2.NetcdfFile ncfile,
java.lang.String target) |
protected void |
reply(java.util.Map<java.lang.String,java.lang.String> result) |
protected void |
reply(java.lang.String sresult) |
protected void |
sendError(int code,
java.lang.String msg) |
protected static final boolean DEBUG
protected static final java.lang.String DEFAULTSERVLETNAME
protected static final java.lang.String DEFAULTREQUESTNAME
protected static final java.lang.String DEFAULTDOWNLOADDIR
protected static final java.lang.String STATUSCODEHEADER
protected static final java.lang.String FILESERVERSERVLET
public static TdsContext testTdsContext
@Autowired protected TdsContext tdsContext
protected javax.servlet.http.HttpServletRequest req
protected javax.servlet.http.HttpServletResponse res
protected thredds.server.reify.Parameters params
protected java.lang.String downloaddir
protected boolean initialized
protected boolean getInitialized
protected java.lang.String server
protected java.lang.String requestname
protected java.lang.String threddsname
protected ucar.nc2.write.Nc4Chunking.Strategy strategy
protected ucar.nc2.write.Nc4Chunking chunking
public ReifyController()
throws javax.servlet.ServletException
javax.servlet.ServletExceptionpublic void init()
throws javax.servlet.ServletException
javax.servlet.ServletExceptionpublic void initGet(javax.servlet.http.HttpServletRequest req)
throws thredds.server.reify.ReifyUtils.SendError
thredds.server.reify.ReifyUtils.SendError@RequestMapping(value="**")
public void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException
javax.servlet.ServletExceptionprotected void sendError(int code,
java.lang.String msg)
protected void reply(java.util.Map<java.lang.String,java.lang.String> result)
protected void reply(java.lang.String sresult)
protected void download(java.util.Map<java.lang.String,java.lang.String> result)
protected void inquire(java.util.Map<java.lang.String,java.lang.String> result)
protected void makeNetcdf4(ucar.nc2.NetcdfFile ncfile,
java.lang.String target)
throws java.io.IOException
java.io.IOExceptionprotected void makeNetcdf3(ucar.nc2.NetcdfFile ncfile,
java.lang.String target)
throws java.io.IOException
java.io.IOExceptionprotected static java.lang.String escapeString(java.lang.String s)
protected java.lang.String directAccess(java.lang.String relpath,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
protected boolean canCopy(java.lang.String truepath,
thredds.server.reify.ReifyUtils.FileFormat targetformat)