From b9be8fc5725b032d6930b80aa0c90b073875e949 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Fri, 10 Nov 2017 14:05:10 +0100 Subject: [PATCH] project files are removed before marking project as removed --- .../api/projects/ProjectRestImpl.java | 1 - .../services/impl/ProjectService.java | 35 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java index 10f59bfadd..0768945b28 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java @@ -559,7 +559,6 @@ public class ProjectRestImpl extends BaseRestImpl { protected String computePathForProject(String projectId, String path) { long id = projectDao.getNextId(); - logger.debug(id); return path + "/../map_images/" + md5(projectId + "-" + id) + "/"; } diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java index f50002b773..977c151b2c 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java @@ -120,7 +120,7 @@ import lcsb.mapviewer.services.view.ProjectViewFactory; public class ProjectService implements IProjectService { /** - * Size of the artifitial buffer that will be released when + * Size of the artificial buffer that will be released when * {@link OutOfMemoryError} is thrown to gain some free memory and report * problem. */ @@ -132,7 +132,7 @@ public class ProjectService implements IProjectService { private static final double CREATION_OF_DATA = 0.50; /** - * How much time (out of 1.00) is used for upploading of the data from file. + * How much time (out of 1.00) is used for uploading of the data from file. */ private static final double UPLOAD_OF_DATA = 0.50; @@ -192,19 +192,19 @@ public class ProjectService implements IProjectService { private IUserService userService; /** - * Services that accessa data about chemicals. + * Services that access data about chemicals. */ @Autowired private IChemicalService chemicalService; /** - * Services that accessa data about drugs. + * Services that access data about drugs. */ @Autowired private IDrugService drugService; /** - * Services that accessa data about mirna. + * Services that access data about mirna. */ @Autowired private IMiRNAService mirnaService; @@ -414,8 +414,7 @@ public class ProjectService implements IProjectService { public void run() { if (async) { // because we are running this in separate thread we need to open a - // new - // session for db connection + // new session for db connection dbUtils.createSessionForCurrentThread(); } @@ -445,6 +444,17 @@ public class ProjectService implements IProjectService { } email = project.getNotifyEmail(); } + if (homeDir != null) { + File homeDirFile = new File(homeDir); + if (homeDirFile.exists()) { + logger.debug("Removing project directory: " + homeDirFile.getAbsolutePath()); + try { + FileUtils.deleteDirectory(homeDirFile); + } catch (IOException e) { + logger.error("Problem with removing diriectory", e); + } + } + } projectDao.delete(project); if (async) { projectDao.commit(); @@ -471,17 +481,6 @@ public class ProjectService implements IProjectService { dbUtils.closeSessionForCurrentThread(); } } - if (homeDir != null) { - File homeDirFile = new File(homeDir); - if (homeDirFile.exists()) { - logger.debug("Removing project directory: " + homeDirFile.getAbsolutePath()); - try { - FileUtils.deleteDirectory(homeDirFile); - } catch (IOException e) { - logger.error("Problem with removing diriectory", e); - } - } - } } }); -- GitLab