From f61a32dab54add0f23e10a98ffe18d06f882c063 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Wed, 07 Apr 2021 22:08:38 +0000
Subject: [PATCH] Nachbesserungen

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

diff --git a/src/de/uhilger/mediaz/api/StorageHandler.java b/src/de/uhilger/mediaz/api/StorageHandler.java
index f022ada..3b8e010 100644
--- a/src/de/uhilger/mediaz/api/StorageHandler.java
+++ b/src/de/uhilger/mediaz/api/StorageHandler.java
@@ -21,6 +21,7 @@
 import com.sun.net.httpserver.HttpExchange;
 import com.sun.net.httpserver.HttpHandler;
 import de.uhilger.mediaz.App;
+import static de.uhilger.mediaz.App.RB_EP_LISTE;
 import de.uhilger.mediaz.Server;
 import static de.uhilger.mediaz.Server.RB_SLASH;
 import de.uhilger.mediaz.store.FileStorage;
@@ -58,6 +59,9 @@
     Beispiele:
   
     HTTP GET an /mz/api/store/Ablageort/
+    liefert alle Ablageort-Objekte
+  
+    HTTP GET an /mz/api/store/Ablageort/liste/  
     liefert eine Liste der Namen vorhandener Ablageorte
   
     HTTP GET an /mz/api/store/Ablageort/Katalog
@@ -86,6 +90,8 @@
   
   /** Name der HTTP Methode DELETE */
   public static final String HTTP_DELETE = "DELETE";
+  
+  public static final String EP_LISTE = "liste/";
 
   @Override
   public void handle(HttpExchange e) throws IOException {
@@ -143,7 +149,7 @@
     String filename = ""; 
     FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
     Gson gson = new Gson();
-    logger.log(Level.FINE, "type: {0}", type);
+    logger.log(Level.FINE, "type: {0}, token: {1}", new Object[]{type, fs.typeFromName(type).getType().getTypeName()});
     Object o = gson.fromJson(body, fs.typeFromName(type).getType());
     if(o instanceof Entity) {
       Object antwortObjekt = fs.write((Entity) o, overwrite);
@@ -177,9 +183,16 @@
     String[] elems = path.split(App.getRs(Server.RB_SLASH));
     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.fine(type);
-      List list = fs.list(type);
+      List list = null;
+      if(path.endsWith(App.getRs(RB_EP_LISTE))) {
+        String type = elems[elems.length - 2];
+        logger.fine(type);
+        list = fs.list(type);
+      } else {
+        String type = elems[elems.length - 1];
+        logger.fine(type);
+        list = fs.listObjects(type);
+      }
       return jsonWithEnclosingType(list);
     } else {
       String type = elems[elems.length - 2];

--
Gitblit v1.9.3