From c980bb439a1685510b1b479669761a93f0d8c5b0 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Sat, 25 Feb 2017 17:32:26 +0000 Subject: [PATCH] Mustache Templates ausgelagert (noch in Arbeit) --- src/java/de/uhilger/filecms/api/FileMgr.java | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java index d70f816..78ac92d 100644 --- a/src/java/de/uhilger/filecms/api/FileMgr.java +++ b/src/java/de/uhilger/filecms/api/FileMgr.java @@ -20,13 +20,13 @@ import de.uhilger.filecms.web.Initialiser; import de.uhilger.filesystem.FileRef; +import de.uhilger.filesystem.FileSystem; import de.uhilger.filesystem.LocalFileSystem; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.io.StringReader; import java.security.Principal; import java.util.ArrayList; import java.util.List; @@ -122,6 +122,31 @@ return code; } + public String deleteFiles(String relPath, List fileNames) { + String result = null; + try { + FileRef[] delRefs = new FileRef[fileNames.size()]; + logger.fine(fileNames.toString()); + File targetDir = getTargetDir(relPath); + for(int i=0; i < fileNames.size(); i++) { + Object o = fileNames.get(i); + if(o instanceof ArrayList) { + ArrayList al = (ArrayList) o; + logger.fine(al.get(0).toString()); + File targetFile = new File(targetDir, al.get(0).toString()); + logger.fine(targetFile.getAbsolutePath()); + delRefs[i] = new FileRef(targetFile.getAbsolutePath(), targetFile.isDirectory()); + } + } + FileSystem fs = new LocalFileSystem(); + fs.delete(delRefs); + result = "deleted"; + } catch (Throwable ex) { + logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); + } + return result; + } + public FileRef saveTextFile(String relPath, String fileName, String contents) { FileRef savedFile = null; try { -- Gitblit v1.9.3