From eab7bbb573b16d7a5de6b361465518c045f1b617 Mon Sep 17 00:00:00 2001
From: ulrich <undisclosed>
Date: Wed, 29 Mar 2017 05:40:03 +0000
Subject: [PATCH] Initialiser nach wbx-lib geschoben

---
 src/de/uhilger/wbx/WbxUtils.java |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/src/de/uhilger/wbx/WbxUtils.java b/src/de/uhilger/wbx/WbxUtils.java
index 4bf0bd8..b5308fc 100644
--- a/src/de/uhilger/wbx/WbxUtils.java
+++ b/src/de/uhilger/wbx/WbxUtils.java
@@ -29,6 +29,9 @@
   
   private static final Logger logger = Logger.getLogger(WbxUtils.class.getName());
   
+  //public static final String FILE_BASE = "filebase";
+  //public static final String DATENABLAGE = "datenAblage";  
+  
   /**
    * Bei der WebBox ist das Datenverzeichnis relativ zum Verzeichnis 
    * $CATALINA_BASE/webapps untergebracht. 
@@ -51,14 +54,52 @@
    * 
    * @return Verzeichnis 'daten' der WebBox
    */
+  /*
   public static File getWbxDataDir(ServletContext ctx) {
+    File file = getWbxDir(ctx);    
+    file = new File(file, "daten/");
+    logger.fine("WebBox Datenbasis: " + file.getAbsolutePath());
+    return file;
+  }
+  
+  public static File getWbxDir(ServletContext ctx) {
     String path = ctx.getRealPath("/");
     logger.fine("getRealPath: " + path); // file-cms in webapps
     File file = new File(path);
     file = file.getParentFile().getParentFile().getParentFile().getParentFile();    
-    file = new File(file, "daten/");
-    logger.fine("Basis: " + file.getAbsolutePath());
+    logger.fine("WebBox: " + file.getAbsolutePath());
     return file;
   }
+  */
+  
+  /**
+   * Die Dateiablage wird entweder auf einen absoluten Pfad gesetzt, 
+   * der im Deployment Descriptor hinterlegt werden kann oder, wenn 
+   * dort nichts eingetragen ist, auf den hart kodierten Pfad 
+   * der WebBox.
+   * 
+   * @param ctx der ServletContext, in den die Angabe eingetragen wird. Dort 
+   * ist anschliessend die Angabe unter Initialiser.FILE_BASE abrufbar
+   */
+  /*
+  public static void ablageErmitteln(ServletContext ctx) {
+    Object o = ctx.getInitParameter(DATENABLAGE);
+    try {
+      if(o instanceof String) {
+        String pfad = o.toString();
+        if(pfad.trim().length() > 0) {
+          ctx.setAttribute(FILE_BASE, pfad);
+          logger.fine("Basis: " + pfad);
+        } else {
+          ctx.setAttribute(FILE_BASE, WbxUtils.getWbxDataDir(ctx).getAbsolutePath());  
+        }
+      } else {
+        ctx.setAttribute(FILE_BASE, WbxUtils.getWbxDataDir(ctx).getAbsolutePath());      
+      }    
+    } catch(Exception ex) {
+      ctx.setAttribute(FILE_BASE, WbxUtils.getWbxDataDir(ctx).getAbsolutePath());
+    }
+  } 
+  */
 
 }

--
Gitblit v1.9.3