Package uk.ac.cam.ch.wwmm.ptclib.io

Examples of uk.ac.cam.ch.wwmm.ptclib.io.ResourceGetter


      }
     
      //if(true) return;

     
      ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/oscar3server/resources/");
      Document filePlaces = rg.getXMLDocument("filePlaces.xml");
      Elements ee = filePlaces.getRootElement().getChildElements();
      String place = null;
      String reload = null;
      for(int i=0;i<ee.size();i++) {
        Element e = ee.get(i);
        String pfn = e.getAttributeValue("name");
        if(Oscar3Props.getInstance().verbose) System.out.println(pfn);
        if((pfn.startsWith("*.") && filename.endsWith(pfn.substring(1))) || pfn.equals(filename)) {
          place = e.getAttributeValue("place");
          reload = e.getAttributeValue("reload");
          break;
        }
      }
      if(place == null) {
        PrintWriter out = response.getWriter();
        out.println("I don't know where to put " + filename);
      } else {
        ResourceGetter nrg = new ResourceGetter(place);
        OutputStream os = nrg.getOutputStream(filename);
        assert(is != null);
        //InputStream is = null;
        //InputStream is = mpr.getInputStream("file");
        int c = is.read();
        while(c != -1) {
View Full Code Here


      String pathTo = path.substring(0, lastSlash+1);
      String name = path.substring(lastSlash+1);
     
      if(Oscar3Props.getInstance().verbose) System.out.println(name);
     
      ResourceGetter rg = new ResourceGetter(pathTo);
     
      if(name.length() > 0 && !name.contains(".")) {
        if(Oscar3Props.getInstance().verbose) System.out.println("Foo!");
        if(Oscar3Props.getInstance().verbose) System.out.println(request.getServletPath());
        response.sendRedirect(request.getServletPath() + request.getPathInfo() + "/");
        return;
      }
     
      if(name.length() == 0) {
        PrintWriter out = response.getWriter();
        response.setContentType("text/html");
        out.write("<html><head><title>Oscar3 resources: " + path + "</title><head>");
        out.write("<body><p>Oscar3 resources: <a href='..'>" + path + "</a></p><ul>");
        for(String s : rg.getFiles()) {
          String maybeSlash = "";
          if(!s.contains(".")) {
            maybeSlash = "/";
          } else if(s.endsWith(".class") || s.equals("package.html") || s.equals("overview.html")) {
            continue;
          }
          out.write("<li><a href='" + s + maybeSlash + "'>" + s + "</a></li>");
        }
        out.write("</ul></body></html>");
        return;
      }
     
      if(name.endsWith(".txt")) {
        String out = rg.getString(name);       
        response.setContentType("text/plain");
        response.getWriter().println(out);       
      } else if(name.endsWith(".xml")) {
        String out = rg.getString(name);       
        response.setContentType("application/xml");
        response.getWriter().println(out);
      } else if(name.endsWith(".xml")) {
        String out = rg.getString(name);       
        response.setContentType("application/xslt+xml");
        response.getWriter().println(out);
      } else if(name.endsWith(".dtd")) {
        String out = rg.getString(name);       
        response.setContentType("application/xml-dtd");
        response.getWriter().println(out);
      } else {
        String out = rg.getString(name);       
        response.setContentType("text/plain");
        response.getWriter().println(out);               
      }
     
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.ptclib.io.ResourceGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.