Exemplo n.º 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);
     }
   }
 }
Exemplo n.º 2
0
 protected void removeFilePath() {
   FilePath filePath = this.getEntityFilePath();
   if (filePath != null) {
     File path =
         new File(
             Utils.getResourcesPath()
                 + Utils.getUploadsPath()
                 + filePath.getFilePath()
                 + File.separator);
     try {
       if (path.exists()) {
         Files.deleteContent(path);
         Files.deleteFolder(path);
       }
       this.filePathFacade.remove(filePath);
     } catch (FileNotFoundException ex) {
       ApplicationLogger.writeError(
           "Le dossier \"" + path.getPath() + "\" n'a pas pu être supprimé", ex);
     }
   }
 }