From 6648a811dfdb4cbe432dae59f373b5a9df28e513 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Mon, 11 Jan 2021 17:25:22 +0000
Subject: [PATCH] ui2: Ordner oeffnen und Datei waehlen hinzugefuegt

---
 src/java/de/uhilger/filecms/web/Initialiser.java |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/java/de/uhilger/filecms/web/Initialiser.java b/src/java/de/uhilger/filecms/web/Initialiser.java
index 82e0192..486704b 100644
--- a/src/java/de/uhilger/filecms/web/Initialiser.java
+++ b/src/java/de/uhilger/filecms/web/Initialiser.java
@@ -51,6 +51,9 @@
   public static final String FILE_BASE = "filebase";
   public static final String DATENABLAGE = "datenAblage";
   public static final String WBX_FILE_BASE = "wbxFileBase";
+  public static final String WBX_DATA_DIR = "wbx.data";
+  public static final String WBX_DEPTH = "tiefe";
+  public static final String WBX_DATA_FOLDER = "datenOrdner";
     
   /**
    * Die Dateiablage wird entweder auf einen absoluten Pfad gesetzt, 
@@ -66,25 +69,32 @@
     
     //File wbxDaten = getDataDir(ctx, 2, "data/");
     
-    WbxUtils wu = new WbxUtils();
-    Object o = wu.getJNDIParameter(WBX_FILE_BASE, WbxUtils.EMPTY_STRING);
+    //WbxUtils wu = new WbxUtils();
+    //Object o = wu.getJNDIParameter(WBX_FILE_BASE, WbxUtils.EMPTY_STRING);
+    String dir = System.getProperty(WBX_DATA_DIR);
     try {
-      if(o instanceof String) {
-        String pfad = o.toString();
-        if(pfad.trim().length() > 0) {
-          ctx.setAttribute(FILE_BASE, pfad);
-          logger.log(Level.INFO, "Daten-Ordner aus wbxFileBase: {0}", pfad);
+      if(dir != null) {
+        //String pfad = o.toString();
+        if(dir.trim().length() > 0) {
+          ctx.setAttribute(FILE_BASE, dir);
+          logger.log(Level.INFO, "Daten-Ordner aus wbx.data: {0}", dir);
         } else {
-          ctx.setAttribute(FILE_BASE, getDataDir(ctx, 2, "data/").getAbsolutePath());  
+          ctx.setAttribute(FILE_BASE, getDefaultDataDir(ctx).getAbsolutePath());  
         }
       } else {
-        ctx.setAttribute(FILE_BASE, getDataDir(ctx, 2, "data/").getAbsolutePath());      
+        ctx.setAttribute(FILE_BASE, getDefaultDataDir(ctx).getAbsolutePath());      
       }    
     } catch(Exception ex) {
-      ctx.setAttribute(FILE_BASE, getDataDir(ctx, 2, "data/").getAbsolutePath());
+      ctx.setAttribute(FILE_BASE, getDefaultDataDir(ctx).getAbsolutePath());
     }
   }  
   
+  private File getDefaultDataDir(ServletContext ctx) {
+    String tiefe = ctx.getInitParameter(WBX_DEPTH);
+    String ordnerName = ctx.getInitParameter(WBX_DATA_FOLDER);
+    return getDataDir(ctx, Integer.parseInt(tiefe), ordnerName);
+  }
+  
   /**
    * Daten-Ordner relativ zum Ablageort des file-cms finden.
    * 

--
Gitblit v1.9.3