FINERACT-2346: Refractor, Minor Sonar fixes and remove some deprecated code

This commit is contained in:
Aman-Mittal
2025-12-01 19:11:59 +01:00
committed by Adam Saghy
parent 73d8659390
commit 00e9ac8320
17 changed files with 83 additions and 123 deletions
@@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
@@ -90,7 +89,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("health")
@Operation(summary = "Query Interoperation Health Request", description = "")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") })
@ApiResponse(responseCode = "200", description = "OK")
public String health(@Context UriInfo uriInfo) {
return "OK";
}
@@ -100,8 +99,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}")
@Operation(summary = "Query Interoperation Account details", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropAccountData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropAccountData.class)))
public String getAccountDetails(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@Context UriInfo uriInfo) {
InteropAccountData result = interopService.getAccountDetails(accountId);
@@ -115,8 +113,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}/transactions")
@Operation(summary = "Query transactions by Account Id", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionsData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionsData.class)))
public String getAccountTransactions(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@DefaultValue("true") @QueryParam("debit") @Parameter(description = "debit") boolean debit,
@DefaultValue("false") @QueryParam("credit") @Parameter(description = "credit") boolean credit,
@@ -139,8 +136,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}/identifiers")
@Operation(summary = "Query Interoperation secondary identifiers by Account Id", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifiersResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifiersResponseData.class)))
public String getAccountIdentifiers(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@Context UriInfo uriInfo) {
InteropIdentifiersResponseData result = interopService.getAccountIdentifiers(accountId);
@@ -154,8 +150,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("parties/{idType}/{idValue}")
@Operation(summary = "Query Interoperation Account by secondary identifier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String getAccountByIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue, @Context UriInfo uriInfo) {
InteropIdentifierAccountResponseData result = interopService.getAccountByIdentifier(idType, idValue, null);
@@ -169,8 +164,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("parties/{idType}/{idValue}/{subIdOrType}")
@Operation(summary = "Query Interoperation Account by secondary identifier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String getAccountByIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue,
@PathParam("subIdOrType") @Parameter(description = "subIdOrType") String subIdOrType, @Context UriInfo uriInfo) {
@@ -186,8 +180,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}")
@Operation(summary = "Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String registerAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue, @Parameter(hidden = true) String identifierJson,
@Context UriInfo uriInfo) {
@@ -207,8 +200,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}/{subIdOrType}")
@Operation(summary = "Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String registerAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue,
@PathParam("subIdOrType") @Parameter(description = "subIdOrType") String subIdOrType,
@@ -229,8 +221,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}")
@Operation(summary = "Allow Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String deleteAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue, @Context UriInfo uriInfo) {
CommandWrapper commandRequest = new InteropWrapperBuilder().deleteAccountIdentifier(idType, idValue, null).build();
@@ -248,8 +239,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}/{subIdOrType}")
@Operation(summary = "Allow Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String deleteAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue,
@PathParam("subIdOrType") @Parameter(description = "subIdOrType") String subIdOrType, @Context UriInfo uriInfo) {
@@ -267,8 +257,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{transactionCode}/requests/{requestCode}")
@Operation(summary = "Query Interoperation Transaction Request", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class)))
public String getTransactionRequest(@PathParam("transactionCode") @Parameter(description = "transactionCode") String transactionCode,
@PathParam("requestCode") @Parameter(description = "requestCode") String requestCode, @Context UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(ENTITY_NAME_REQUEST);
@@ -285,8 +274,7 @@ public class InteropApiResource {
@Path("requests")
@Operation(summary = "Allow Interoperation Transaction Request", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropTransactionRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class)))
public String createTransactionRequest(@Parameter(hidden = true) String quotesJson, @Context UriInfo uriInfo) {
CommandWrapper commandRequest = new InteropWrapperBuilder().createTransactionRequest().withJson(quotesJson).build();
@@ -302,8 +290,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{transactionCode}/quotes/{quoteCode}")
@Operation(summary = "Query Interoperation Quote", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class)))
public String getQuote(@PathParam("transactionCode") @Parameter(description = "transactionCode") String transactionCode,
@PathParam("quoteCode") @Parameter(description = "quoteCode") String quoteCode, @Context UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(ENTITY_NAME_QUOTE);
@@ -320,8 +307,7 @@ public class InteropApiResource {
@Path("quotes")
@Operation(summary = "Calculate Interoperation Quote", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropQuoteRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class)))
public String createQuote(@Parameter(hidden = true) String quotesJson, @Context UriInfo uriInfo) {
CommandWrapper commandRequest = new InteropWrapperBuilder().createQuotes().withJson(quotesJson).build();
@@ -336,8 +322,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{transactionCode}/transfers/{transferCode}")
@Operation(summary = "Query Interoperation Transfer", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class)))
public String getTransfer(@PathParam("transactionCode") @Parameter(description = "transactionCode") String transactionCode,
@PathParam("transferCode") @Parameter(description = "transferCode") String transferCode, @Context UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(ENTITY_NAME_QUOTE);
@@ -354,8 +339,7 @@ public class InteropApiResource {
@Path("transfers")
@Operation(summary = "Prepare Interoperation Transfer", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropTransferRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class)))
public String performTransfer(@QueryParam("action") @Parameter(description = "action") String action,
@Parameter(hidden = true) String quotesJson, @Context UriInfo uriInfo) {
@@ -383,8 +367,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}/kyc")
@Operation(summary = "Query KYC by Account Id", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropKycResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropKycResponseData.class)))
public String getClientKyc(@PathParam("accountId") @Parameter(description = "accountId") String accountId, @Context UriInfo uriInfo) {
InteropKycResponseData result = interopService.getKyc(accountId);
ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
@@ -458,17 +458,15 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
private void checkClientOrGroupActive(final Loan loan) {
final Client client = loan.client();
if (client != null) {
if (client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
if (client != null && client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
final Group group = loan.group();
if (group != null) {
if (group.isNotActive()) {
throw new GroupNotActiveException(group.getId());
}
if (group != null && group.isNotActive()) {
throw new GroupNotActiveException(group.getId());
}
}
@Override
@@ -46,7 +46,7 @@ public class GenerateAdhocClientScheduleTasklet implements Tasklet {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
final Collection<AdHocData> adhocs = adHocReadPlatformService.retrieveAllActiveAdHocQuery();
if (adhocs.size() > 0) {
if (!adhocs.isEmpty()) {
adhocs.forEach(adhoc -> {
boolean run = true;
LocalDate next = null;
@@ -83,7 +83,7 @@ public class GenerateAdhocClientScheduleTasklet implements Tasklet {
final StringBuilder insertSqlBuilder = new StringBuilder(900);
insertSqlBuilder.append("INSERT INTO ").append(adhoc.getTableName()).append("(").append(adhoc.getTableFields())
.append(") ").append(adhoc.getQuery());
if (insertSqlBuilder.length() > 0) {
if (!insertSqlBuilder.isEmpty()) {
final int result = jdbcTemplate.update(insertSqlBuilder.toString());
log.debug("{}: Records affected by generateClientSchedule: {}", ThreadLocalContextUtil.getTenant().getName(),
result);