diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/GetNavActionById.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/GetNavActionById.kt index 07934015..9fb2321c 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/GetNavActionById.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/GetNavActionById.kt @@ -16,15 +16,20 @@ class GetNavActionById( ): GetMissionAction(getStatusForAction, getControlByActionId) { private val logger = LoggerFactory.getLogger(GetNavActionById::class.java) - fun execute(actionId: UUID?): MissionNavActionEntity? { + fun execute(actionId: String?): MissionNavActionEntity? { if (actionId == null) { logger.error("GetNavActionById received a null actionId") throw IllegalArgumentException("GetNavActionById should not receive null missionId or actionId null") } - val model = missionActionRepository.findById(actionId).orElse(null) ?: return null - val entity = MissionNavActionEntity.fromMissionActionModel(model) - entity.computeControls(controls = this.getControls(entity)) - entity.computeCompleteness() - return entity + return try { + val model = missionActionRepository.findById(UUID.fromString(actionId)).orElse(null) ?: return null + val entity = MissionNavActionEntity.fromMissionActionModel(model) + entity.computeControls(controls = this.getControls(entity)) + entity.computeCompleteness() + entity + } catch (e: Exception) { + logger.error("GetNavActionById failed loading action", e) + return null + } } } diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/UpdateNavAction.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/UpdateNavAction.kt index 4ea1c35b..c2e44146 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/UpdateNavAction.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/action/v2/UpdateNavAction.kt @@ -5,7 +5,6 @@ import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionNavActionEnti import fr.gouv.dgampa.rapportnav.domain.repositories.mission.action.INavMissionActionRepository import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.control.v2.ProcessMissionActionControl import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.infraction.v2.ProcessMissionActionInfraction -import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionAction import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionNavAction import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionNavActionData import org.slf4j.LoggerFactory diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/api/bff/v2/MissionActionRestController.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/api/bff/v2/MissionActionRestController.kt index a4e3177a..aeb893ea 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/api/bff/v2/MissionActionRestController.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/api/bff/v2/MissionActionRestController.kt @@ -2,7 +2,10 @@ package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.v2 import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionSourceEnum import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.* -import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.* +import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionAction +import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionEnvAction +import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionFishAction +import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionNavAction import io.swagger.v3.oas.annotations.Operation import org.slf4j.LoggerFactory import org.springframework.web.bind.annotation.* @@ -41,7 +44,7 @@ class MissionActionRestController( @PathVariable(name = "missionId") missionId: Int, @PathVariable(name = "actionId") actionId: String, ): MissionAction? { - val navAction = getNavActionById.execute(actionId = UUID.fromString(actionId)) + val navAction = getNavActionById.execute(actionId = actionId) if (navAction != null) return MissionAction.fromMissionActionEntity(navAction) val fishAction = getFishActionById.execute(missionId = missionId, actionId = actionId) diff --git a/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/action/GetNavActionByIdTest.kt b/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/action/GetNavActionByIdTest.kt index 7cf4f05f..d2257eaa 100644 --- a/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/action/GetNavActionByIdTest.kt +++ b/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/action/GetNavActionByIdTest.kt @@ -59,7 +59,7 @@ class GetNavActionByIdTest { missionActionRepository = missionActionRepository, getStatusForAction = getStatusForAction, getControlByActionId = getControlByActionId ) - val missionEnvAction = getNavActionById.execute(actionId = actionId) + val missionEnvAction = getNavActionById.execute(actionId = actionId.toString()) assertThat(missionEnvAction).isNotNull assertThat(missionEnvAction?.getActionId()).isEqualTo(actionId.toString())