From fa49e68fe798cad7f5ba42e78788928ea2b39391 Mon Sep 17 00:00:00 2001 From: Erick Santinon Gomes Date: Tue, 18 Nov 2025 12:08:01 -0300 Subject: [PATCH 1/4] fix: add a try catch so when a token is expired it doesnt return 500 --- .../kotlin/br/all/security/service/TokenService.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/src/main/kotlin/br/all/security/service/TokenService.kt b/web/src/main/kotlin/br/all/security/service/TokenService.kt index 79a4edd57..4201e97c7 100644 --- a/web/src/main/kotlin/br/all/security/service/TokenService.kt +++ b/web/src/main/kotlin/br/all/security/service/TokenService.kt @@ -30,7 +30,16 @@ class TokenService(jwtProperties: JwtProperties) { fun extractUsername(token: String): String? = getAllClaims(token).subject - fun isExpired(token: String) = getAllClaims(token).expiration.before(Date(System.currentTimeMillis())) + fun isExpired(token: String): Boolean = + try { + val claims = getAllClaims(token) + val exp = claims.expiration + exp.before(Date()) + } catch (e: io.jsonwebtoken.ExpiredJwtException) { + true + } catch (e: Exception) { + true + } fun isValid(token: String, userDetails: UserDetails) = extractUsername(token) == userDetails.username && !isExpired(token) From 9b35c6747cc4bf671b9c22e1cf7d2a8221d58904 Mon Sep 17 00:00:00 2001 From: Erick Santinon Gomes Date: Tue, 18 Nov 2025 22:47:14 -0300 Subject: [PATCH 2/4] refactor: change response text --- .../kotlin/br/all/search/controller/SearchSessionController.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/src/main/kotlin/br/all/search/controller/SearchSessionController.kt b/web/src/main/kotlin/br/all/search/controller/SearchSessionController.kt index 29026c2ee..ad17ce733 100644 --- a/web/src/main/kotlin/br/all/search/controller/SearchSessionController.kt +++ b/web/src/main/kotlin/br/all/search/controller/SearchSessionController.kt @@ -269,7 +269,7 @@ class SearchSessionController( description = "Success updating an existing search session of a systematic study", content = [Content( mediaType = "application/json", - schema = Schema(implementation = UpdateSearchSessionService.ResponseModel::class) + schema = Schema(implementation = PatchSearchSessionService.ResponseModel::class) )] ), ApiResponse( @@ -289,7 +289,6 @@ class SearchSessionController( ), ] ) - // CHANGE API RESPONSE TEXT @PatchMapping("/patch-search-session/{sessionId}") fun patchSearchSession( @PathVariable systematicStudyId: UUID, From b810ffd5aa3a07282868a92e20cf0ac3940aa5fe Mon Sep 17 00:00:00 2001 From: Erick Santinon Gomes Date: Wed, 19 Nov 2025 00:20:22 -0300 Subject: [PATCH 3/4] refactor: remove redundant code --- .../service/FindAllStudyReviewsBySourceServiceImpl.kt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/review/src/main/kotlin/br/all/application/study/find/service/FindAllStudyReviewsBySourceServiceImpl.kt b/review/src/main/kotlin/br/all/application/study/find/service/FindAllStudyReviewsBySourceServiceImpl.kt index 3c96a6eb3..d6c66cfd5 100644 --- a/review/src/main/kotlin/br/all/application/study/find/service/FindAllStudyReviewsBySourceServiceImpl.kt +++ b/review/src/main/kotlin/br/all/application/study/find/service/FindAllStudyReviewsBySourceServiceImpl.kt @@ -14,7 +14,6 @@ import br.all.domain.model.review.SystematicStudy class FindAllStudyReviewsBySourceServiceImpl( private val systematicStudyRepository: SystematicStudyRepository, private val studyReviewRepository: StudyReviewRepository, - // private val protocolRepository: ProtocolRepository, private val credentialsService: CredentialsService, ) : FindAllStudyReviewsBySourceService { @@ -26,18 +25,8 @@ class FindAllStudyReviewsBySourceServiceImpl( presenter.prepareIfFailsPreconditions(user, systematicStudy) - if(presenter.isDone()) return - val searchSource = SearchSource(request.searchSource) -// val protocolDto = protocolRepository.findBySystematicStudy(systematicStudyId.value) -// val hasSource = protocolDto?.informationSources?.contains(searchSource.id) ?: false -// -// if (!hasSource) { -// val message = "Protocol ID $systematicStudyId does not contain ${searchSource.id} as a search source" -// presenter.prepareFailView(NoSuchElementException(message)) -// } - if (presenter.isDone()) return val studyReviews = studyReviewRepository.findAllBySource(request.systematicStudyId, searchSource.toString()) From a3eec1fdaf1847168656532c6998cc27899b19e7 Mon Sep 17 00:00:00 2001 From: Erick Santinon Gomes Date: Wed, 19 Nov 2025 00:20:50 -0300 Subject: [PATCH 4/4] fix: searchSession was being generated with random id --- .../br/all/utils/example/CreateSearchSessionExampleService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/main/kotlin/br/all/utils/example/CreateSearchSessionExampleService.kt b/web/src/main/kotlin/br/all/utils/example/CreateSearchSessionExampleService.kt index fe8f76b2e..93d518963 100644 --- a/web/src/main/kotlin/br/all/utils/example/CreateSearchSessionExampleService.kt +++ b/web/src/main/kotlin/br/all/utils/example/CreateSearchSessionExampleService.kt @@ -47,7 +47,7 @@ class CreateSearchSessionExampleService ( ) val searchSession = SearchSessionDto( - id = uuidGeneratorService.next(), + id = studyReviews[0].searchSessionId.value, systematicStudyId = systematicStudyId.value(), userId = userId, searchString = searchString,