| | |
| | | |
| | | |
| | | public FileRef newFolder(String relPath, String folderName) { |
| | | if (!relPath.startsWith(".")) { |
| | | logger.finer(relPath); |
| | | String targetPath = null; |
| | | if(relPath.startsWith(PUB_DIR_NAME)) { |
| | |
| | | File targetDir = new File(getBase().getAbsolutePath(), targetPath); |
| | | targetDir.mkdirs(); |
| | | return new FileRef(targetDir.getAbsolutePath(), true); |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public String getCode(String relPath, String fileName) { |
| | | String code = null; |
| | | |
| | | if (!relPath.startsWith(".")) { |
| | | Object p = getRequest().getUserPrincipal(); |
| | | if(p instanceof Principal) { |
| | | Reader reader = null; |
| | |
| | | File targetFile = new File(getTargetDir(relPath), fileName); |
| | | |
| | | //reader = new InputStreamReader(new FileInputStream(targetFile), "UTF8"); |
| | | |
| | | reader = new FileReader(targetFile); |
| | | StringBuffer buf = new StringBuffer(); |
| | | char[] readBuffer = new char[1024]; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | return code; |
| | | } |
| | | |
| | | public String renameFile(String relPath, String fname, String newName) { |
| | | if (!relPath.startsWith(".")) { |
| | | File targetDir = getTargetDir(relPath); |
| | | File file = new File(targetDir, fname); |
| | | file.renameTo(new File(targetDir, newName)); |
| | | return fname + " umbenannt zu " + newName; |
| | | } else { |
| | | return "Pfad nicht erlaubt."; |
| | | } |
| | | } |
| | | |
| | | public String deleteFiles(String relPath, List fileNames) { |
| | | String result = null; |
| | | try { |
| | | logger.fine(fileNames.toString()); |
| | | if (!relPath.startsWith(".")) { |
| | | File targetDir = getTargetDir(relPath); |
| | | for(int i=0; i < fileNames.size(); i++) { |
| | | Object o = fileNames.get(i); |
| | |
| | | } |
| | | } |
| | | result = "deleted"; |
| | | } |
| | | } catch (Throwable ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | |
| | | private String copyOrMoveFiles(String fromPath, String toPath, List fileNames, int operation) { |
| | | String result = null; |
| | | try { |
| | | if (!fromPath.startsWith(".")) { |
| | | File srcDir = getTargetDir(fromPath); |
| | | File targetDir = getTargetDir(toPath); |
| | | Iterator i = fileNames.iterator(); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (IOException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | |
| | | public FileRef saveTextFileAs(String relPath, String fileName, String contents) { |
| | | FileRef savedFile = null; |
| | | logger.fine(relPath + " " + fileName); |
| | | if (!relPath.startsWith(".")) { |
| | | //FileRef datenRef = getBase(); |
| | | Object p = getRequest().getUserPrincipal(); |
| | | if(p instanceof Principal) { |
| | |
| | | targetFile.getParentFile().mkdirs(); |
| | | } |
| | | saveToFile(targetFile, contents); |
| | | } |
| | | } |
| | | return savedFile; |
| | | } |
| | |
| | | public FileRef saveTextFile(String relPath, String fileName, String contents) { |
| | | FileRef savedFile = null; |
| | | logger.fine(relPath + " " + fileName); |
| | | if (!relPath.startsWith(".")) { |
| | | //FileRef datenRef = getBase(); |
| | | Object p = getRequest().getUserPrincipal(); |
| | | if(p instanceof Principal) { |
| | |
| | | } |
| | | saveToFile(targetFile, contents); |
| | | } |
| | | } |
| | | return savedFile; |
| | | } |
| | | |
| | | public String bildVerkleinern(String relPath, String bildName) { |
| | | if (!relPath.startsWith(".")) { |
| | | File dir = getTargetDir(relPath); |
| | | File original = new File(dir, bildName); |
| | | Bild bild = new Bild(); |
| | | //for (int i = 0; i < Bild.GR.length; i++) { |
| | | |
| | | //int gr = bild.getVariantenGroesse(i); |
| | | |
| | | String ext = ""; |
| | | String nurname = bildName; |
| | | int dotpos = bildName.indexOf("."); |
| | |
| | | } catch(IOException | InterruptedException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | |
| | | return "ok"; |
| | | } else { |
| | | return "Pfad micht erlaubt."; |
| | | } |
| | | } |
| | | |
| | | public String extractZipfile(String relPath, String filename) { |
| | | String result; |
| | | String result = null; |
| | | if (!relPath.startsWith(".")) { |
| | | try { |
| | | File targetDir = getTargetDir(relPath); |
| | | File archive = new File(targetDir, filename); |
| | |
| | | result = ex.getLocalizedMessage(); |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |