From 86bbf7cbbfcdc82c994b0a3d0ea9a04290160683 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Tue, 06 Apr 2021 14:47:48 +0000
Subject: [PATCH] Katalog (in Arbeit)

---
 src/de/uhilger/mediaz/api/StorageHandler.java |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/de/uhilger/mediaz/api/StorageHandler.java b/src/de/uhilger/mediaz/api/StorageHandler.java
index e4bf00d..f022ada 100644
--- a/src/de/uhilger/mediaz/api/StorageHandler.java
+++ b/src/de/uhilger/mediaz/api/StorageHandler.java
@@ -41,7 +41,7 @@
  * @author Ulrich Hilger
  * @version 1, 5.4.2021
  */
-public class StorageHandler implements HttpHandler  {
+public class StorageHandler extends AbstractHandler implements HttpHandler {
   
   private static final Logger logger = Logger.getLogger(StorageHandler.class.getName());
 
@@ -120,7 +120,7 @@
         }
         break;
     }
-    logger.info(response);
+    logger.fine(response);
     e.sendResponseHeaders(code, response.length());
     OutputStream os = e.getResponseBody();
     os.write(response.getBytes());
@@ -143,13 +143,13 @@
     String filename = ""; 
     FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
     Gson gson = new Gson();
-    logger.log(Level.INFO, "type: {0}", type);
+    logger.log(Level.FINE, "type: {0}", type);
     Object o = gson.fromJson(body, fs.typeFromName(type).getType());
     if(o instanceof Entity) {
       Object antwortObjekt = fs.write((Entity) o, overwrite);
       if(antwortObjekt instanceof File) {
         File file = (File) antwortObjekt;
-        logger.log(Level.INFO, "Datei {0} geschrieben.", file.getAbsolutePath());
+        logger.log(Level.FINE, "Datei {0} geschrieben.", file.getAbsolutePath());
         filename = file.getName();
         return type + FileHandler.STR_BLANK + filename;
       }
@@ -178,7 +178,7 @@
     FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
     if(path.endsWith(App.getRs(RB_SLASH))) {
       String type = elems[elems.length - 1];
-      logger.info(type);
+      logger.fine(type);
       List list = fs.list(type);
       return jsonWithEnclosingType(list);
     } else {
@@ -186,17 +186,6 @@
       String elemName = elems[elems.length - 1];
       return fs.readJson(type, elemName);
     }
-  }
-  
-  private String jsonWithEnclosingType(Object o) {
-    StringBuilder sb = new StringBuilder();
-    sb.append("{\"");
-    sb.append(o.getClass().getSimpleName());
-    sb.append("\": ");
-    Gson gson = new Gson();
-    sb.append(gson.toJson(o));
-    sb.append("}");
-    return sb.toString();
   }
   
   private String bodyLesen(HttpExchange e) throws IOException {
@@ -210,7 +199,7 @@
     }
     r.close();
     String json = sb.toString();
-    logger.log(Level.INFO, "json: {0}", json);
+    logger.log(Level.FINE, "json: {0}", json);
     return json;
   }
 }

--
Gitblit v1.9.3