From be9b6dd4d15f1fdf430121947152ca5f368cfbde Mon Sep 17 00:00:00 2001 From: ulrich <undisclosed> Date: Sun, 05 Mar 2017 10:52:20 +0000 Subject: [PATCH] TinyMCE laden verbessert --- src/java/de/uhilger/filecms/api/FileMgr.java | 40 +++++++++++++++------------------------- 1 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java index b3adeaf..649357d 100644 --- a/src/java/de/uhilger/filecms/api/FileMgr.java +++ b/src/java/de/uhilger/filecms/api/FileMgr.java @@ -166,32 +166,14 @@ } public String copyFiles(String fromPath, String toPath, List fileNames) { - String result = null; - try { - File srcDir = getTargetDir(fromPath); - File targetDir = getTargetDir(toPath); - Iterator i = fileNames.iterator(); - while(i.hasNext()) { - Object o = i.next(); - if (o instanceof ArrayList) { - ArrayList al = (ArrayList) o; - File srcFile = new File(srcDir, al.get(0).toString()); - if(srcFile.isDirectory()) { - logger.fine("copy dir " + srcFile.getAbsolutePath() + " to dir " + targetDir.getAbsolutePath()); - FileUtils.copyDirectoryToDirectory(srcFile, targetDir); - } else { - logger.fine("copy srcFile " + srcFile.getAbsolutePath() + " to dir " + targetDir.getAbsolutePath()); - FileUtils.copyFileToDirectory(srcFile, targetDir); - } - } - } - } catch (IOException ex) { - logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); - } - return result; + return copyOrMoveFiles(fromPath, toPath, fileNames, OP_COPY); } public String moveFiles(String fromPath, String toPath, List fileNames) { + return copyOrMoveFiles(fromPath, toPath, fileNames, OP_MOVE); + } + + private String copyOrMoveFiles(String fromPath, String toPath, List fileNames, int operation) { String result = null; try { File srcDir = getTargetDir(fromPath); @@ -203,9 +185,17 @@ ArrayList al = (ArrayList) o; File srcFile = new File(srcDir, al.get(0).toString()); if(srcFile.isDirectory()) { - FileUtils.moveDirectoryToDirectory(srcFile, targetDir, false); + if(operation == OP_MOVE) { + FileUtils.moveDirectoryToDirectory(srcFile, targetDir, false); + } else { + FileUtils.copyDirectoryToDirectory(srcFile, targetDir); + } } else { - FileUtils.moveFileToDirectory(srcFile, targetDir, false); + if(operation == OP_MOVE) { + FileUtils.moveFileToDirectory(srcFile, targetDir, false); + } else { + FileUtils.copyFileToDirectory(srcFile, targetDir); + } } } } -- Gitblit v1.9.3