PDF ergaenzt (noch experimentell)
| | |
| | | public static final String HTML = "html"; |
| | | public static final String PDF = "pdf"; |
| | | |
| | | public void handle(HttpExchange e, String fileBase, String fileName) throws IOException { |
| | | public void handle(HttpExchange e, String fileBase, String fileName, boolean pdf) throws IOException { |
| | | File adocfile = new File(fileBase, fileName); |
| | | logger.fine("adocfile: " + adocfile.getAbsolutePath()); |
| | | AdocActor actor = new AdocActor(); |
| | | File outfile = actor.getTargetFile(adocfile, AdocActor.HTML); |
| | | File outfile; |
| | | if(pdf) { |
| | | outfile = actor.getTargetFile(adocfile, AdocActor.PDF); |
| | | } else { |
| | | outfile = actor.getTargetFile(adocfile, AdocActor.HTML); |
| | | } |
| | | logger.fine("outfile: " + outfile.getAbsolutePath()); |
| | | HttpResponder fs = new HttpResponder(); |
| | | fs.serveFile(e, outfile); |
| | |
| | | String fileBase = exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(); |
| | | AdocActor actor = new AdocActor(); |
| | | HttpHelper helper = new HttpHelper(); |
| | | actor.processAdocFile(new File(fileBase, helper.getFileName(exchange)), Boolean.FALSE.toString()); |
| | | if(query != null && query.equalsIgnoreCase("pdf=true")) { |
| | | actor.processAdocFile(new File(fileBase, helper.getFileName(exchange)), Boolean.TRUE.toString()); |
| | | } else { |
| | | actor.processAdocFile(new File(fileBase, helper.getFileName(exchange)), Boolean.FALSE.toString()); |
| | | } |
| | | } |
| | | } |
| | | chain.doFilter(exchange); |
| | |
| | | String ctxPath = e.getHttpContext().getPath(); |
| | | String uriPath = e.getRequestURI().getPath(); |
| | | String fName = uriPath.substring(ctxPath.length()); |
| | | |
| | | |
| | | AdocActor actor = new AdocActor(); |
| | | actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName); |
| | | String query = uri.getQuery(); |
| | | if(query != null && query.equalsIgnoreCase("pdf=true")) { |
| | | actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName, true); |
| | | } else { |
| | | actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName, false); |
| | | } |
| | | } |
| | | |
| | | |