1 23 package com.sun.enterprise.tools.admingui.servlet; 24 25 import java.io.File ; 26 import java.io.FileInputStream ; 27 import java.io.InputStream ; 28 29 import javax.servlet.ServletRequest ; 30 31 32 35 public class DiagnosticReportContentSource implements DownloadServlet.ContentSource { 36 37 44 public String getId() { 45 return "diagReport"; } 47 48 55 public InputStream getInputStream(DownloadServlet.Context ctx) { 56 ctx.setAttribute(DownloadServlet.EXTENSION, "jar"); 59 ServletRequest request = ctx.getServletRequest(); 61 String filename = request.getParameter("diagReportConfirmation." 62 + "diagReportConfirmation.report"); if ((filename == null) || (filename.trim().length() == 0)) { 64 throw new IllegalArgumentException ( 65 "Report name not specified!"); } 67 68 InputStream stream = null; 70 try { 71 stream = new FileInputStream (filename); 72 } catch (Exception ex) { 73 throw new RuntimeException (ex); 74 } 75 76 ctx.setAttribute("stream", stream); 79 return stream; 81 } 82 83 88 public void cleanUp(DownloadServlet.Context ctx) { 89 InputStream stream = 91 (InputStream ) ctx.getAttribute("stream"); 93 if (stream != null) { 95 try { 96 stream.close(); 97 } catch (Exception ex) { 98 } 100 } 101 102 ctx.removeAttribute("stream"); } 105 106 113 public long getLastModified(DownloadServlet.Context context) { 114 return -1; 115 } 116 } 117 | Popular Tags |