1 package org.paneris.bibliomania.pagination; 2 3 import java.io.File; 4 import java.io.FileNotFoundException; 5 import java.io.FileReader; 6 import java.io.IOException; 7 8 import org.melati.Melati; 9 import org.melati.util.IoUtils; 10 import org.paneris.bibliomania.BibliomaniaDatabase; 11 import org.paneris.bibliomania.BibliomaniaServlet; 12 import org.webmacro.WebMacroException; 13 import org.webmacro.servlet.HandlerException; 14 import org.webmacro.servlet.WebContext; 15 16 public class ShowTexLog extends BibliomaniaServlet { 17 18 private static final long serialVersionUID = 1L; 19 20 protected String area() { 21 return "Admin"; 22 } 23 24 protected String bibliomaniaHandle(Melati melati, WebContext context) 25 throws WebMacroException { 26 File log = new File(context.getForm("texLogFile")); 27 if (!((BibliomaniaDatabase)melati.getDatabase()).pagination(). 28 isTempFile(log)) 29 throw new HandlerException("access to " + log + " not granted"); 30 31 try { 32 context.put("log", new String(IoUtils.slurp(new FileReader(log), 4096))); 33 } catch (FileNotFoundException e) { 34 throw new HandlerException("File" + log + " not found:" + e.toString()); 35 } catch (IOException e) { 36 throw new HandlerException(e.toString()); 37 } 38 39 return bibliomaniaTemplate("pagination/TexLog.wm"); 40 } 41 }