Skip to content

Commit

Permalink
DMP-4613 Add ARM RPO check for getExtendedProductionsByMatter status
Browse files Browse the repository at this point in the history
Fixed sonar complaint
  • Loading branch information
karen-hedges committed Jan 22, 2025
1 parent f4264f1 commit eb73834
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/uk/gov/hmcts/darts/arm/rpo/impl/ArmRpoApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class ArmRpoApiImpl implements ArmRpoApi {
private static final String CREATE_EXPORT_CSV_EXTENSION = "_CSV";

private static final String COULD_NOT_CONSTRUCT_API_REQUEST = "Could not construct API request: ";
public static final String AND_RESPONSE = " and response - ";
private static final String AND_RESPONSE = " and response - ";

private final ArmRpoClient armRpoClient;
private final ArmRpoService armRpoService;
Expand Down Expand Up @@ -138,17 +138,18 @@ private void processIndexesByMatterIdResponse(String matterId, UserAccountEntity
ArmRpoExecutionDetailEntity armRpoExecutionDetailEntity) {
handleResponseStatus(userAccount, indexesByMatterIdResponse, errorMessage, armRpoExecutionDetailEntity);

if (CollectionUtils.isEmpty(indexesByMatterIdResponse.getIndexes())
|| isNull(indexesByMatterIdResponse.getIndexes().getFirst())
|| isNull(indexesByMatterIdResponse.getIndexes().getFirst().getIndex())
|| StringUtils.isBlank(indexesByMatterIdResponse.getIndexes().getFirst().getIndex().getIndexId())) {
List<IndexesByMatterIdResponse.Index> indexes = indexesByMatterIdResponse.getIndexes();
if (CollectionUtils.isEmpty(indexes)
|| isNull(indexes.getFirst())
|| isNull(indexes.getFirst().getIndex())
|| StringUtils.isBlank(indexes.getFirst().getIndex().getIndexId())) {
throw handleFailureAndCreateException(errorMessage.append("Unable to find any indexes by matter ID in response").toString(),
armRpoExecutionDetailEntity,
userAccount);
}

String indexId = indexesByMatterIdResponse.getIndexes().getFirst().getIndex().getIndexId();
if (indexesByMatterIdResponse.getIndexes().size() > 1) {
String indexId = indexes.getFirst().getIndex().getIndexId();
if (indexes.size() > 1) {
log.warn("More than one index found in response for matterId: {}. Using first index id: {} from response: {}",
matterId, indexId, indexesByMatterIdResponse);
}
Expand Down Expand Up @@ -246,8 +247,9 @@ private void processGetProfileEntitlementsResponse(UserAccountEntity userAccount
var profileEntitlement = entitlements.stream()
.filter(entitlement -> configuredEntitlement.equals(entitlement.getName()))
.findFirst()
.orElseThrow(() -> handleFailureAndCreateException(exceptionMessageBuilder.append(
"No matching entitlements '" + configuredEntitlement + "' were returned").toString(), executionDetail, userAccount));
.orElseThrow(() -> handleFailureAndCreateException(
exceptionMessageBuilder.append("No matching entitlements '").append(configuredEntitlement).append("' were returned").toString(),
executionDetail, userAccount));

String entitlementId = profileEntitlement.getEntitlementId();
if (StringUtils.isEmpty(entitlementId)) {
Expand Down

0 comments on commit eb73834

Please sign in to comment.