| | |
| | | * Dazu muss ein AdocHandler mit dem PatternDelegator an einen Pfad |
| | | * geknuepft werden, der Dateien mit der Endung adoc bezeichnet. |
| | | * |
| | | * Ein dafuer geeigneter regulaerer Ausdruck ist z.B. <br /> |
| | | * Ein dafuer geeigneter regulaerer Ausdruck ist z.B. |
| | | * <pre> |
| | | * .+\\.adoc |
| | | * </pre> |
| | |
| | | * Zum Erzeugen der HTML-Version muss ein AdocFilter mit dem HttpContext |
| | | * verbunden sein, an den der AdocHandler gebunden ist. |
| | | * |
| | | * Benoetigt das Attribut |
| | | * FileHandler.ATTR_FILE_BASE |
| | | * |
| | | * @author Ulrich Hilger |
| | | * @version 1, 16.06.2021 |
| | | */ |
| | |
| | | |
| | | private static final Logger logger = Logger.getLogger(AdocHandler.class.getName()); |
| | | |
| | | /** |
| | | * Benoetigt das Attribut |
| | | * FileHandler.ATTR_FILE_BASE |
| | | */ |
| | | public AdocHandler() { |
| | | //super(absoluteDirectoryPathAndName); |
| | | } |
| | | |
| | | @Override |
| | | public void handle(HttpExchange e) throws IOException { |
| | | URI uri = e.getRequestURI(); |
| | | logger.fine(uri.toString()); |
| | | //String query = uri.getQuery(); |
| | | //String[] params = query.split("?&"); // hier noch Regex ermitteln |
| | | //String requestPathStr = uri.getPath(); |
| | | //logger.fine("filter: " + requestUriStr); |
| | | |
| | | String ctxPath = e.getHttpContext().getPath(); |
| | | String uriPath = e.getRequestURI().getPath(); |
| | | String fName = uriPath.substring(ctxPath.length()); |
| | | |
| | | |
| | | //if(requestPathStr.toLowerCase().endsWith(AdocFilter.ADOC)) { |
| | | AdocActor actor = new AdocActor(); |
| | | actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName); |
| | | /* |
| | | File adocfile = new File(fileBase, getFileName(e)); |
| | | logger.fine("adocfile: " + adocfile.getAbsolutePath()); |
| | | AdocActor actor = new AdocActor(); |
| | | File outfile = actor.getTargetFile(adocfile, AdocActor.HTML); |
| | | logger.fine("outfile: " + outfile.getAbsolutePath()); |
| | | HttpResponder fs = new HttpResponder(); |
| | | fs.serveFile(e, outfile); |
| | | */ |
| | | //} else { |
| | | // super.handle(e); // andere Inhalte zu FileHandler delegieren |
| | | //} |
| | | |
| | | AdocActor actor = new AdocActor(); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |