fix: sometimes, project administrators may be null. Fixing nullPointerException
All checks were successful
Format / formatting (push) Successful in 6s
Build / build (push) Successful in 37s
CI / build (push) Successful in 11s

This commit is contained in:
Pierre Tellier 2025-03-17 09:18:21 +01:00
parent 834d68949c
commit 84b70f8f38

View File

@ -77,7 +77,7 @@ public class AdminApiService {
// TODO: check if tests are sufficient - peer verification required // TODO: check if tests are sufficient - peer verification required
public void addNewProject(Project project) { public void addNewProject(Project project) {
project.setIdProject(null); project.setIdProject(null);
// We remove it from the request to be sure that it will be auto generated // We remove the ID from the request to be sure that it will be auto generated
try { try {
this.projectService.getProjectByName(project.getProjectName(), true); this.projectService.getProjectByName(project.getProjectName(), true);
throw new ResponseStatusException(HttpStatus.CONFLICT, "Project already exists"); throw new ResponseStatusException(HttpStatus.CONFLICT, "Project already exists");
@ -87,8 +87,12 @@ public class AdminApiService {
} }
} }
Project newProject = projectService.addNewProject(project); Project newProject = projectService.addNewProject(project);
newProject.getProjectAdministrator().updateListProject(newProject); if (project.getProjectAdministrator() != null) {
newProject.getEntrepreneurProposed().setProjectProposed(newProject); newProject.getProjectAdministrator().updateListProject(newProject);
}
if (newProject.getEntrepreneurProposed() != null) {
newProject.getEntrepreneurProposed().setProjectProposed(newProject);
}
newProject newProject
.getListEntrepreneurParticipation() .getListEntrepreneurParticipation()
.forEach( .forEach(