From 90c249f74bda9d718b0392bf1f70c3d44ec5cb71 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Wed, 30 Jun 2021 10:09:27 +0000
Subject: [PATCH] auf Attribute des HttpContext umgestellt

---
 src/de/uhilger/httpserver/adoc/AdocActor.java |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/de/uhilger/httpserver/adoc/AdocActor.java b/src/de/uhilger/httpserver/adoc/AdocActor.java
index 66bbe00..94944f9 100644
--- a/src/de/uhilger/httpserver/adoc/AdocActor.java
+++ b/src/de/uhilger/httpserver/adoc/AdocActor.java
@@ -17,7 +17,10 @@
  */
 package de.uhilger.httpserver.adoc;
 
+import com.sun.net.httpserver.HttpExchange;
+import de.uhilger.httpserver.base.HttpResponder;
 import java.io.File;
+import java.io.IOException;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -45,6 +48,16 @@
   private static final String DOT = ".";
   public static final String HTML = "html";
   public static final String PDF = "pdf";
+  
+  public void handle(HttpExchange e, String fileBase, String fileName) throws IOException {
+    File adocfile = new File(fileBase, fileName);
+    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);
+  }
   
   public File getTargetFile(File adocfile, String ext) {
     String nameext = adocfile.getName();
@@ -74,6 +87,7 @@
       die HTML-Datei noch nicht existiert
     */
     if(!htmlfile.exists() || adocfile.lastModified() > htmlfile.lastModified()) {
+      logger.fine("calling transform for " + absname);
       transform(absname);
     }
  
@@ -121,6 +135,7 @@
    * nach PDF transformiert werden soll
    */
   private void transform(String fileName, String backend) {    
+    logger.fine("fileName: " + fileName + ", backend: " + backend);
     Map<String, Object> attributes;
     File outFile = new File(fileName);
     String thisDirName = outFile.getParent();
@@ -150,9 +165,14 @@
               .attributes(attributes).asMap();
     }
     
+    File adcf = new File(fileName);
+    logger.fine("before asciidoctor create, adcf: " + adcf.getAbsolutePath());
     Asciidoctor asciidoctor = create();    
+    logger.fine("asciidoctor created.");
     asciidoctor.requireLibrary("asciidoctor-diagram");
-    asciidoctor.convertFile(new File(fileName), options);    
+    logger.fine("asciidoctor requireLibrary diagram passed.");
+    logger.fine("calling asciidoctor.convert for file " + adcf.getAbsolutePath());
+    asciidoctor.convertFile(adcf, options);    
   }
   
 }

--
Gitblit v1.9.3