src/java/de/uhilger/filecms/api/FileMgr.java | ●●●●● patch | view | raw | blame | history | |
src/java/de/uhilger/filecms/api/UploadServlet.java | ●●●●● patch | view | raw | blame | history | |
src/java/de/uhilger/filecms/web/Initialiser.java | ●●●●● patch | view | raw | blame | history | |
src/java/logging.properties | ●●●●● patch | view | raw | blame | history | |
web/ui/ui.js | ●●●●● patch | view | raw | blame | history |
src/java/de/uhilger/filecms/api/FileMgr.java
@@ -45,6 +45,9 @@ public static final String PUB_DIR_NAME = "Oeffentlich"; public static final String HOME_DIR_NAME = "Persoenlicher Ordner"; public static final int OP_COPY = 1; public static final int OP_MOVE = 2; public String hallo() { return "Hallo Welt!"; } @@ -61,12 +64,13 @@ files.add(namedPublicFolder); } else { String path = getTargetDir(relPath).getAbsolutePath(); logger.fine(path); logger.fine("path: " + path); LocalFileSystem fs = new LocalFileSystem(); logger.fine("listing " + getTargetDir(relPath).getAbsolutePath()); FileRef[] fileRefs = fs.list(new FileRef(getTargetDir(relPath).getAbsolutePath(), true)); for(int i = 0; i < fileRefs.length; i++) { files.add(fileRefs[i]); logger.finer("added " + fileRefs[i].getAbsolutePath()); logger.fine("added " + fileRefs[i].getAbsolutePath()); } } return files; @@ -147,6 +151,56 @@ return result; } public String copyFiles(String fromPath, String toPath, List fileNames) { return copyOrMoveFiles(fromPath, toPath, fileNames, OP_COPY); } public String moveFiles(String fromPath, String toPath, List fileNames) { return copyOrMoveFiles(fromPath, toPath, fileNames, OP_MOVE); } /** * Dateien kopieren * * @param fromPath der relative Pfad, aus dem die Dateien stammen, die kopiert werden sollen * @param toPath der relative Pfad, an den die Dateien kopiert werden sollen * @param fileNames Liste mit Namen der Dateien, die kopiert werden sollen * @param operation OP_COPY oder OP_MOVE * @return null bei Fehler oder Quittungstext, wenn erfolgreich */ private String copyOrMoveFiles(String fromPath, String toPath, List fileNames, int operation) { String result = null; try { FileRef[] files = new FileRef[fileNames.size()]; logger.fine(fileNames.toString()); File srcDir = getTargetDir(fromPath); 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 srcFile = new File(srcDir, al.get(0).toString()); logger.fine(srcFile.getAbsolutePath()); files[i] = new FileRef(srcFile.getAbsolutePath(), srcFile.isDirectory()); } } File targetDir = getTargetDir(toPath); FileSystem fs = new LocalFileSystem(); switch(operation) { case OP_COPY: fs.copy(files, new FileRef(targetDir.getAbsolutePath(), true)); break; case OP_MOVE: fs.move(files, new FileRef(targetDir.getAbsolutePath(), true)); break; } result = "kopiert"; } 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 { @@ -190,9 +244,9 @@ logger.fine(relPath); String targetPath = null; if(relPath.startsWith(PUB_DIR_NAME)) { targetPath = PUB_DIR_PATH + getUserName() + "/" + relPath.substring(PUB_DIR_NAME.length()); 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()); targetPath = HOME_DIR_PATH + getUserName() + relPath.substring(HOME_DIR_NAME.length()); } else { // kann eigentlich nicht sein.. } @@ -200,6 +254,7 @@ File targetDir = new File(getBase().getAbsolutePath(), targetPath); return targetDir; } private FileRef getBase() { FileRef base = null; Object o = getServletContext().getAttribute(Initialiser.FILE_BASE); src/java/de/uhilger/filecms/api/UploadServlet.java
@@ -28,7 +28,6 @@ import java.io.IOException; import java.io.InputStream; import java.security.Principal; import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.logging.Level; @@ -166,8 +165,11 @@ private FileRef getBase() { FileRef base = null; Object o = getServletContext().getAttribute(Initialiser.FILE_BASE); if (o instanceof FileRef) { base = (FileRef) o; if(o instanceof String) { String baseStr = (String) o; logger.fine(baseStr); File file = new File(baseStr); base = new FileRef(file.getAbsolutePath(), file.isDirectory()); } return base; } src/java/de/uhilger/filecms/web/Initialiser.java
@@ -62,13 +62,13 @@ ctx.setAttribute(FILE_BASE, pfad); logger.fine("Basis: " + pfad); } else { ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx)); ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx).getAbsolutePath()); } } else { ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx)); ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx).getAbsolutePath()); } } catch(Exception ex) { ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx)); ctx.setAttribute(FILE_BASE, getWbxDataDir(ctx).getAbsolutePath()); } } @@ -99,6 +99,7 @@ logger.fine("getRealPath: " + path); // file-cms in webapps File file = new File(path); file = file.getParentFile().getParentFile().getParentFile().getParentFile(); file = new File(file, "daten/"); logger.fine("Basis: " + file.getAbsolutePath()); return file; } src/java/logging.properties
@@ -43,7 +43,7 @@ java.util.logging.FileHandler.count = 2 # java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.FileHandler.level = NONE java.util.logging.FileHandler.level = FINER # Limit the message that are printed on the console to INFO and above. # java.util.logging.ConsoleHandler.level = INFO @@ -66,3 +66,4 @@ # com.xyz.foo.level = SEVERE de.uhilger.filecms.handlers = java.util.logging.ConsoleHandler de.uhilger.filecms.level = FINER de.uhilger.filesystem.level = FINER web/ui/ui.js
@@ -487,7 +487,7 @@ function fm_copy_files() { cutCopySrcDir = pfad; cutCopyFiles = fm_gewaehlte_dateien(); cutCopyOperation = 'cut'; cutCopyOperation = 'copy'; } /* @@ -497,16 +497,24 @@ */ function fm_paste_files() { var m; if(cutCopyOperation = 'cut') { m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); if(cutCopyOperation === 'cut') { //m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(cutCopyFiles); } else { m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); //m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(cutCopyFiles); } var u = '../svc' + m; fm_post(u, {p1: cutCopySrcDir, p2: pfad, p3: encodeURIComponent(cutCopyFiles)}, function(resp) { fm_get(u, "text", function(resp) { // console.log('deleteFiles gab folgendes zurueck: ' + resp); fm_get_list(pfad); }); /* fm_post(u, {p1: encodeURIComponent(cutCopySrcDir), p2: encodeURIComponent(pfad), p3: encodeURIComponent(cutCopyFiles)},'text', function(resp) { // resp evtl. zeigen.. fm_get_list(pfad); }); */ } function fm_del_files() { @@ -736,12 +744,12 @@ }); } function fm_post(u, d, scallback) { function fm_post(u, d, dtype, scallback) { $.ajax({ url: u, data: d, type: "POST", dataType: "json", dataType: dtype, success: scallback, error: function (xhr, status, errorThrown) { $('#fehler').html("Error: " + errorThrown + " Status: " + status);