From 5adf10229cbd122b2ac2981fdc6392324356945b Mon Sep 17 00:00:00 2001
From: ulrich
Date: Sun, 09 Jan 2022 14:32:52 +0000
Subject: [PATCH] Logging entfernt

---
 src/de/uhilger/httpserver/cm/OrdnerBearbeiter.java |   18 +++-----
 src/de/uhilger/httpserver/cm/FileManager.java      |   77 ++++++++++++++++++--------------------
 src/de/uhilger/httpserver/cm/FileTransporter.java  |    9 +---
 3 files changed, 47 insertions(+), 57 deletions(-)

diff --git a/src/de/uhilger/httpserver/cm/FileManager.java b/src/de/uhilger/httpserver/cm/FileManager.java
index 2668d3b..bef1009 100644
--- a/src/de/uhilger/httpserver/cm/FileManager.java
+++ b/src/de/uhilger/httpserver/cm/FileManager.java
@@ -105,9 +105,6 @@
  */
 public class FileManager extends FileHandler implements ThreadListener {
 
-  /* Der Logger fuer diesen ListFileHandler */
-  private static final Logger logger = Logger.getLogger(FileManager.class.getName());
-
   /*
   private static final String[] specialChars = {new String("\u00c4"), new String("\u00d6"),
     new String("\u00dc"), new String("\u00e4"), new String("\u00f6"), new String("\u00fc"), new String("\u00df")};
@@ -158,7 +155,7 @@
       String userId = e.getPrincipal().getUsername();
       if(auth.hasRole(userId, e.getHttpContext().getAttributes().get(ATTR_ROLE).toString())) {
         String method = e.getRequestMethod();
-        logger.fine("method: " + method);
+        //logger.fine("method: " + method);
         HttpHelper helper = new HttpHelper();
         switch (method) {
           case HttpHelper.HTTP_GET:
@@ -187,7 +184,7 @@
     if (query != null) {
       String[] params = query.split("=");
       for (String param : params) {
-        logger.fine("param: " + param);
+        //logger.fine("param: " + param);
       }
       switch (params[0]) {
         case P_COPY:
@@ -199,18 +196,18 @@
         case P_DUPLICATE:
           if(Boolean.parseBoolean(params[1])) {
             String neuerDateiName = duplizieren(exchange, helper);
-            logger.fine("neuer Name: " + neuerDateiName);
+            //logger.fine("neuer Name: " + neuerDateiName);
             standardHeaderUndAntwort(exchange, SC_OK, neuerDateiName);
           }
           break;
         case P_RENAME:
           String neuerDateiName = umbenennen(exchange, helper, params[1]);
-          logger.fine("neuer Name: " + neuerDateiName);
+          //logger.fine("neuer Name: " + neuerDateiName);
           standardHeaderUndAntwort(exchange, SC_OK, neuerDateiName);
           break;
         case P_ZIP:
           String path = exchange.getRequestURI().toString();
-          logger.fine(path);
+          //logger.fine(path);
           String antwort = packFolder(helper.getFileName(exchange), path, exchange);
           if(antwort.equalsIgnoreCase("ok")) {
             standardHeaderUndAntwort(exchange, SC_OK, antwort);
@@ -220,7 +217,7 @@
           break;
         case P_UNZIP:
           path = exchange.getRequestURI().toString();
-          logger.fine(path);
+          //logger.fine(path);
           antwort = extractZipfile(helper.getFileName(exchange), path, exchange);
           if(antwort.equalsIgnoreCase("ok")) {
             standardHeaderUndAntwort(exchange, SC_OK, antwort);
@@ -259,13 +256,13 @@
 
   private void liste(HttpExchange e, HttpHelper helper) throws IOException {
     String path = e.getRequestURI().toString();
-    logger.fine(path);
+    //logger.fine(path);
     String fName = helper.getFileName(e);
     String dirListPath = e.getHttpContext().getPath() + fName;
     if (path.endsWith(STR_SLASH)) {      
-      logger.fine("fName: " + fName);
+      //logger.fine("fName: " + fName);
       File dir = new File(e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName);
-      logger.fine("absPath: " + dir.getAbsolutePath());
+      //logger.fine("absPath: " + dir.getAbsolutePath());
       File[] files = dir.listFiles(new ImageFileFilter());
       if(files != null && files.length > 0) {
         Arrays.sort(files);
@@ -323,7 +320,7 @@
         String fromName = fName.replace(ImageActor.B64, "");
         File fromFile = new File(e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fromName);
         File toFile = new File(e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName);
-        logger.fine("from " + fromFile.getAbsolutePath() + ", to " + toFile.getAbsolutePath());
+        //logger.fine("from " + fromFile.getAbsolutePath() + ", to " + toFile.getAbsolutePath());
         if(!toFile.exists()) {
           actor.b64Image(fromFile, toFile);
         }
@@ -387,20 +384,20 @@
   private void emptyListResponse(HttpExchange e) throws IOException {
     HttpResponder r = new HttpResponder();
     String json = "{}";
-    logger.log(Level.FINE, "json: ''{0}''", json);
+    //logger.log(Level.FINE, "json: ''{0}''", json);
     r.antwortSenden(e, SC_OK, json);        
   }
 
   private void speichern(HttpExchange exchange, HttpHelper helper) throws IOException {
     String fileName = helper.getFileName(exchange);
-    logger.info("fileName: " + fileName);
+    //logger.info("fileName: " + fileName);
 
     // file ist die Datei, um die es geht
     File file = new File(exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fileName);
 
     String method = exchange.getRequestMethod();
     if (fileName.endsWith(STR_SLASH)) {
-      logger.info("neuer Ordner: " + file.getAbsolutePath());
+      //logger.info("neuer Ordner: " + file.getAbsolutePath());
       // neuen Ordner erstellen oder ablehnen, wenn der Ordner schon existiert
       if (method.equalsIgnoreCase(HttpHelper.HTTP_POST)) {
         if (!file.exists()) {
@@ -415,7 +412,7 @@
         standardHeaderUndAntwort(exchange, SC_METHOD_NOT_ALLOWED, antwort);        
       }
     } else {
-      logger.info("Datei speichern: " + file.getAbsolutePath());
+      //logger.info("Datei speichern: " + file.getAbsolutePath());
       // Datei speichern
       if (method.equalsIgnoreCase(HttpHelper.HTTP_POST)) {
         if (file.exists()) {
@@ -447,9 +444,9 @@
 
       // dekodieren
       String content = sb.toString();
-      logger.fine(content);
+      //logger.fine(content);
       String decoded = URLDecoder.decode(content, UTF8);
-      logger.fine(decoded);
+      //logger.fine(decoded);
 
       // in Datei schreiben
       byte[] bytes = decoded.getBytes();
@@ -466,7 +463,7 @@
   }
 
   private void copyOrMove(HttpExchange exchange, String quelle, String ziel, int op) throws IOException {
-    logger.fine("quelle: " + quelle + ", ziel: " + ziel);
+    //logger.fine("quelle: " + quelle + ", ziel: " + ziel);
     String[] dateiNamen = dateiliste(exchange);
     copyOrMoveFiles(quelle, ziel, dateiNamen, op, exchange);
     standardHeaderUndAntwort(exchange, SC_OK, "Dateien verarbeitet.");
@@ -478,9 +475,9 @@
     File targetDir = new File(e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), toPath);
     for (String fileName : fileNames) {
       File srcFile = new File(srcDir, fileName);
-      logger.fine("srcFile: " + srcFile);
+      //logger.fine("srcFile: " + srcFile);
       if (srcFile.isDirectory()) {
-        logger.fine("srcFile is directory.");
+        //logger.fine("srcFile is directory.");
         OrdnerBearbeiter bearbeiter = new OrdnerBearbeiter();
         bearbeiter.setTargetDir(targetDir.toPath());
         bearbeiter.setOperation(operation);
@@ -518,7 +515,7 @@
 
   private String[] dateiliste(HttpExchange exchange) throws IOException {
     String body = new HttpHelper().bodyLesen(exchange);
-    logger.fine("dateien: " + body);
+    //logger.fine("dateien: " + body);
     Gson gson = new Gson();
     return gson.fromJson(body, String[].class);
   }
@@ -562,19 +559,19 @@
     int newdotpos = newName.lastIndexOf(STR_DOT);
     String newfname = newName.substring(0, newdotpos);
     String newext = newName.substring(newdotpos);
-    logger.fine("newfname: " + newfname + ", newext: " + newext);
+    //logger.fine("newfname: " + newfname + ", newext: " + newext);
     
     String fnameext = targetFile.getName();
     int dotpos = fnameext.lastIndexOf(STR_DOT);
     String fname = fnameext.substring(0, dotpos);
     String ext = fnameext.substring(dotpos);
-    logger.fine("fname: " + fname + ", ext: " + ext);
+    //logger.fine("fname: " + fname + ", ext: " + ext);
     
     DirectoryStream<Path> stream = Files.newDirectoryStream(targetDir.toPath(), fname + "*" + ext); //"*.{txt,doc,pdf,ppt}"
     for (Path path : stream) {
-      logger.fine(path.getFileName().toString());
+      //logger.fine(path.getFileName().toString());
       alt = path.getFileName().toString();
-      logger.fine("alt: " + alt);
+      //logger.fine("alt: " + alt);
       if(alt.contains(ImageActor.TN)) {
         neu = newfname + ImageActor.TN + newext;
       } else if (alt.contains(ImageActor.KL)) {
@@ -599,13 +596,13 @@
   private String deleteFiles(String relPath, List<String> fileNames, HttpExchange e) {
     String result = null;
     try {
-      logger.fine(fileNames.toString());
+      //logger.fine(fileNames.toString());
       if (!relPath.startsWith(STR_DOT)) {
         File targetDir = new File(e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), relPath); // getTargetDir(relPath);
-        logger.fine("targetDir: " + targetDir);
+        //logger.fine("targetDir: " + targetDir);
         for (String fileName : fileNames) {
           File targetFile = new File(targetDir, fileName);
-          logger.fine(targetFile.getAbsolutePath());
+          //logger.fine(targetFile.getAbsolutePath());
           if (targetFile.isDirectory()) {
             OrdnerBearbeiter bearbeiter = new OrdnerBearbeiter();
             bearbeiter.setOperation(OP_DELETE);
@@ -629,7 +626,7 @@
         result = "deleted";
       }
     } catch (Throwable ex) {
-      logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
+      //logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
     }
     return result;
   }
@@ -639,10 +636,10 @@
     int dotpos = fnameext.lastIndexOf(STR_DOT);
     String fname = fnameext.substring(0, dotpos);
     String ext = fnameext.substring(dotpos);
-    logger.fine("fname: " + fname + ", ext: " + ext);
+    //logger.fine("fname: " + fname + ", ext: " + ext);
     DirectoryStream<Path> stream = Files.newDirectoryStream(targetDir.toPath(), fname + "*" + ext); //"*.{txt,doc,pdf,ppt}"
     for (Path path : stream) {
-      logger.fine(path.getFileName().toString());
+      //logger.fine(path.getFileName().toString());
       Files.delete(path);
     }
     stream.close();
@@ -653,11 +650,11 @@
     int dotpos = fnameext.lastIndexOf(STR_DOT);
     String fname = fnameext.substring(0, dotpos);
     String ext = fnameext.substring(dotpos);
-    logger.fine("fname: " + fname + ", ext: " + ext);
+    //logger.fine("fname: " + fname + ", ext: " + ext);
     Path targetPath = targetDir.toPath();
     DirectoryStream<Path> stream = Files.newDirectoryStream(srcDir.toPath(), fname + "*" + ext); //"*.{txt,doc,pdf,ppt}"
     for (Path path : stream) {
-      logger.fine(path.getFileName().toString());
+      //logger.fine(path.getFileName().toString());
       //Files.delete(path);
       Files.move(path, targetPath.resolve(path.getFileName()));
     }
@@ -673,7 +670,7 @@
   /* --------- ZIP entpacken ---------------- */
   
   public String extractZipfile(String fName, String relPath, HttpExchange e) {  
-    logger.fine("fName: " + fName + ", relPath: " + relPath);
+    //logger.fine("fName: " + fName + ", relPath: " + relPath);
     String result = null;
     if (!relPath.startsWith(".")) {    
       try {
@@ -687,7 +684,7 @@
         }
       } catch(Exception ex) {
         result = ex.getLocalizedMessage();
-        logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
+        //logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
       }
     } else {
       result = "Falsche relative Pfadangabe.";
@@ -759,11 +756,11 @@
     if (!relPath.startsWith(".")) {    
       try {        
         //String fName = getFileName(e);
-        logger.fine("fName: " + fName);
+        //logger.fine("fName: " + fName);
         if (fName.endsWith(STR_SLASH)) {
           File dir = new File(e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName);
           if(dir.isDirectory()) {
-            logger.fine("absPath: " + dir.getAbsolutePath());
+            //logger.fine("absPath: " + dir.getAbsolutePath());
             File parentDir = dir.getParentFile();
             StringBuilder fname = new StringBuilder();
             fname.append(dir.getName());
@@ -779,7 +776,7 @@
         }
       } catch(Exception ex) {
         String result = ex.getLocalizedMessage();
-        logger.log(Level.SEVERE, result, ex);
+        //logger.log(Level.SEVERE, result, ex);
         return result;
       }
     } else {
diff --git a/src/de/uhilger/httpserver/cm/FileTransporter.java b/src/de/uhilger/httpserver/cm/FileTransporter.java
index d32e384..5b74f5f 100644
--- a/src/de/uhilger/httpserver/cm/FileTransporter.java
+++ b/src/de/uhilger/httpserver/cm/FileTransporter.java
@@ -18,7 +18,6 @@
 package de.uhilger.httpserver.cm;
 
 import java.io.File;
-import java.util.logging.Logger;
 
 /**
  * FileTransporter
@@ -27,8 +26,6 @@
  * @version 1, 04.07.2021
  */
 public class FileTransporter {
-
-  private static final Logger logger = Logger.getLogger(FileTransporter.class.getName());
 
   /**
    * Einen Namen fuer eine Datei erzeugen, der noch nicht existiert.
@@ -48,14 +45,14 @@
   public File getNewFileName(File file) {
     File dir = file.getParentFile();
     String targetName = file.getName();
-    logger.fine("targetName: " + targetName);
+    //logger.fine("targetName: " + targetName);
     String ext = "";
     int dotpos = targetName.indexOf(".");
     if (dotpos > -1) {
       ext = targetName.substring(dotpos);
       targetName = targetName.substring(0, dotpos);
     }
-    logger.fine("targetName: " + targetName + ", ext: " + ext);
+    //logger.fine("targetName: " + targetName + ", ext: " + ext);
     int i = 1;
     while (file.exists()) {
       StringBuffer buf = new StringBuffer();
@@ -68,7 +65,7 @@
       file = new File(dir, buf.toString());
       i++;
     }
-    logger.fine("new file: " + file.getName());
+    //logger.fine("new file: " + file.getName());
     return file;
   }
   
diff --git a/src/de/uhilger/httpserver/cm/OrdnerBearbeiter.java b/src/de/uhilger/httpserver/cm/OrdnerBearbeiter.java
index 9a34660..4c15578 100644
--- a/src/de/uhilger/httpserver/cm/OrdnerBearbeiter.java
+++ b/src/de/uhilger/httpserver/cm/OrdnerBearbeiter.java
@@ -24,7 +24,6 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.attribute.BasicFileAttributes;
-import java.util.logging.Logger;
 
 /**
  * Ein FileVisitor zum Verschieben oder Kopieren ganzer Ordnerstrukturen mit
@@ -35,15 +34,12 @@
  */
 public class OrdnerBearbeiter extends FileTransporter implements FileVisitor {
 
-  /* Der Logger fuer diesen ListFileHandler */
-  private static final Logger logger = Logger.getLogger(OrdnerBearbeiter.class.getName());
-
   private Path targetDir;
   private int operation;
 
   public void setTargetDir(Path targetDir) {
     this.targetDir = targetDir;
-    logger.fine("targetDir: " + targetDir.toString());
+    //logger.fine("targetDir: " + targetDir.toString());
   }
 
   /**
@@ -61,14 +57,14 @@
       if (dir instanceof Path) {
         Path sourceDir = (Path) dir;
         File destFile = targetDir.resolve(sourceDir.getFileName()).toFile();
-        logger.fine("sourceDir: " + sourceDir + ", destFile: " + destFile);
+        //logger.fine("sourceDir: " + sourceDir + ", destFile: " + destFile);
         if (destFile.exists()) {
           File newDir = getNewFileName(destFile);
           destFile.renameTo(newDir);
         }
         destFile.mkdir();
         this.targetDir = destFile.toPath();
-        logger.fine("targetDir now: " + targetDir.toString());
+        //logger.fine("targetDir now: " + targetDir.toString());
       }
     }
     return FileVisitResult.CONTINUE;
@@ -84,10 +80,10 @@
           destFile = getNewFileName(destFile);
         }
         if (operation == FileManager.OP_MOVE) {
-          logger.fine("move source: " + source.toString() + ", destFile: " + destFile.getAbsolutePath());
+          //logger.fine("move source: " + source.toString() + ", destFile: " + destFile.getAbsolutePath());
           Files.move(source, destFile.toPath());
         } else if (operation == FileManager.OP_COPY) {
-          logger.fine("copy source: " + source.toString() + ", destFile: " + destFile.getAbsolutePath());
+          //logger.fine("copy source: " + source.toString() + ", destFile: " + destFile.getAbsolutePath());
           Files.copy(source, destFile.toPath());
         }
       }
@@ -109,11 +105,11 @@
         Path finishedDir = (Path) dir;
         targetDir = targetDir.getParent();
         if(operation == FileManager.OP_MOVE) {
-          logger.fine("delete " + finishedDir.toString());
+          //logger.fine("delete " + finishedDir.toString());
           Files.delete(finishedDir);
         }
       }
-      logger.fine("targetDir now: " + targetDir.toString());
+      //logger.fine("targetDir now: " + targetDir.toString());
     } else {
       Files.delete((Path) dir);
     }

--
Gitblit v1.9.3