@Test public void asciiDataRequestTest() throws UnsupportedEncodingException { String mockURI = "/thredds/dodsC" + path + ".ascii"; String mockQueryString = "Temperature_height_above_ground[0:1:0][0:1:0][41][31]"; MockHttpServletRequest request = new MockHttpServletRequest("GET", mockURI); request.setContextPath("/thredds"); request.setQueryString(mockQueryString); request.setPathInfo(path + ".ascii"); MockHttpServletResponse response = new MockHttpServletResponse(); opendapServlet.doGet(request, response); assertEquals(200, response.getStatus()); }
@RequestMapping(value = "**", method = RequestMethod.GET) public void doGet(HttpServletRequest request, HttpServletResponse response) { log.debug("doGet(): User-Agent = " + request.getHeader("User-Agent")); ReqState rs = getRequestState(request, response); try { if (baseURI == null) { URI reqURI = ServletUtil.getRequestURI(request); assert reqURI != null; String baseUriString = request.getContextPath() + request.getServletPath() + "/"; baseURI = reqURI.resolve(baseUriString); log.debug("doGet(): baseURI was set = {}", baseURI); } String dataSet = rs.getDataSet(); String requestSuffix = rs.getRequestSuffix(); if ((dataSet == null) || dataSet.equals("/") || dataSet.equals("")) { doGetDIR(rs); } else if (requestSuffix.equalsIgnoreCase("blob")) { doGetBLOB(rs); } else if (requestSuffix.equalsIgnoreCase("close")) { doClose(rs); } else if (requestSuffix.equalsIgnoreCase("dds")) { doGetDDS(rs); } else if (requestSuffix.equalsIgnoreCase("das")) { doGetDAS(rs); } else if (requestSuffix.equalsIgnoreCase("ddx")) { doGetDDX(rs); } else if (requestSuffix.equalsIgnoreCase("dods")) { doGetDAP2Data(rs); } else if (requestSuffix.equalsIgnoreCase("asc") || requestSuffix.equalsIgnoreCase("ascii")) { doGetASC(rs); } else if (requestSuffix.equalsIgnoreCase("info")) { doGetINFO(rs); } else if (requestSuffix.equalsIgnoreCase("html") || requestSuffix.equalsIgnoreCase("htm")) { doGetHTML(rs); } else if (requestSuffix.equalsIgnoreCase("ver") || requestSuffix.equalsIgnoreCase("version") || dataSet.equalsIgnoreCase("/version") || dataSet.equalsIgnoreCase("/version/")) { doGetVER(rs); } else if (dataSet.equalsIgnoreCase("/help") || dataSet.equalsIgnoreCase("/help/") || dataSet.equalsIgnoreCase("/" + requestSuffix) || requestSuffix.equalsIgnoreCase("help")) { doGetHELP(rs); } else { sendErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "Unrecognized request"); return; } } catch (FileNotFoundException e) { sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } catch (BadURLException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); dap2ExceptionHandler(e, rs); } catch (DAP2Exception de) { int status = (de.getErrorCode() == DAP2Exception.NO_SUCH_FILE) ? HttpServletResponse.SC_NOT_FOUND : HttpServletResponse.SC_BAD_REQUEST; if ((de.getErrorCode() == DAP2Exception.UNKNOWN_ERROR) || ((de.getErrorCode() == DAP2Exception.UNDEFINED_ERROR)) && (de.getErrorMessage() != null)) { log.info(de.getErrorMessage()); } response.setStatus(status); dap2ExceptionHandler(de, rs); } catch (ParseException pe) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); parseExceptionHandler(pe, response); } catch (RequestTooLargeException e) { throw e; } catch (java.net.SocketException e) { log.info("SocketException: " + e.getMessage(), e); } catch (IOException e) { String eName = e.getClass().getName(); if (eName.equals("org.apache.catalina.connector.ClientAbortException")) { log.debug("ClientAbortException: " + e.getMessage()); return; } log.error("request= " + rs, e); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (Throwable t) { log.error("request= " + rs, t); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); } }
OpendapServlet extends AbstractServlet implements InitializingBean { @RequestMapping(value = "**", method = RequestMethod.GET) public void doGet(HttpServletRequest request, HttpServletResponse response) { log.debug("doGet(): User-Agent = " + request.getHeader("User-Agent")); ReqState rs = getRequestState(request, response); try { if (baseURI == null) { URI reqURI = ServletUtil.getRequestURI(request); assert reqURI != null; String baseUriString = request.getContextPath() + request.getServletPath() + "/"; baseURI = reqURI.resolve(baseUriString); log.debug("doGet(): baseURI was set = {}", baseURI); } String dataSet = rs.getDataSet(); String requestSuffix = rs.getRequestSuffix(); if ((dataSet == null) || dataSet.equals("/") || dataSet.equals("")) { doGetDIR(rs); } else if (requestSuffix.equalsIgnoreCase("blob")) { doGetBLOB(rs); } else if (requestSuffix.equalsIgnoreCase("close")) { doClose(rs); } else if (requestSuffix.equalsIgnoreCase("dds")) { doGetDDS(rs); } else if (requestSuffix.equalsIgnoreCase("das")) { doGetDAS(rs); } else if (requestSuffix.equalsIgnoreCase("ddx")) { doGetDDX(rs); } else if (requestSuffix.equalsIgnoreCase("dods")) { doGetDAP2Data(rs); } else if (requestSuffix.equalsIgnoreCase("asc") || requestSuffix.equalsIgnoreCase("ascii")) { doGetASC(rs); } else if (requestSuffix.equalsIgnoreCase("info")) { doGetINFO(rs); } else if (requestSuffix.equalsIgnoreCase("html") || requestSuffix.equalsIgnoreCase("htm")) { doGetHTML(rs); } else if (requestSuffix.equalsIgnoreCase("ver") || requestSuffix.equalsIgnoreCase("version") || dataSet.equalsIgnoreCase("/version") || dataSet.equalsIgnoreCase("/version/")) { doGetVER(rs); } else if (dataSet.equalsIgnoreCase("/help") || dataSet.equalsIgnoreCase("/help/") || dataSet.equalsIgnoreCase("/" + requestSuffix) || requestSuffix.equalsIgnoreCase("help")) { doGetHELP(rs); } else { sendErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "Unrecognized request"); return; } } catch (FileNotFoundException e) { sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } catch (BadURLException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); dap2ExceptionHandler(e, rs); } catch (DAP2Exception de) { int status = (de.getErrorCode() == DAP2Exception.NO_SUCH_FILE) ? HttpServletResponse.SC_NOT_FOUND : HttpServletResponse.SC_BAD_REQUEST; if ((de.getErrorCode() == DAP2Exception.UNKNOWN_ERROR) || ((de.getErrorCode() == DAP2Exception.UNDEFINED_ERROR)) && (de.getErrorMessage() != null)) { log.info(de.getErrorMessage()); } response.setStatus(status); dap2ExceptionHandler(de, rs); } catch (ParseException pe) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); parseExceptionHandler(pe, response); } catch (RequestTooLargeException e) { throw e; } catch (java.net.SocketException e) { log.info("SocketException: " + e.getMessage(), e); } catch (IOException e) { String eName = e.getClass().getName(); if (eName.equals("org.apache.catalina.connector.ClientAbortException")) { log.debug("ClientAbortException: " + e.getMessage()); return; } log.error("request= " + rs, e); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (Throwable t) { log.error("request= " + rs, t); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); } } }
OpendapServlet extends AbstractServlet implements InitializingBean { @RequestMapping(value = "**", method = RequestMethod.GET) public void doGet(HttpServletRequest request, HttpServletResponse response) { log.debug("doGet(): User-Agent = " + request.getHeader("User-Agent")); ReqState rs = getRequestState(request, response); try { if (baseURI == null) { URI reqURI = ServletUtil.getRequestURI(request); assert reqURI != null; String baseUriString = request.getContextPath() + request.getServletPath() + "/"; baseURI = reqURI.resolve(baseUriString); log.debug("doGet(): baseURI was set = {}", baseURI); } String dataSet = rs.getDataSet(); String requestSuffix = rs.getRequestSuffix(); if ((dataSet == null) || dataSet.equals("/") || dataSet.equals("")) { doGetDIR(rs); } else if (requestSuffix.equalsIgnoreCase("blob")) { doGetBLOB(rs); } else if (requestSuffix.equalsIgnoreCase("close")) { doClose(rs); } else if (requestSuffix.equalsIgnoreCase("dds")) { doGetDDS(rs); } else if (requestSuffix.equalsIgnoreCase("das")) { doGetDAS(rs); } else if (requestSuffix.equalsIgnoreCase("ddx")) { doGetDDX(rs); } else if (requestSuffix.equalsIgnoreCase("dods")) { doGetDAP2Data(rs); } else if (requestSuffix.equalsIgnoreCase("asc") || requestSuffix.equalsIgnoreCase("ascii")) { doGetASC(rs); } else if (requestSuffix.equalsIgnoreCase("info")) { doGetINFO(rs); } else if (requestSuffix.equalsIgnoreCase("html") || requestSuffix.equalsIgnoreCase("htm")) { doGetHTML(rs); } else if (requestSuffix.equalsIgnoreCase("ver") || requestSuffix.equalsIgnoreCase("version") || dataSet.equalsIgnoreCase("/version") || dataSet.equalsIgnoreCase("/version/")) { doGetVER(rs); } else if (dataSet.equalsIgnoreCase("/help") || dataSet.equalsIgnoreCase("/help/") || dataSet.equalsIgnoreCase("/" + requestSuffix) || requestSuffix.equalsIgnoreCase("help")) { doGetHELP(rs); } else { sendErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "Unrecognized request"); return; } } catch (FileNotFoundException e) { sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } catch (BadURLException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); dap2ExceptionHandler(e, rs); } catch (DAP2Exception de) { int status = (de.getErrorCode() == DAP2Exception.NO_SUCH_FILE) ? HttpServletResponse.SC_NOT_FOUND : HttpServletResponse.SC_BAD_REQUEST; if ((de.getErrorCode() == DAP2Exception.UNKNOWN_ERROR) || ((de.getErrorCode() == DAP2Exception.UNDEFINED_ERROR)) && (de.getErrorMessage() != null)) { log.info(de.getErrorMessage()); } response.setStatus(status); dap2ExceptionHandler(de, rs); } catch (ParseException pe) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); parseExceptionHandler(pe, response); } catch (RequestTooLargeException e) { throw e; } catch (java.net.SocketException e) { log.info("SocketException: " + e.getMessage(), e); } catch (IOException e) { String eName = e.getClass().getName(); if (eName.equals("org.apache.catalina.connector.ClientAbortException")) { log.debug("ClientAbortException: " + e.getMessage()); return; } log.error("request= " + rs, e); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (Throwable t) { log.error("request= " + rs, t); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); } }  }
OpendapServlet extends AbstractServlet implements InitializingBean { @RequestMapping(value = "**", method = RequestMethod.GET) public void doGet(HttpServletRequest request, HttpServletResponse response) { log.debug("doGet(): User-Agent = " + request.getHeader("User-Agent")); ReqState rs = getRequestState(request, response); try { if (baseURI == null) { URI reqURI = ServletUtil.getRequestURI(request); assert reqURI != null; String baseUriString = request.getContextPath() + request.getServletPath() + "/"; baseURI = reqURI.resolve(baseUriString); log.debug("doGet(): baseURI was set = {}", baseURI); } String dataSet = rs.getDataSet(); String requestSuffix = rs.getRequestSuffix(); if ((dataSet == null) || dataSet.equals("/") || dataSet.equals("")) { doGetDIR(rs); } else if (requestSuffix.equalsIgnoreCase("blob")) { doGetBLOB(rs); } else if (requestSuffix.equalsIgnoreCase("close")) { doClose(rs); } else if (requestSuffix.equalsIgnoreCase("dds")) { doGetDDS(rs); } else if (requestSuffix.equalsIgnoreCase("das")) { doGetDAS(rs); } else if (requestSuffix.equalsIgnoreCase("ddx")) { doGetDDX(rs); } else if (requestSuffix.equalsIgnoreCase("dods")) { doGetDAP2Data(rs); } else if (requestSuffix.equalsIgnoreCase("asc") || requestSuffix.equalsIgnoreCase("ascii")) { doGetASC(rs); } else if (requestSuffix.equalsIgnoreCase("info")) { doGetINFO(rs); } else if (requestSuffix.equalsIgnoreCase("html") || requestSuffix.equalsIgnoreCase("htm")) { doGetHTML(rs); } else if (requestSuffix.equalsIgnoreCase("ver") || requestSuffix.equalsIgnoreCase("version") || dataSet.equalsIgnoreCase("/version") || dataSet.equalsIgnoreCase("/version/")) { doGetVER(rs); } else if (dataSet.equalsIgnoreCase("/help") || dataSet.equalsIgnoreCase("/help/") || dataSet.equalsIgnoreCase("/" + requestSuffix) || requestSuffix.equalsIgnoreCase("help")) { doGetHELP(rs); } else { sendErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "Unrecognized request"); return; } } catch (FileNotFoundException e) { sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } catch (BadURLException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); dap2ExceptionHandler(e, rs); } catch (DAP2Exception de) { int status = (de.getErrorCode() == DAP2Exception.NO_SUCH_FILE) ? HttpServletResponse.SC_NOT_FOUND : HttpServletResponse.SC_BAD_REQUEST; if ((de.getErrorCode() == DAP2Exception.UNKNOWN_ERROR) || ((de.getErrorCode() == DAP2Exception.UNDEFINED_ERROR)) && (de.getErrorMessage() != null)) { log.info(de.getErrorMessage()); } response.setStatus(status); dap2ExceptionHandler(de, rs); } catch (ParseException pe) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); parseExceptionHandler(pe, response); } catch (RequestTooLargeException e) { throw e; } catch (java.net.SocketException e) { log.info("SocketException: " + e.getMessage(), e); } catch (IOException e) { String eName = e.getClass().getName(); if (eName.equals("org.apache.catalina.connector.ClientAbortException")) { log.debug("ClientAbortException: " + e.getMessage()); return; } log.error("request= " + rs, e); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (Throwable t) { log.error("request= " + rs, t); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); } }  void afterPropertiesSet(); String getServerVersion(); @RequestMapping(value = "**", method = RequestMethod.GET) void doGet(HttpServletRequest request, HttpServletResponse response); void doGetASC(ReqState rs); void doGetDAS(ReqState rs); void doGetDDS(ReqState rs); void doGetDDX(ReqState rs); void doGetBLOB(ReqState rs); void doGetDAP2Data(ReqState rs); void doGetVER(ReqState rs); void doGetHELP(ReqState rs); void doGetDIR(ReqState rs); void doGetINFO(ReqState rs); void doGetHTML(ReqState rs); String getServerName(); void parseExceptionHandler(ParseException pe, HttpServletResponse response); void dap2ExceptionHandler(DAP2Exception de, ReqState rs); }
OpendapServlet extends AbstractServlet implements InitializingBean { @RequestMapping(value = "**", method = RequestMethod.GET) public void doGet(HttpServletRequest request, HttpServletResponse response) { log.debug("doGet(): User-Agent = " + request.getHeader("User-Agent")); ReqState rs = getRequestState(request, response); try { if (baseURI == null) { URI reqURI = ServletUtil.getRequestURI(request); assert reqURI != null; String baseUriString = request.getContextPath() + request.getServletPath() + "/"; baseURI = reqURI.resolve(baseUriString); log.debug("doGet(): baseURI was set = {}", baseURI); } String dataSet = rs.getDataSet(); String requestSuffix = rs.getRequestSuffix(); if ((dataSet == null) || dataSet.equals("/") || dataSet.equals("")) { doGetDIR(rs); } else if (requestSuffix.equalsIgnoreCase("blob")) { doGetBLOB(rs); } else if (requestSuffix.equalsIgnoreCase("close")) { doClose(rs); } else if (requestSuffix.equalsIgnoreCase("dds")) { doGetDDS(rs); } else if (requestSuffix.equalsIgnoreCase("das")) { doGetDAS(rs); } else if (requestSuffix.equalsIgnoreCase("ddx")) { doGetDDX(rs); } else if (requestSuffix.equalsIgnoreCase("dods")) { doGetDAP2Data(rs); } else if (requestSuffix.equalsIgnoreCase("asc") || requestSuffix.equalsIgnoreCase("ascii")) { doGetASC(rs); } else if (requestSuffix.equalsIgnoreCase("info")) { doGetINFO(rs); } else if (requestSuffix.equalsIgnoreCase("html") || requestSuffix.equalsIgnoreCase("htm")) { doGetHTML(rs); } else if (requestSuffix.equalsIgnoreCase("ver") || requestSuffix.equalsIgnoreCase("version") || dataSet.equalsIgnoreCase("/version") || dataSet.equalsIgnoreCase("/version/")) { doGetVER(rs); } else if (dataSet.equalsIgnoreCase("/help") || dataSet.equalsIgnoreCase("/help/") || dataSet.equalsIgnoreCase("/" + requestSuffix) || requestSuffix.equalsIgnoreCase("help")) { doGetHELP(rs); } else { sendErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "Unrecognized request"); return; } } catch (FileNotFoundException e) { sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } catch (BadURLException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); dap2ExceptionHandler(e, rs); } catch (DAP2Exception de) { int status = (de.getErrorCode() == DAP2Exception.NO_SUCH_FILE) ? HttpServletResponse.SC_NOT_FOUND : HttpServletResponse.SC_BAD_REQUEST; if ((de.getErrorCode() == DAP2Exception.UNKNOWN_ERROR) || ((de.getErrorCode() == DAP2Exception.UNDEFINED_ERROR)) && (de.getErrorMessage() != null)) { log.info(de.getErrorMessage()); } response.setStatus(status); dap2ExceptionHandler(de, rs); } catch (ParseException pe) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); parseExceptionHandler(pe, response); } catch (RequestTooLargeException e) { throw e; } catch (java.net.SocketException e) { log.info("SocketException: " + e.getMessage(), e); } catch (IOException e) { String eName = e.getClass().getName(); if (eName.equals("org.apache.catalina.connector.ClientAbortException")) { log.debug("ClientAbortException: " + e.getMessage()); return; } log.error("request= " + rs, e); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (Throwable t) { log.error("request= " + rs, t); sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); } }  void afterPropertiesSet(); String getServerVersion(); @RequestMapping(value = "**", method = RequestMethod.GET) void doGet(HttpServletRequest request, HttpServletResponse response); void doGetASC(ReqState rs); void doGetDAS(ReqState rs); void doGetDDS(ReqState rs); void doGetDDX(ReqState rs); void doGetBLOB(ReqState rs); void doGetDAP2Data(ReqState rs); void doGetVER(ReqState rs); void doGetHELP(ReqState rs); void doGetDIR(ReqState rs); void doGetINFO(ReqState rs); void doGetHTML(ReqState rs); String getServerName(); void parseExceptionHandler(ParseException pe, HttpServletResponse response); void dap2ExceptionHandler(DAP2Exception de, ReqState rs); static public org.slf4j.Logger log; }