コード例 #1
0
 public void setEntityPathFilePath() {
   FilePath filePath = this.getEntityFilePath();
   Integer id = this.getId();
   if (filePath != null) {
     String message =
         "Modification du chemin \""
             + filePath.getFilePath()
             + "\" pour l'instance de la classe \""
             + this.entityClass.getName()
             + "\"";
     ApplicationLogger.writeInfo(message);
     String path = filePath.getFilePath();
     path = path.substring(0, path.lastIndexOf(File.separator));
     path += File.separator + String.format("%04d", id);
     try {
       Files.move(
           new File(Utils.getResourcesPath() + Utils.getUploadsPath() + filePath.getFilePath()),
           new File(Utils.getResourcesPath() + Utils.getUploadsPath() + path));
       filePath.setFilePath(path);
       this.filePathFacade.edit(filePath);
     } catch (IOException ex) {
       ApplicationLogger.writeError(
           "Erreur lors du déplacement du "
               + "dossier \""
               + Utils.getResourcesPath()
               + Utils.getUploadsPath()
               + filePath.getFilePath()
               + "\"",
           ex);
     }
   }
 }