Definition at line 23 of file FileDownloader.java.
Public Member Functions | |
void | init (ServletConfig config) throws ServletException |
void | download (HttpServletRequest request, HttpServletResponse res) |
Protected Member Functions | |
void | doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException |
void | doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException |
Static Private Member Functions | |
File | makeCards (HttpServletRequest request, String tarRoot) throws IOException, JetWebException |
Private Attributes | |
String | destinationDirName |
File | destinationDir |
PrintWriter | out |
int | paperId |
|
Handles the HTTP
Definition at line 51 of file FileDownloader.java. References FileDownloader.download(). 00053 { 00054 download(request,response); 00055 }
|
|
Handles the HTTP
Definition at line 41 of file FileDownloader.java. References FileDownloader.download(). 00043 { 00044 download(request,response); 00045 }
|
|
Make a tarball and send it as a download attachment. Uses ant tools. Definition at line 62 of file FileDownloader.java. References FileDownloader.makeCards(), and FileDownloader.out. Referenced by FileDownloader.doGet(), and FileDownloader.doPost(). 00062 { 00063 00064 String tarRoot; 00065 File tarDir; 00066 00067 // Could test on the servlet request here and make different tarballs as required. 00068 00069 try{ 00070 00071 if (true) { 00072 tarRoot = "HZSteerCards"; 00073 tarDir = makeCards(request,tarRoot); 00074 } 00075 00076 // Set the headers. 00077 res.setContentType("application/x-download"); 00078 res.setHeader("Content-Disposition", "attachment; filename=" + tarRoot+".tar"); 00079 00080 // Send the file. 00081 OutputStream out = res.getOutputStream(); 00082 TarOutputStream tos = new TarOutputStream(out); 00083 00084 TarEntry te = new TarEntry(tarDir); 00085 for (TarEntry newte : te.getDirectoryEntries()){ 00086 for (TarEntry newte2 : newte.getDirectoryEntries()){ 00087 00088 if (!newte2.isDirectory()) { 00089 TarEntry go = new TarEntry(tarRoot+"/" 00090 +newte2.getFile().getParentFile().getName() 00091 +"/"+newte2.getFile().getName()); 00092 go.setSize(newte2.getFile().length()); 00093 tos.putNextEntry(go); 00094 //System.out.println("Loop1 "+go.getName()); 00095 FileInputStream fIn = new FileInputStream(newte2.getFile()); 00096 byte[] buffer = new byte[8 * 1024]; 00097 int count = 0; 00098 System.out.println(go.getName()); 00099 do { 00100 tos.write(buffer, 0, count); 00101 count = fIn.read(buffer, 0, buffer.length); 00102 } while (count != -1); 00103 tos.closeEntry(); 00104 } 00105 } 00106 } 00107 00108 tos.close(); 00109 00110 } catch (Exception e) { 00111 try { 00112 res.setContentType("text/html"); 00113 res.setHeader("Content-Disposition",""); 00114 e.printStackTrace(System.out); 00115 e.printStackTrace(res.getWriter()); 00116 HTMLErrorWriter.write(res.getWriter(),e); 00117 } catch (IOException io) { 00118 System.out.println(io); 00119 } 00120 } 00121 }
|
|
Definition at line 31 of file FileDownloader.java. 00031 {
00032 super.init(config);
00033 // Set up configuration with servlet mode on.
00034 JetWebConfig.init();
00035 }
|
|
Definition at line 124 of file FileDownloader.java. References ResultSearchPattern.getPhotonPDFList(), and ResultSearchPattern.getProtonPDFList(). Referenced by FileDownloader.download(). 00125 { 00126 00127 File workDir = File.createTempFile(tarRoot,""); 00128 workDir.delete(); 00129 workDir.mkdir(); 00130 00131 // loop over all known generators 00132 for (String name : Generator.allNames()){ 00133 00134 // make a directory called name-version 00135 for (String version : Generator.allVersions(name)){ 00136 00137 File genDir = new File(workDir.getPath(),name+"-"+version); 00138 genDir.mkdir(); 00139 00140 Model model = new Model(); 00141 model.getProtonPDFList().add(JetWebConfig.defaultProtonPDF); 00142 model.getPhotonPDFList().add(JetWebConfig.defaultPhotonPDF); 00143 00144 Generator gen = Generator.Maker(name,version); 00145 gen.setSoftDefaults(); 00146 00147 // loop over all known valid processtypes and write a card file 00148 for (MCProcessType proc: MCProcessType.getAll(true)){ 00149 String cardName = genDir.getPath()+"/"+proc+".input"; 00150 00151 BufferedWriter cards = 00152 new BufferedWriter(new FileWriter(cardName) ); 00153 gen.writeSteering(cards,model,proc); 00154 cards.newLine(); 00155 cards.close(); 00156 } 00157 } 00158 } 00159 // end loops 00160 return workDir; 00161 }
|
|
Definition at line 26 of file FileDownloader.java. |
|
Definition at line 25 of file FileDownloader.java. |
|
Definition at line 28 of file FileDownloader.java. Referenced by FileDownloader.download(). |
|
Definition at line 29 of file FileDownloader.java. |
Generated Wed Jan 17 09:14:27 GMT 2007