From c509a016b6156e34034500803f8e18a2a9529940 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Mon, 20 Feb 2017 18:17:58 +0000 Subject: [PATCH] Neuer Ordner hergestellt --- src/java/de/uhilger/filecms/api/FileMgr.java | 99 ++++++++++++++----------------------------------- 1 files changed, 29 insertions(+), 70 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java index 20277a1..6a2be58 100644 --- a/src/java/de/uhilger/filecms/api/FileMgr.java +++ b/src/java/de/uhilger/filecms/api/FileMgr.java @@ -42,26 +42,13 @@ public static final String PUB_DIR_NAME = "Oeffentlich"; public static final String HOME_DIR_NAME = "Persoenlicher Ordner"; - //private FileRef homeFolder; - //private FileRef publicFolder; - //private FileRef namedHomeFolder; - //private FileRef namedPublicFolder; - - public String hallo() { return "Hallo Welt!"; } public List<FileRef> list(String relPath) { List<FileRef> files = new ArrayList(); - if(relPath.length() == 0) { - /* - publicFolder = new FileRef(getUserPubDir().getAbsolutePath(), true); - logger.info(publicFolder.getAbsolutePath()); - homeFolder = new FileRef(getUserHomeDir().getAbsolutePath(), true); - logger.info(homeFolder.getAbsolutePath()); - */ FileRef namedPublicFolder = new FileRef(PUB_DIR_NAME, true); logger.finer(namedPublicFolder.getAbsolutePath()); FileRef namedHomeFolder = new FileRef(HOME_DIR_NAME, true); @@ -70,20 +57,6 @@ files.add(namedHomeFolder); files.add(namedPublicFolder); } else { - /* - 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); - */ - LocalFileSystem fs = new LocalFileSystem(); String path = getTargetDir(relPath).getAbsolutePath(); logger.fine(path); @@ -92,25 +65,39 @@ files.add(fileRefs[i]); logger.finer("added " + fileRefs[i].getAbsolutePath()); } - //files = Arrays.asList(fileRefs); - } - + } return files; } + public FileRef newFolder(String relPath, String folderName) { + logger.finer(relPath); + String targetPath = null; + if(relPath.startsWith(PUB_DIR_NAME)) { + targetPath = PUB_DIR_PATH + getUserName() + "/" + relPath.substring(PUB_DIR_NAME.length()) + "/" + folderName; + } else if(relPath.startsWith(HOME_DIR_NAME)) { + targetPath = HOME_DIR_PATH + getUserName() + "/" + relPath.substring(HOME_DIR_NAME.length()) + "/" + folderName; + } else { + // kann eigentlich nicht sein.. + } + logger.finer(targetPath); + 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; + 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() { @@ -122,18 +109,6 @@ return base; } - /* - private File getUserPubDir() { - File userDir = null; - File daten = new File(getBase().getAbsolutePath()); - Object p = getRequest().getUserPrincipal(); - if(p instanceof Principal) { - userDir = new File(daten, PUB_DIR_PATH + ((Principal) p).getName()); - } - return userDir; - } - */ - private String getUserName() { String userName = null; Object p = getRequest().getUserPrincipal(); @@ -143,18 +118,6 @@ return userName; } - /* - private File getUserHomeDir() { - File userDir = null; - File daten = new File(getBase().getAbsolutePath()); - Object p = getRequest().getUserPrincipal(); - if(p instanceof Principal) { - userDir = new File(daten, HOME_DIR_PATH + ((Principal) p).getName()); - } - return userDir; - } - */ - public FileRef saveTextFile(String relPath, String fileName, String contents) { FileRef savedFile = null; try { @@ -162,10 +125,6 @@ File daten = new File(datenRef.getAbsolutePath()); Object p = getRequest().getUserPrincipal(); if(p instanceof Principal) { - /* - File userDir = new File(daten, "www/" + ((Principal) p).getName()); - File saveDir = new File(userDir, relPath); - */ File targetFile = new File(getTargetDir(relPath), fileName); if(targetFile.exists()) { /* -- Gitblit v1.9.3