Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -289,7 +289,6 @@ class SearchSessionController(
),
]
)
// CHANGE API RESPONSE TEXT
@PatchMapping("/patch-search-session/{sessionId}")
fun patchSearchSession(
@PathVariable systematicStudyId: UUID,
Expand Down
11 changes: 10 additions & 1 deletion web/src/main/kotlin/br/all/security/service/TokenService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CreateSearchSessionExampleService (
)

val searchSession = SearchSessionDto(
id = uuidGeneratorService.next(),
id = studyReviews[0].searchSessionId.value,
systematicStudyId = systematicStudyId.value(),
userId = userId,
searchString = searchString,
Expand Down
Loading