Commit 0b97bed5 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when model in project doesn't exist project update doesn't crash

parent 3dab2e84
Pipeline #4340 passed with stage
in 1 minute and 33 seconds
......@@ -870,17 +870,16 @@ public class ProjectService implements IProjectService {
modelDao.update(originalModel);
if (params.isAnalyzeAnnotations()) {
analyzeAnnotations(originalModel, params);
}
Logger.getRootLogger().removeAppender(appender);
project.addLoggingInfo(appender);
if (params.isCacheModel()) {
cacheData(originalModel, params);
}
updateProjectStatus(project, ProjectStatus.DONE, IProgressUpdater.MAX_PROGRESS, params);
if (project.getNotifyEmail() != null && !project.getNotifyEmail().equals("")) {
try {
......@@ -1351,7 +1350,10 @@ public class ProjectService implements IProjectService {
public void updateProject(Project project, String token) throws SecurityException {
projectDao.update(project);
if (token != null) {
modelService.getLastModelByProjectId(project.getProjectId(), token).setProject(project);
Model model = modelService.getLastModelByProjectId(project.getProjectId(), token);
if (model != null) {
model.setProject(project);
}
}
}
......
......@@ -780,4 +780,20 @@ public class ProjectServiceTest extends ServiceTestFunctions {
}
}
@Test
public void testUpdateProjectWithoutModel() throws Exception {
try {
createUser();
Project project = new Project();
project.setProjectId(projectId);
projectDao.add(project);
projectService.updateProject(project, adminToken);
projectService.removeProject(project, null, false, adminToken);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment