Package de.fuberlin.wiwiss.d2rq.download

Examples of de.fuberlin.wiwiss.d2rq.download.DownloadContentQuery


  private boolean handleDownload(String resourceURI, HttpServletResponse response, D2RServer server) throws IOException {
    Mapping m = D2RServer.retrieveSystemLoader(getServletContext()).getMapping();
    for (Resource r: m.downloadMapResources()) {
      DownloadMap d = m.downloadMap(r);
      DownloadContentQuery q = new DownloadContentQuery(d, resourceURI);
      if (q.hasContent()) {
        response.setContentType(q.getMediaType() != null ? q.getMediaType() : "application/octet-stream");
        InputStream is = q.getContentStream();
        OutputStream os = response.getOutputStream();
        final byte[] buffer = new byte[0x10000];
        int read;
        do {
          read = is.read(buffer, 0, buffer.length);
          if (read>0) {
            os.write(buffer, 0, read);
          }
        } while (read >= 0);
        is.close();
        q.close();
        return true;
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.download.DownloadContentQuery

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.