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
@@ -1,16 +1,16 @@
package uk.gov.hmcts.reform.prl.clients;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.dto.datamigration.caseflag.CaseFlag;
import uk.gov.hmcts.reform.prl.models.dto.hearingdetails.CommonDataResponse;

@FeignClient(name = "common-ref-data-api", url = "${commonData.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class)
configuration = FeignRetryConfig.class)
public interface CommonDataRefApi {

@GetMapping(value = "refdata/commondata/lov/categories/{categoryId}", consumes = "application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.constants.PrlAppsConstants;
import uk.gov.hmcts.reform.prl.models.court.Court;
import uk.gov.hmcts.reform.prl.models.court.ServiceArea;

@FeignClient(name = "court-finder-api", primary = false, url = "${courtfinder.api.url}")
@FeignClient(name = "court-finder-api", primary = false, url = "${courtfinder.api.url}",
configuration = FeignRetryConfig.class)
public interface CourtFinderApi {



@GetMapping(value = PrlAppsConstants.CHILD_ARRANGEMENTS_POSTCODE_URL)
ServiceArea findClosestChildArrangementsCourtByPostcode(@PathVariable("postcode") String postcode);

Expand All @@ -21,5 +21,4 @@ public interface CourtFinderApi {

@GetMapping(value = PrlAppsConstants.DOMESTIC_ABUSE_POSTCODE_URL)
ServiceArea findClosestDomesticAbuseCourtByPostCode(@PathVariable("postcode") String postcode);

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package uk.gov.hmcts.reform.prl.clients;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.FeeResponse;

@FeignClient(
name = "fees-register-api",
url = "${fees-register.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class
configuration = FeignRetryConfig.class
)
public interface FeesRegisterApi {
@GetMapping("/fees-register/fees/lookup")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package uk.gov.hmcts.reform.prl.clients;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.dto.ccd.AutomatedHearingCaseData;
import uk.gov.hmcts.reform.prl.models.dto.ccd.AutomatedHearingResponse;
import uk.gov.hmcts.reform.prl.models.dto.hearingmanagement.NextHearingDetails;
Expand All @@ -20,7 +20,7 @@
@FeignClient(
name = "hearing-api",
url = "${fis_hearing.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class
configuration = FeignRetryConfig.class
)
public interface HearingApiClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.court.CourtDetails;

@FeignClient(name = "location-ref-data-api", primary = false, url = "${locationfinder.api.url}")
@FeignClient(name = "location-ref-data-api", primary = false, url = "${locationfinder.api.url}",
configuration = FeignRetryConfig.class)
public interface LocationRefDataApi {
@GetMapping(value = "/refdata/location/court-venues/services")
CourtDetails getCourtDetailsByService(@RequestHeader("Authorization") String authorization,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package uk.gov.hmcts.reform.prl.clients;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.OrgSolicitors;
import uk.gov.hmcts.reform.prl.models.OrganisationUser;
import uk.gov.hmcts.reform.prl.models.Organisations;
Expand All @@ -15,7 +15,7 @@
@FeignClient(
name = "rd-professional-api",
url = "${rd_professional.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class
configuration = FeignRetryConfig.class
)
public interface OrganisationApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.dto.payment.OnlineCardPaymentRequest;
import uk.gov.hmcts.reform.prl.models.dto.payment.PaymentResponse;
import uk.gov.hmcts.reform.prl.models.dto.payment.PaymentServiceRequest;
Expand All @@ -16,7 +17,8 @@
import uk.gov.hmcts.reform.prl.models.dto.payment.ServiceRequestReferenceStatusResponse;

@ConditionalOnProperty(prefix = "payments", name = "api.url")
@FeignClient(name = "payments", url = "${payments.api.url}")
@FeignClient(name = "payments", url = "${payments.api.url}",
configuration = FeignRetryConfig.class)
public interface PaymentApi {

@PostMapping(value = "/service-request", consumes = "application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.config.consts.CustomHttpHeaders;
import uk.gov.hmcts.reform.prl.models.dto.payment.PbaOrganisationResponse;

@FeignClient(name = "pba-validation-client", url = "${pba.validation.service.api.baseurl}")
@FeignClient(name = "pba-validation-client", url = "${pba.validation.service.api.baseurl}",
configuration = FeignRetryConfig.class)
public interface PbaValidationClient {

@Operation(description = "Validates Solicitor Pay By Account (PBA) number for payment")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package uk.gov.hmcts.reform.prl.clients;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -10,6 +9,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.roleassignment.addroleassignment.RoleAssignmentQueryRequest;
import uk.gov.hmcts.reform.prl.models.roleassignment.addroleassignment.RoleAssignmentRequest;
import uk.gov.hmcts.reform.prl.models.roleassignment.addroleassignment.RoleAssignmentResponse;
Expand All @@ -18,7 +18,7 @@

@FeignClient(name = "amRoleAssignment",
url = "${amRoleAssignment.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class)
configuration = FeignRetryConfig.class)
public interface RoleAssignmentApi {

@PostMapping(path = "/am/role-assignments", consumes = "application/json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package uk.gov.hmcts.reform.prl.clients.cafcass;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.cafcass.hearing.Hearings;

import java.util.List;
Expand All @@ -14,7 +14,7 @@
@FeignClient(
name = "hearing-api-cafcaas",
url = "${fis_hearing.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class
configuration = FeignRetryConfig.class
)
public interface HearingApiClient {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package uk.gov.hmcts.reform.prl.clients.cafcass;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.cafcass.hearing.refdata.Categories;

import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@FeignClient(
name = "ref-data",
url = "${refdata.api.url}",
configuration = FeignClientProperties.FeignClientConfiguration.class)
configuration = FeignRetryConfig.class)
public interface ReferenceDataApi {
String SERVICE_AUTHORIZATION = "ServiceAuthorization";
String REF_DATA_CATEGORY_ENDPOINT = "/refdata/commondata/lov/categories";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.extendedcasedetails.ExtendedCaseDetails;

import static org.springframework.http.HttpHeaders.AUTHORIZATION;
Expand All @@ -12,7 +13,8 @@
@FeignClient(
name = "core-case-data-api",
primary = false,
url = "${core_case_data.api.url}"
url = "${core_case_data.api.url}",
configuration = FeignRetryConfig.class
)
public interface ExtendedCaseDataApi {
String SERVICE_AUTHORIZATION = "ServiceAuthorization";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.prl.config.FeignRetryConfig;
import uk.gov.hmcts.reform.prl.models.ordnancesurvey.OsPlacesResponse;

@FeignClient(name = "os-court-finder-api", primary = false, url = "${postcodelookup.api.url}",
configuration = OsCourtFinderApi.FeignClientConfiguration.class)
public interface OsCourtFinderApi {

// Nested configuration class ensures it is only used for this client
class FeignClientConfiguration {
class FeignClientConfiguration extends FeignRetryConfig {

@Value("${postcodelookup.api.key}")
private String apiKey;
Expand Down
54 changes: 54 additions & 0 deletions src/main/java/uk/gov/hmcts/reform/prl/config/FeignRetryConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package uk.gov.hmcts.reform.prl.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collection;

@Configuration
@Slf4j
public class FeignRetryConfig extends FeignClientProperties.FeignClientConfiguration {

@Bean
public feign.Retryer feignRetryer() {
return new feign.Retryer.Default(500, 3000, 5);
}

@Bean
public feign.codec.ErrorDecoder feignErrorDecoder() {
return (methodKey, response) -> {
log.error("Feign error in {} status={} method={}",
methodKey,
response.status(),
response.request().httpMethod());

Collection<String> retryAfterHeader = response.headers().get("Retry-After");

Long retryAfter = null;

if (retryAfterHeader != null && !retryAfterHeader.isEmpty()) {
retryAfter = Long.parseLong(retryAfterHeader.iterator().next()) * 1000;
}

// Only retry GET methods and 5xx responses
boolean isGet = response.request().httpMethod() == feign.Request.HttpMethod.GET;
int status = response.status();

if (isGet && status >= 500 && status < 600) {
log.warn("retrying now for status {}", status);
return new feign.RetryableException(
status,
"Retryable 5xx for GET",
response.request().httpMethod(),
null,
retryAfter,
response.request()
);
}

return feign.FeignException.errorStatus(methodKey, response);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -26,10 +28,16 @@ void removeCaseRoles(
@RequestBody final RemoveUserRolesRequest request
);


@PostMapping(
value = "/case-users/search",
consumes = MediaType.APPLICATION_JSON_VALUE
)
@Retryable(
value = { Exception.class },
maxAttempts = 3,
backoff = @Backoff(delay = 500)
)
FindUserCaseRolesResponse findUserCaseRoles(
@RequestHeader(AUTHORIZATION) String authorisation,
@RequestHeader(SERVICE_AUTHORIZATION) String serviceAuthorization,
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,8 @@ hwf-update-case-state-task:
prepare-hearing-bundle:
calendar-days-before-hearing: ${PREPARE_HEARING_BUNDLE_CALENDAR_DAYS_BEFORE_HEARING:7}

feign:
client:
config:
default:
loggerLevel: FULL