Exemple #1
0
 private void renameFolderInSystem(
     String systemPath, String oldRelativeFolder, String newRelativeFolder) {
   try {
     String baseName = FilenameUtils.getBaseName(systemPath);
     if (!FileNameUtil.isValidFileName(baseName)) {
       throw new GWTException(baseName + " has illegal characters");
     }
     if (("/" + oldRelativeFolder).equals(Global.PUBLICFOLDER)
         || ("/" + oldRelativeFolder).equals(Global.PRIVATEFOLDER)) {
       throw new GWTException(
           "Cannot rename " + Global.PUBLICFOLDER + " or " + Global.PRIVATEFOLDER);
     } else {
       File srcDir = new File(systemPath + "/" + oldRelativeFolder);
       File destDir = new File(systemPath + "/" + newRelativeFolder);
       FileUtils.moveDirectory(srcDir, destDir);
     }
   } catch (GWTException e) {
     throw e;
   } catch (FileExistsException e) {
     throw new GWTException(newRelativeFolder + " already exists");
   } catch (Exception e) {
     Application.log.error("", e);
     throw new GWTException(e);
   }
 }
Exemple #2
0
 private void createFolder(String folder, String systemFolderPath) throws GWTException {
   try {
     String baseName = FilenameUtils.getBaseName(folder);
     if (!FileNameUtil.isValidFileName(baseName)) {
       throw new GWTException(baseName + " has illegal characters");
     }
     File dirToCreate = new File(systemFolderPath);
     if (dirToCreate.exists()) {
       throw new GWTException(baseName + " already exists");
     }
     dirToCreate.mkdir();
   } catch (GWTException e) {
     throw e;
   } catch (Exception e) {
     Application.log.error("", e);
     throw new GWTException(e);
   }
 }
Exemple #3
0
  private void renameFileInSystem(
      String systemPath, String oldRelativeFile, String newRelativeFile) {
    try {
      if (!FileNameUtil.isValidFileName(newRelativeFile)) {
        throw new GWTException(newRelativeFile + " has illegal characters");
      }

      File srcDir = new File(systemPath + "/" + oldRelativeFile);
      File destDir = new File(systemPath + "/" + newRelativeFile);
      FileUtils.moveFile(srcDir, destDir);

    } catch (GWTException e) {
      throw e;
    } catch (FileExistsException e) {
      throw new GWTException(newRelativeFile + " already exists");
    } catch (Exception e) {
      Application.log.error("", e);
      throw new GWTException(e);
    }
  }