package org.autoplot.servlet; import java.io.IOException; import java.io.PrintWriter; import java.text.ParseException; import java.util.Collections; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.das2.datum.Datum; import org.das2.datum.DatumRange; import org.das2.datum.DatumRangeUtil; import org.das2.datum.TimeParser; import org.das2.datum.Units; import org.das2.fsm.FileStorageModel; import org.das2.util.filesystem.FileSystem; /** * URI Templates servlet implements the hybrid generate/parse method * for resolving URIs. * @author jbf */ public class URITemplatesServlet extends HttpServlet { private boolean supportsGenerate( String s ) { return !(s.contains("$v") || s.contains("$(v") || s.contains("$x") || s.contains("$(x") || s.contains(";sparse") || s.contains(",sparse")); // TODO: make canonical!!! } private int doParse( DatumRange trdr, String root, String template, PrintWriter out ) throws IOException { int count= 0; FileSystem fs= FileSystem.create( root ); FileStorageModel fsm= FileStorageModel.create( fs, template ); fsm.setContext( trdr ); String[] names= fsm.getNamesFor( trdr ); for ( String n : names ) { out.printf( "
GET
and POST
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("");
out.println("");
out.println("");
out.println("search limited to %s
\n", timerange ); if ( parseUri.length()==0 ) { out.printf( "generation used for entire URI
\n" ); } else { out.printf( "generation used for " + generateUri + ", parsing for " +parseUri + "
\n" ); } out.printf( "Filename | Time Range | Version |
"+st + " | "+dr + " | N/A |
Search limited to 10000 results. |
GET
method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP POST
method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}//