diff --git a/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt b/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt index d3099f14c43e15aae2c81d6f3545d9ccc08da589..e0561b84a8962c5ae9f2b657aaa4d11caae5d174 100644 --- a/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt +++ b/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt @@ -166,13 +166,22 @@ class RepositoryController( false } - val toolRun = - toolRunService.getToolRunForRepository( - projectId = id, - includeFindings = isProjectMember, - ) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "tool run not found") + val toolRunDto = + repositoryService.getToolRunByProjectId(projectId = id) + ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "tool run not found") + + val response = + if (isProjectMember) { + toolRunService.getFindingsForToolRun( + projectId = id, + includeFindings = isProjectMember, + toolRun = toolRunDto, + ) + } else { + toolRunDto + } - return ToolRunResponseDto(isProjectMember = isProjectMember, toolRun = toolRun) + return ToolRunResponseDto(isProjectMember = isProjectMember, toolRun = response) } @PostMapping(ApiPaths.REPOSITORY_UPDATE_CONSENT) diff --git a/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt b/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt index 4cc7d021193cc9f783ec60a137bd3758f452aa33..d74207742c52ef91fd8ac33dc5a2fc06a50b48b9 100644 --- a/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt +++ b/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt @@ -142,17 +142,16 @@ class ToolRunService( * This method retrieves the tool run stored for the given repository. Additionally, it queries * the tool APIs for all tools contained in the tool run and create finding objects for them. */ - suspend fun getToolRunForRepository( + suspend fun getFindingsForToolRun( projectId: Long, + toolRun: ToolRunDto, includeFindings: Boolean = false, - ): ToolRunDto? { - - val toolRun = repositoryService.getToolRunByProjectId(projectId = projectId) + ): ToolRunDto { val apiJobs: MutableList<Job> = mutableListOf() if (includeFindings) { - toolRun?.tools?.forEach { tool -> + toolRun.tools.forEach { tool -> when (tool.toolType) { ToolType.ORT -> { apiJobs.add(