Dateiverwaltung für die WebBox
ulrich
2018-04-06 ef09bfdbe63f5e5bd94a8118812d0f4ef28183ba
src/java/de/uhilger/filecms/web/Initialiser.java
@@ -61,21 +61,30 @@
   * 
   * @return Verzeichnis 'daten' der WebBox
   */
  /*
  protected File getWbxDataDir(ServletContext ctx) {
    File file = getWbxDir(ctx);    
    file = new File(file, "daten/");
    logger.fine("WebBox Datenbasis: " + file.getAbsolutePath());
    return file;
  }
  */
  
  /*
  protected File getWbxDir(ServletContext ctx) {
    logger.fine("Catalina Base: " + System.getProperty("catalina.base"));
    File catalinaBase = new File(System.getProperty("catalina.base"));
    File wbxDir = catalinaBase.getParentFile().getParentFile();
    return wbxDir;
    /*
    String path = ctx.getRealPath("/");
    logger.fine("getRealPath: " + path); // file-cms in webapps
    File file = new File(path);
    file = file.getParentFile().getParentFile().getParentFile().getParentFile();    
    logger.fine("WebBox: " + file.getAbsolutePath());
    return file;
  }
    */
  //}
  
  /**
   * Die Dateiablage wird entweder auf einen absoluten Pfad gesetzt, 
@@ -97,13 +106,13 @@
          ctx.setAttribute(FILE_BASE, pfad);
          logger.fine("Basis: " + pfad);
        } else {
          ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx).getAbsolutePath());
          ctx.setAttribute(FILE_BASE, wu.getWbxDataDir().getAbsolutePath());
        }
      } else {
        ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx).getAbsolutePath());
        ctx.setAttribute(FILE_BASE, wu.getWbxDataDir().getAbsolutePath());
      }    
    } catch(Exception ex) {
      ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx).getAbsolutePath());
      ctx.setAttribute(FILE_BASE, wu.getWbxDataDir().getAbsolutePath());
    }
  }  
  
@@ -127,6 +136,23 @@
        }
      }
    }
    // hier noch den context anlegen
    String path = ctx.getRealPath("/");
    //File appDir = new File(path);
    logger.fine("Catalina Base: " + System.getProperty("catalina.base"));
    //File catalinaBase = appDir.getParentFile().getParentFile();
    File catalinaBase = new File(System.getProperty("catalina.base"));
    File confLocalhost = new File(catalinaBase, "conf/Catalina/localhost");
    File dataContext = new File(confLocalhost, "data.xml");
    File srcDir = new File(path, "/META-INF/conf");
    File dataCtxSrc = new File(srcDir, "data.xml");
    logger.fine("dataCtxSrc: " + dataCtxSrc.getAbsolutePath());
    logger.fine("dataContext: " + dataContext.getAbsolutePath());
    try {
      FileUtils.copyFile(dataCtxSrc, dataContext);
    } catch (IOException ex) {
      logger.log(Level.SEVERE, null, ex);
    }
  }
  @Override