-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ESWE-1181] Fix API clients, JPA auditing #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package uk.gov.justice.digital.hmpps.jobsboardintegrationapi.config | ||
|
||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing | ||
|
||
@Configuration | ||
@EnableJpaAuditing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enable JPA auditing for audit fields (create and last updated timestamps) |
||
class JpaConfig |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add client logging for troubleshooting, disabled by default. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,9 @@ class JobsBoardApiWebClient( | |
return jobsBoardWebClient | ||
.get().uri("/employers/{id}", id).accept(APPLICATION_JSON).retrieve() | ||
.bodyToMono(GetEmployerResponse::class.java) | ||
.onErrorResume(WebClientResponseException.NotFound::class.java) { | ||
log.debug("Employer not found. employerId={}", id) | ||
.onErrorResume(WebClientResponseException.NotFound::class.java) { error -> | ||
val errorResponse = if (error is WebClientResponseException) error.responseBodyAsString else null | ||
log.warn("Employer not found. employerId={}; errorResponse={}", id, errorResponse) | ||
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error logging - write down the error response, if any |
||
Mono.empty() | ||
}.block()?.employer() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Qualifier | |
import org.springframework.http.MediaType.APPLICATION_JSON | ||
import org.springframework.stereotype.Service | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import org.springframework.web.reactive.function.client.WebClientResponseException | ||
import reactor.core.publisher.Mono | ||
import uk.gov.justice.digital.hmpps.jobsboardintegrationapi.config.ConditionalOnIntegrationEnabled | ||
import uk.gov.justice.digital.hmpps.jobsboardintegrationapi.shared.domain.MNJobBoardApiClient | ||
|
@@ -23,9 +24,15 @@ class MNJobBoardApiWebClient( | |
|
||
override fun createEmployer(request: CreatEmployerRequest): CreatEmployerResponse { | ||
log.debug("Creating employer employerName={}", request.employerName) | ||
return mnJobBoardWebClient.post().uri(EMPLOYERS_ENDPOINT).accept(APPLICATION_JSON).retrieve() | ||
log.trace("Create employer request={}", request) | ||
return mnJobBoardWebClient.post().uri(EMPLOYERS_ENDPOINT) | ||
.accept(APPLICATION_JSON).body(Mono.just(request), request.javaClass) | ||
.retrieve() | ||
.bodyToMono(MNCreatEmployerResponse::class.java) | ||
.onErrorResume { error -> Mono.error(Exception("Fail to create employer", error)) }.block()!! | ||
.onErrorResume { error -> | ||
val errorResponse = if (error is WebClientResponseException) error.responseBodyAsString else null | ||
Mono.error(Exception("Fail to create employer! errorResponse=$errorResponse", error)) | ||
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error logging - write down the error response, if any |
||
}.block()!! | ||
.responseObject | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"properties": [ | ||
{ | ||
"name": "api.base.url.jobsboard", | ||
"type": "java.lang.String", | ||
"description": "Base URL for Jobs Board APIs" | ||
}, | ||
{ | ||
"name": "api.base.url.mnjobboard", | ||
"type": "java.lang.String", | ||
"description": "Base URL for MN Job Board APIs" | ||
}, | ||
{ | ||
"name": "api.integration.enabled", | ||
"type": "java.lang.String", | ||
"description": "Feature flag to switch on/off JobsBoard-to-MN-Job-Board Integration functions" | ||
}, | ||
{ | ||
"name": "api.client.logging.enabled", | ||
"type": "java.lang.String", | ||
"description": "Enabling client logging at API Web Client; disabled by default" | ||
} | ||
] } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,10 @@ api: | |
base.url: | ||
jobsboard: "https://jobs-board-api-dev.hmpps.service.justice.gov.uk" | ||
mnjobboard: "https://testservices.sequation.net/sequation-job-api" | ||
|
||
integration: | ||
enabled: false | ||
client.logging: | ||
enabled: false | ||
|
||
spring: | ||
datasource: | ||
|
@@ -25,3 +26,8 @@ spring: | |
flyway: | ||
user: 'job-board-intg' | ||
password: 'job-board-intg' | ||
|
||
logging.level: | ||
uk.gov.justice.digital.hmpps.jobsboardintegrationapi: | ||
shared.infrastructure: DEBUG | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set this to |
||
reactor.netty.http.client: INFO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set this to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename container for avoiding name clash to
hmpps-auth
instance (standalone at 9090)