Dateiverwaltung für die WebBox
ulrich
2017-03-15 972e946a9836c2909a8318587beeb9bee6631573
CATALINA_BASE_FOLDER (erste Versuche)
1 files modified
22 ■■■■■ changed files
src/java/de/uhilger/filecms/api/FileMgr.java 22 ●●●●● patch | view | raw | blame | history
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();
  }
}