From da33e62e75c14122527a5369bd964c68e4e84849 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Thu, 22 Apr 2021 19:02:02 +0000
Subject: [PATCH] Gestaltung der Hervorhebung in Listen angepasst

---
 src/de/uhilger/mediaz/Server.java |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/de/uhilger/mediaz/Server.java b/src/de/uhilger/mediaz/Server.java
index af203fb..a3f1b1c 100644
--- a/src/de/uhilger/mediaz/Server.java
+++ b/src/de/uhilger/mediaz/Server.java
@@ -19,7 +19,10 @@
 
 import com.sun.net.httpserver.HttpServer;
 import de.uhilger.mediaz.api.FileHandler;
+import de.uhilger.mediaz.api.GeraetSteuerung;
 import de.uhilger.mediaz.api.ListFileHandler;
+import de.uhilger.mediaz.api.ListHandler;
+import de.uhilger.mediaz.api.MediaSteuerung;
 import de.uhilger.mediaz.api.StopServerHandler;
 import de.uhilger.mediaz.api.StorageHandler;
 import de.uhilger.mediaz.store.FileStorage;
@@ -48,11 +51,14 @@
   public static final String RB_SERVER_START_MSG = "msgServerStart";
   public static final String RB_WEBROOT = "webroot";
   public static final String RB_STORE = "store";
+  public static final String RB_STRG = "strg";
+  public static final String RB_GSTRG = "gstrg";
+  public static final String RB_ALIST= "alist";
   //public static final String RB_UI_ROOT = "uiroot";
   public static final String RB_STOP_SERVER = "stopServer";
   //public static final String RB_ABLAGE_TEST = "testAblage";
   //public static final String RB_STORE_TEST = "testStore";
-  public static final String RB_SLASH = "slash";
+  public static final String SLASH = "/";
 
   private int port;
 
@@ -83,9 +89,8 @@
    * @param ctxName Name des Kontexts, unter dem der Server aufrufbar sein soll
    */
   public void setContextName(String ctxName) {
-    String slash = App.getRs(RB_SLASH);
-    if (!ctxName.startsWith(slash)) {
-      this.ctx = slash + ctxName;
+    if (!ctxName.startsWith(SLASH)) {
+      this.ctx = SLASH + ctxName;
     } else {
       this.ctx = ctxName;
     }
@@ -104,23 +109,21 @@
 
     String wwwData = App.getInitParameter(App.getRs(App.RB_AP_WWW_DATA));
     File wwwDir = new File(wwwData);
-    //String ui = App.getInitParameter(App.getRs(App.RB_AP_UI));
-    //File uiDir = new File(ui);
 
     HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
-    server.createContext(ctx + App.getRs(RB_WEBROOT), 
-            new FileHandler(wwwDir.getAbsolutePath()));
+    server.createContext(ctx + App.getRs(RB_WEBROOT), new FileHandler(wwwDir.getAbsolutePath()));
     ablageorteEinklinken(server);
     server.createContext(ctx + App.getRs(RB_STORE), new StorageHandler());
-    //server.createContext(ctx + App.getRs(RB_UI_ROOT), new FileHandler(uiDir.getAbsolutePath()));    
+    server.createContext(ctx + App.getRs(RB_STRG), new MediaSteuerung());
+    server.createContext(ctx + App.getRs(RB_GSTRG), new GeraetSteuerung());
+    server.createContext(ctx + App.getRs(RB_ALIST), new ListHandler());
     server.createContext(ctx + App.getRs(RB_STOP_SERVER), new StopServerHandler());
-    //server.createContext(ctx + App.getRs(RB_ABLAGE_TEST), new AblageTestHandler());
-    //server.createContext(ctx + App.getRs(RB_STORE_TEST), new StoreTestHandler());
     server.setExecutor(Executors.newFixedThreadPool(20));
     server.start();
   }
 
-  private void ablageorteEinklinken(HttpServer server) throws ClassNotFoundException, IOException {
+  private void ablageorteEinklinken(HttpServer server) 
+              throws ClassNotFoundException, IOException {
     String typ = Ablageort.class.getSimpleName();
     FileStorage store = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
     List<String> orte = store.list(typ);
@@ -129,11 +132,11 @@
       String ortName = i.next();
       Entity e = store.read(typ, ortName);
       if(e instanceof Ablageort) {
-        Ablageort ort = (Ablageort) e; 
-          Ablageort ablageort = (Ablageort) e;
-          logger.fine(ctx + ablageort.getUrl());
-          server.createContext(ctx + ablageort.getUrl(), 
-                  new ListFileHandler(new File(ablageort.getOrt()).getAbsolutePath()));
+        Ablageort ablageort = (Ablageort) e;
+        logger.log(Level.FINE, "{0}{1}", new Object[]{ctx, ablageort.getUrl()});
+        logger.fine(ablageort.getOrt());
+        server.createContext(ctx + ablageort.getUrl(),  
+          new ListFileHandler(new File(ablageort.getOrt()).getAbsolutePath()));
       }
     }
   }

--
Gitblit v1.9.3