From 5efd94fed0b470d715b9aa4d2e6b0e300ca2ec06 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Tue, 21 Feb 2017 07:19:47 +0000
Subject: [PATCH] FileMgr aufgeraeumt

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

diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java
index 6a2be58..e79970a 100644
--- a/src/java/de/uhilger/filecms/api/FileMgr.java
+++ b/src/java/de/uhilger/filecms/api/FileMgr.java
@@ -57,9 +57,9 @@
       files.add(namedHomeFolder);
       files.add(namedPublicFolder);
     } else {
-      LocalFileSystem fs = new LocalFileSystem();
       String path = getTargetDir(relPath).getAbsolutePath();
       logger.fine(path);
+      LocalFileSystem fs = new LocalFileSystem();
       FileRef[] fileRefs = fs.list(new FileRef(getTargetDir(relPath).getAbsolutePath(), true));
       for(int i = 0; i < fileRefs.length; i++) {
         files.add(fileRefs[i]);
@@ -83,39 +83,6 @@
     File targetDir = new File(getBase().getAbsolutePath(), targetPath);
     targetDir.mkdirs();
     return new FileRef(targetDir.getAbsolutePath(), true);
-  }
-  
-  private File getTargetDir(String relPath) {
-    logger.finer(relPath);
-    String targetPath = null;
-    if(relPath.startsWith(PUB_DIR_NAME)) {
-      targetPath = PUB_DIR_PATH + getUserName() + "/" + relPath.substring(PUB_DIR_NAME.length());
-    } else if(relPath.startsWith(HOME_DIR_NAME)) {
-      targetPath = HOME_DIR_PATH + getUserName() + "/" + relPath.substring(HOME_DIR_NAME.length());
-    } else {
-      // kann eigentlich nicht sein..
-    }
-    logger.finer(targetPath);
-    File targetDir = new File(getBase().getAbsolutePath(), targetPath);
-    return targetDir;
-  }
-  
-  private FileRef getBase() {
-    FileRef base = null;
-    Object o = getServletContext().getAttribute(Initialiser.FILE_BASE);
-    if(o instanceof FileRef) {
-      base = (FileRef) o;
-    }
-    return base;
-  }
-  
-  private String getUserName() {
-    String userName = null;
-    Object p = getRequest().getUserPrincipal();
-    if(p instanceof Principal) {
-      userName = ((Principal) p).getName();
-    }
-    return userName;
   }
   
   public FileRef saveTextFile(String relPath, String fileName, String contents) {
@@ -154,12 +121,48 @@
     }
     return savedFile;
   }
+    
+  /* ---- Hilfsfunktionen ---- */
   
+  private File getTargetDir(String relPath) {
+    logger.finer(relPath);
+    String targetPath = null;
+    if(relPath.startsWith(PUB_DIR_NAME)) {
+      targetPath = PUB_DIR_PATH + getUserName() + "/" + relPath.substring(PUB_DIR_NAME.length());
+    } else if(relPath.startsWith(HOME_DIR_NAME)) {
+      targetPath = HOME_DIR_PATH + getUserName() + "/" + relPath.substring(HOME_DIR_NAME.length());
+    } else {
+      // kann eigentlich nicht sein..
+    }
+    logger.finer(targetPath);
+    File targetDir = new File(getBase().getAbsolutePath(), targetPath);
+    return targetDir;
+  }
+  private FileRef getBase() {
+    FileRef base = null;
+    Object o = getServletContext().getAttribute(Initialiser.FILE_BASE);
+    if(o instanceof FileRef) {
+      base = (FileRef) o;
+    }
+    return base;
+  }
+  
+  private String getUserName() {
+    String userName = null;
+    Object p = getRequest().getUserPrincipal();
+    if(p instanceof Principal) {
+      userName = ((Principal) p).getName();
+    }
+    return userName;
+  }
+  
+  /*
   private File getWebappsDir() {
     File cfile = new File(this.getClass().getResource(
             this.getClass().getSimpleName() + ".class").getFile());
     String path = cfile.getAbsolutePath();
     return new File(path.substring(0, path.indexOf(getRequest().getContextPath())));
   }
+  */
     
 }

--
Gitblit v1.9.3