From 972e946a9836c2909a8318587beeb9bee6631573 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Wed, 15 Mar 2017 17:07:50 +0000
Subject: [PATCH] CATALINA_BASE_FOLDER (erste Versuche)

---
 src/java/de/uhilger/filecms/api/FileMgr.java |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java
index 73b7c0b..b4ece2e 100644
--- a/src/java/de/uhilger/filecms/api/FileMgr.java
+++ b/src/java/de/uhilger/filecms/api/FileMgr.java
@@ -52,6 +52,8 @@
   //public static final String HOME_DIR_NAME = "Persoenlicher Ordner";
   public static final String HOME_DIR_NAME = "Persoenlich";
   
+  public static final String CATALINA_BASE_FOLDER = "base";
+  
   public static final int OP_COPY = 1;
   public static final int OP_MOVE = 2;
   
@@ -67,9 +69,11 @@
       logger.finer(namedPublicFolder.getAbsolutePath());
       FileRef namedHomeFolder = new FileRef(HOME_DIR_NAME, true);
       logger.finer(namedHomeFolder.getAbsolutePath());
+      FileRef namedBaseFolder = new FileRef(CATALINA_BASE_FOLDER, true);
       files = new ArrayList();
       files.add(namedHomeFolder);
       files.add(namedPublicFolder);
+      files.add(namedBaseFolder);
     } else {
       String path = getTargetDir(relPath).getAbsolutePath();
       logger.fine("listing path: " + path);
@@ -353,16 +357,24 @@
   
   private File getTargetDir(String relPath) {
     logger.fine(relPath);
+    File targetDir;
     String targetPath = null;
     if(relPath.startsWith(PUB_DIR_NAME)) {
       targetPath = PUB_DIR_PATH + getUserName() + relPath.substring(PUB_DIR_NAME.length());
+      targetDir = new File(getBase().getAbsolutePath(), targetPath);
     } else if(relPath.startsWith(HOME_DIR_NAME)) {
       targetPath = HOME_DIR_PATH + getUserName() + relPath.substring(HOME_DIR_NAME.length());
+      targetDir = new File(getBase().getAbsolutePath(), targetPath);
+    } else if(relPath.startsWith(CATALINA_BASE_FOLDER)) {
+      targetPath = getCatalinaBase();
+      targetDir = new File(targetPath, relPath.substring(CATALINA_BASE_FOLDER.length()));
     } else {
       // kann eigentlich nicht sein..
+      targetPath = PUB_DIR_PATH + getUserName() + relPath.substring(PUB_DIR_NAME.length());
+      targetDir = new File(getBase().getAbsolutePath(), targetPath);
     }
     logger.fine(targetPath);
-    File targetDir = new File(getBase().getAbsolutePath(), targetPath);
+    //File targetDir = new File(getBase().getAbsolutePath(), targetPath);
     return targetDir;
   }
   
@@ -386,4 +398,12 @@
     }
     return userName;
   }    
+  
+  private String getCatalinaBase() {
+    String path = getServletContext().getRealPath("/");
+    logger.fine("getRealPath: " + path); // file-cms in webapps
+    File file = new File(path);
+    file = file.getParentFile().getParentFile();
+    return file.getAbsolutePath();
+  }
 }
\ No newline at end of file

--
Gitblit v1.9.3