From ab80cc0477033f893811aee6ac3832cabb40cba4 Mon Sep 17 00:00:00 2001 From: Arnold Galovics Date: Fri, 8 Apr 2022 17:24:59 +0200 Subject: [PATCH] Lombok refactoring continued --- .../fineract/batch/api/BatchApiResource.java | 21 +----- .../command/CommandStrategyProvider.java | 2 - .../ActivateClientCommandStrategy.java | 8 +-- .../internal/ApplyLoanCommandStrategy.java | 8 +-- .../internal/ApplySavingsCommandStrategy.java | 8 +-- .../internal/ApproveLoanCommandStrategy.java | 8 +-- .../ApproveLoanRescheduleCommandStrategy.java | 8 +-- .../CollectChargesCommandStrategy.java | 8 +-- .../internal/CreateChargeCommandStrategy.java | 8 +-- .../internal/CreateClientCommandStrategy.java | 8 +-- .../internal/DisburseLoanCommandStrategy.java | 8 +-- .../internal/RepayLoanCommandStrategy.java | 8 +-- .../internal/UpdateClientCommandStrategy.java | 8 +-- .../batch/service/BatchApiServiceImpl.java | 19 +----- .../batch/service/ResolutionHelper.java | 10 +-- .../commands/api/AuditsApiResource.java | 14 +--- .../api/MakercheckersApiResource.java | 16 +---- .../fineract/commands/data/AuditData.java | 64 ++----------------- .../commands/data/AuditSearchData.java | 16 ++--- .../commands/data/ProcessingResultLookup.java | 18 ++---- .../provider/CommandHandlerProvider.java | 18 ++---- .../service/AuditReadPlatformServiceImpl.java | 37 ++--------- ...CommandSourceWritePlatformServiceImpl.java | 34 ++++------ .../SynchronousCommandProcessingService.java | 31 ++------- 24 files changed, 79 insertions(+), 309 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/api/BatchApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/batch/api/BatchApiResource.java index 18d47e028e7..f8fbcb43044 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/api/BatchApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/api/BatchApiResource.java @@ -37,13 +37,13 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.serialization.BatchRequestJsonHelper; import org.apache.fineract.batch.service.BatchApiService; import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -70,6 +70,7 @@ + "Batch API uses Json Path to handle dependent parameters. For example, if request '2' is referencing request '1' and in the \"body\" or in \"relativeUrl\" of request '2', there is a dependent parameter (which will look like \"$.parameter_name\"), then Batch API will internally substitute this dependent parameter from the response body of request '1'.\n" + "\n" + "Batch API is able to handle deeply nested dependent requests as well nested parameters. As shown in the example, requests are dependent on each other as, 1<--2<--6, i.e a nested dependency, where request '6' is not directly dependent on request '1' but still it is one of the nested child of request '1'. In the same way Batch API could handle a deeply nested dependent value, such as {..[..{..,$.parameter_name,..}..]}.") +@RequiredArgsConstructor public class BatchApiResource { private final PlatformSecurityContext context; @@ -77,24 +78,6 @@ public class BatchApiResource { private final BatchApiService service; private final BatchRequestJsonHelper batchRequestJsonHelper; - /** - * Constructs a 'BatchApiService' with context, toApiJsonSerializer, service and batchRequestJsonHelper. - * - * @param context - * @param toApiJsonSerializer - * @param service - * @param batchRequestJsonHelper - */ - @Autowired - public BatchApiResource(final PlatformSecurityContext context, final ToApiJsonSerializer toApiJsonSerializer, - final BatchApiService service, final BatchRequestJsonHelper batchRequestJsonHelper) { - - this.context = context; - this.toApiJsonSerializer = toApiJsonSerializer; - this.service = service; - this.batchRequestJsonHelper = batchRequestJsonHelper; - } - /** * Rest assured POST method to get {@link BatchRequest} and returns back the consolidated {@link BatchResponse} * diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/CommandStrategyProvider.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/CommandStrategyProvider.java index 79abc061c86..c8316fe91b4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/CommandStrategyProvider.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/CommandStrategyProvider.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.fineract.batch.command.internal.UnknownCommandStrategy; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -46,7 +45,6 @@ public class CommandStrategyProvider { * * @param applicationContext */ - @Autowired public CommandStrategyProvider(final ApplicationContext applicationContext) { // calls init() function of this class. diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ActivateClientCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ActivateClientCommandStrategy.java index 934641ee8aa..d5601e06ffe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ActivateClientCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ActivateClientCommandStrategy.java @@ -21,13 +21,13 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.client.api.ClientsApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -44,15 +44,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class ActivateClientCommandStrategy implements CommandStrategy { private final ClientsApiResource clientsApiResource; - @Autowired - public ActivateClientCommandStrategy(final ClientsApiResource clientsApiResource) { - this.clientsApiResource = clientsApiResource; - } - @Override public BatchResponse execute(final BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java index 5d5b1b8518e..0a0d45cea04 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java @@ -19,13 +19,13 @@ package org.apache.fineract.batch.command.internal; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.api.LoansApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -42,15 +42,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class ApplyLoanCommandStrategy implements CommandStrategy { private final LoansApiResource loansApiResource; - @Autowired - public ApplyLoanCommandStrategy(final LoansApiResource loansApiResource) { - this.loansApiResource = loansApiResource; - } - @Override public BatchResponse execute(BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java index e7a5df0ea74..32359c81fb1 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java @@ -19,13 +19,13 @@ package org.apache.fineract.batch.command.internal; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.savings.api.SavingsAccountsApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -42,15 +42,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class ApplySavingsCommandStrategy implements CommandStrategy { private final SavingsAccountsApiResource savingsAccountsApiResource; - @Autowired - public ApplySavingsCommandStrategy(final SavingsAccountsApiResource savingsAccountsApiResource) { - this.savingsAccountsApiResource = savingsAccountsApiResource; - } - @Override public BatchResponse execute(BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java index 111e1f72043..26dac2941d6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java @@ -21,13 +21,13 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.api.LoansApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -44,15 +44,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class ApproveLoanCommandStrategy implements CommandStrategy { private final LoansApiResource loansApiResource; - @Autowired - public ApproveLoanCommandStrategy(final LoansApiResource loansApiResource) { - this.loansApiResource = loansApiResource; - } - @Override public BatchResponse execute(final BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanRescheduleCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanRescheduleCommandStrategy.java index 9ed6fd5d292..4220f9c139e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanRescheduleCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanRescheduleCommandStrategy.java @@ -21,25 +21,21 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.rescheduleloan.api.RescheduleLoansApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component +@RequiredArgsConstructor public class ApproveLoanRescheduleCommandStrategy implements CommandStrategy { private final RescheduleLoansApiResource rescheduleLoansApiResource; - @Autowired - public ApproveLoanRescheduleCommandStrategy(final RescheduleLoansApiResource rescheduleLoansApiResource) { - this.rescheduleLoansApiResource = rescheduleLoansApiResource; - } - @Override public BatchResponse execute(BatchRequest request, UriInfo uriInfo) { final BatchResponse response = new BatchResponse(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java index 4fdebcccd16..9d516cb7d30 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java @@ -21,13 +21,13 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.api.LoanChargesApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -44,15 +44,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class CollectChargesCommandStrategy implements CommandStrategy { private final LoanChargesApiResource loanChargesApiResource; - @Autowired - public CollectChargesCommandStrategy(final LoanChargesApiResource loanChargesApiResource) { - this.loanChargesApiResource = loanChargesApiResource; - } - @Override public BatchResponse execute(BatchRequest request, UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java index 479f02d635e..0edc2b9a8d5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java @@ -21,13 +21,13 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.api.LoanChargesApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -44,15 +44,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class CreateChargeCommandStrategy implements CommandStrategy { private final LoanChargesApiResource loanChargesApiResource; - @Autowired - public CreateChargeCommandStrategy(final LoanChargesApiResource loanChargesApiResource) { - this.loanChargesApiResource = loanChargesApiResource; - } - @Override public BatchResponse execute(BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateClientCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateClientCommandStrategy.java index 40025896414..3020a2f20c3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateClientCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateClientCommandStrategy.java @@ -19,13 +19,13 @@ package org.apache.fineract.batch.command.internal; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.client.api.ClientsApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -42,15 +42,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class CreateClientCommandStrategy implements CommandStrategy { private final ClientsApiResource clientsApiResource; - @Autowired - public CreateClientCommandStrategy(final ClientsApiResource clientsApiResource) { - this.clientsApiResource = clientsApiResource; - } - @Override public BatchResponse execute(final BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java index 0ac7d829fc4..e4244be9090 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java @@ -21,13 +21,13 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.api.LoansApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -44,15 +44,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class DisburseLoanCommandStrategy implements CommandStrategy { private final LoansApiResource loansApiResource; - @Autowired - public DisburseLoanCommandStrategy(final LoansApiResource loansApiResource) { - this.loansApiResource = loansApiResource; - } - @Override public BatchResponse execute(final BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/RepayLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/RepayLoanCommandStrategy.java index 65c88010f2f..c91269cf77a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/RepayLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/RepayLoanCommandStrategy.java @@ -21,13 +21,13 @@ import com.google.common.base.Splitter; import java.util.List; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.loanaccount.api.LoanTransactionsApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -42,15 +42,11 @@ * @see BatchResponse */ @Component +@RequiredArgsConstructor public class RepayLoanCommandStrategy implements CommandStrategy { private final LoanTransactionsApiResource loanTransactionsApiResource; - @Autowired - public RepayLoanCommandStrategy(final LoanTransactionsApiResource loanTransactionsApiResource) { - this.loanTransactionsApiResource = loanTransactionsApiResource; - } - @Override public BatchResponse execute(BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/UpdateClientCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/UpdateClientCommandStrategy.java index e09ea4c4b4f..2977ed58b05 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/UpdateClientCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/UpdateClientCommandStrategy.java @@ -19,13 +19,13 @@ package org.apache.fineract.batch.command.internal; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.portfolio.client.api.ClientsApiResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -42,15 +42,11 @@ * @see org.apache.fineract.batch.domain.BatchResponse */ @Component +@RequiredArgsConstructor public class UpdateClientCommandStrategy implements CommandStrategy { private final ClientsApiResource clientsApiResource; - @Autowired - public UpdateClientCommandStrategy(final ClientsApiResource clientsApiResource) { - this.clientsApiResource = clientsApiResource; - } - @Override public BatchResponse execute(BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java index 3bc605ba779..44ef9819173 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java @@ -26,6 +26,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.command.CommandContext; import org.apache.fineract.batch.command.CommandStrategy; import org.apache.fineract.batch.command.CommandStrategyProvider; @@ -35,7 +36,6 @@ import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.batch.service.ResolutionHelper.BatchRequestNode; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.NonTransientDataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionException; @@ -54,28 +54,13 @@ * @see org.apache.fineract.batch.command.CommandStrategyProvider */ @Service +@RequiredArgsConstructor public class BatchApiServiceImpl implements BatchApiService { private final CommandStrategyProvider strategyProvider; private final ResolutionHelper resolutionHelper; private final TransactionTemplate transactionTemplate; - /** - * Constructs a 'BatchApiServiceImpl' with an argument of - * {@link org.apache.fineract.batch.command.CommandStrategyProvider} type. - * - * @param strategyProvider - * @param resolutionHelper - * @param transactionTemplate - */ - @Autowired - public BatchApiServiceImpl(final CommandStrategyProvider strategyProvider, final ResolutionHelper resolutionHelper, - final TransactionTemplate transactionTemplate) { - this.strategyProvider = strategyProvider; - this.resolutionHelper = resolutionHelper; - this.transactionTemplate = transactionTemplate; - } - /** * Returns the response list by getting a proper {@link org.apache.fineract.batch.command.CommandStrategy}. * execute() method of acquired commandStrategy is then provided with the separate Request. diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java b/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java index 08c7586d71e..a14a0e8db40 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java @@ -27,10 +27,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import lombok.RequiredArgsConstructor; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -41,6 +41,7 @@ * @see BatchApiServiceImpl */ @Component +@RequiredArgsConstructor public class ResolutionHelper { /** @@ -76,12 +77,7 @@ public void addChildRequest(final BatchRequestNode batchRequest) { } - private FromJsonHelper fromJsonHelper; - - @Autowired - public ResolutionHelper(final FromJsonHelper fromJsonHelper) { - this.fromJsonHelper = fromJsonHelper; - } + private final FromJsonHelper fromJsonHelper; /** * Returns a map containing requests that are divided in accordance of dependency relations among them. Each diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/api/AuditsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/commands/api/AuditsApiResource.java index a0d7170ba65..e5f80132d20 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/api/AuditsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/api/AuditsApiResource.java @@ -39,6 +39,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.commands.data.AuditData; import org.apache.fineract.commands.data.AuditSearchData; import org.apache.fineract.commands.service.AuditReadPlatformService; @@ -49,7 +50,6 @@ import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.utils.SQLBuilder; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -61,6 +61,7 @@ + "Permissions: To search and look at audit entries a user needs to be attached to a role that has one of the ALL_FUNCTIONS, ALL_FUNCTIONS_READ or READ_AUDIT permissions.\n" + "\n" + "Data Scope: A user can only see audits that are within their data scope. However, 'head office' users can see all audits including those that aren't office/branch related e.g. Loan Product changes.\")") +@RequiredArgsConstructor public class AuditsApiResource { private static final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "actionName", "entityName", "resourceId", @@ -75,17 +76,6 @@ public class AuditsApiResource { private final DefaultToApiJsonSerializer toApiJsonSerializer; private final DefaultToApiJsonSerializer toApiJsonSerializerSearchTemplate; - @Autowired - public AuditsApiResource(final PlatformSecurityContext context, final AuditReadPlatformService auditReadPlatformService, - final ApiRequestParameterHelper apiRequestParameterHelper, final DefaultToApiJsonSerializer toApiJsonSerializer, - final DefaultToApiJsonSerializer toApiJsonSerializerSearchTemplate) { - this.context = context; - this.auditReadPlatformService = auditReadPlatformService; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.toApiJsonSerializer = toApiJsonSerializer; - this.toApiJsonSerializerSearchTemplate = toApiJsonSerializerSearchTemplate; - } - @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java index 4d310482d34..1f302846afe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java @@ -41,6 +41,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.apache.fineract.commands.data.AuditData; import org.apache.fineract.commands.data.AuditSearchData; @@ -52,7 +53,6 @@ import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.security.utils.SQLBuilder; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -60,6 +60,7 @@ @Component @Scope("singleton") @Tag(name = "Maker Checker (or 4-eye) functionality") +@RequiredArgsConstructor public class MakercheckersApiResource { private static final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "actionName", "entityName", "resourceId", @@ -72,19 +73,6 @@ public class MakercheckersApiResource { private final ApiRequestParameterHelper apiRequestParameterHelper; private final PortfolioCommandSourceWritePlatformService writePlatformService; - @Autowired - public MakercheckersApiResource(final AuditReadPlatformService readPlatformService, - final DefaultToApiJsonSerializer toApiJsonSerializerAudit, - final DefaultToApiJsonSerializer toApiJsonSerializerSearchTemplate, - final ApiRequestParameterHelper apiRequestParameterHelper, - final PortfolioCommandSourceWritePlatformService writePlatformService) { - this.readPlatformService = readPlatformService; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.toApiJsonSerializerAudit = toApiJsonSerializerAudit; - this.toApiJsonSerializerSearchTemplate = toApiJsonSerializerSearchTemplate; - this.writePlatformService = writePlatformService; - } - @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditData.java b/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditData.java index 676405c30a0..0f6b2dfb206 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditData.java @@ -19,88 +19,36 @@ package org.apache.fineract.commands.data; import java.time.ZonedDateTime; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; /** * Immutable data object representing client data. */ +@AllArgsConstructor +@Getter public final class AuditData { - @SuppressWarnings("unused") private final Long id; - @SuppressWarnings("unused") private final String actionName; private final String entityName; - @SuppressWarnings("unused") private final Long resourceId; - @SuppressWarnings("unused") private final Long subresourceId; - @SuppressWarnings("unused") private final String maker; - @SuppressWarnings("unused") private final ZonedDateTime madeOnDate; - @SuppressWarnings("unused") private final String checker; - @SuppressWarnings("unused") private final ZonedDateTime checkedOnDate; - @SuppressWarnings("unused") private final String processingResult; + @Setter private String commandAsJson; - @SuppressWarnings("unused") private final String officeName; - @SuppressWarnings("unused") private final String groupLevelName; - @SuppressWarnings("unused") private final String groupName; - @SuppressWarnings("unused") private final String clientName; - @SuppressWarnings("unused") private final String loanAccountNo; - @SuppressWarnings("unused") private final String savingsAccountNo; - @SuppressWarnings("unused") private final Long clientId; - @SuppressWarnings("unused") private final Long loanId; - @SuppressWarnings("unused") private final String url; - - public AuditData(final Long id, final String actionName, final String entityName, final Long resourceId, final Long subresourceId, - final String maker, final ZonedDateTime madeOnDate, final String checker, final ZonedDateTime checkedOnDate, - final String processingResult, final String commandAsJson, final String officeName, final String groupLevelName, - final String groupName, final String clientName, final String loanAccountNo, final String savingsAccountNo, final Long clientId, - final Long loanId, final String url) { - - this.id = id; - this.actionName = actionName; - this.entityName = entityName; - this.resourceId = resourceId; - this.subresourceId = subresourceId; - this.maker = maker; - this.madeOnDate = madeOnDate; - this.checker = checker; - this.checkedOnDate = checkedOnDate; - this.commandAsJson = commandAsJson; - this.processingResult = processingResult; - this.officeName = officeName; - this.groupLevelName = groupLevelName; - this.groupName = groupName; - this.clientName = clientName; - this.loanAccountNo = loanAccountNo; - this.savingsAccountNo = savingsAccountNo; - this.clientId = clientId; - this.loanId = loanId; - this.url = url; - } - - public void setCommandAsJson(final String commandAsJson) { - this.commandAsJson = commandAsJson; - } - - public String getCommandAsJson() { - return this.commandAsJson; - } - - public String getEntityName() { - return this.entityName; - } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditSearchData.java b/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditSearchData.java index d0ecd1a75eb..35fe021003a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditSearchData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/data/AuditSearchData.java @@ -20,27 +20,19 @@ import java.util.Collection; import java.util.List; +import lombok.Getter; +import lombok.RequiredArgsConstructor; import org.apache.fineract.useradministration.data.AppUserData; /** * Immutable data object representing audit search results. */ +@RequiredArgsConstructor +@Getter public final class AuditSearchData { - @SuppressWarnings("unused") private final Collection appUsers; - @SuppressWarnings("unused") private final List actionNames; - @SuppressWarnings("unused") private final List entityNames; - @SuppressWarnings("unused") private final Collection processingResults; - - public AuditSearchData(final Collection appUsers, final List apiOperations, final List resources, - final Collection processingResults) { - this.appUsers = appUsers; - this.actionNames = apiOperations; - this.entityNames = resources; - this.processingResults = processingResults; - } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/data/ProcessingResultLookup.java b/fineract-provider/src/main/java/org/apache/fineract/commands/data/ProcessingResultLookup.java index e8e8db2a2ea..bca4ac5b1e5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/data/ProcessingResultLookup.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/data/ProcessingResultLookup.java @@ -18,25 +18,17 @@ */ package org.apache.fineract.commands.data; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + /** * Immutable data object for application user data. */ +@RequiredArgsConstructor +@Getter public class ProcessingResultLookup { private final Long id; private final String processingResult; - public ProcessingResultLookup(final Long id, final String processingResult) { - this.id = id; - this.processingResult = processingResult; - } - - public Long getId() { - return this.id; - } - - public String getProcessingResult() { - return this.processingResult; - } - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java b/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java index 67888063e88..31a54fde021 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java @@ -20,17 +20,16 @@ import com.google.common.base.Preconditions; import java.util.HashMap; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.fineract.commands.annotation.CommandType; import org.apache.fineract.commands.exception.UnsupportedCommandException; import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; /** @@ -46,18 +45,13 @@ * @see CommandType */ @Component -@Scope("singleton") +@NoArgsConstructor +@Slf4j public class CommandHandlerProvider implements ApplicationContextAware { - private static final Logger LOGGER = LoggerFactory.getLogger(CommandHandlerProvider.class); - private ApplicationContext applicationContext; private HashMap registeredHandlers; - CommandHandlerProvider() { - - } - /** * Returns a handler for the given entity and action.
*
@@ -87,12 +81,12 @@ private void initializeHandlerRegistry() { final String[] commandHandlerBeans = this.applicationContext.getBeanNamesForAnnotation(CommandType.class); if (ArrayUtils.isNotEmpty(commandHandlerBeans)) { for (final String commandHandlerName : commandHandlerBeans) { - LOGGER.info("Register command handler '{}' ...", commandHandlerName); + log.info("Register command handler '{}' ...", commandHandlerName); final CommandType commandType = this.applicationContext.findAnnotationOnBean(commandHandlerName, CommandType.class); try { this.registeredHandlers.put(commandType.entity() + "|" + commandType.action(), commandHandlerName); } catch (final Throwable th) { - LOGGER.error("Unable to register command handler '{}'!", commandHandlerName, th); + log.error("Unable to register command handler '{}'!", commandHandlerName, th); } } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java index 1d738cd9646..d2f98b74125 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java @@ -31,6 +31,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.fineract.commands.data.AuditData; import org.apache.fineract.commands.data.AuditSearchData; @@ -64,17 +66,15 @@ import org.apache.fineract.useradministration.data.AppUserData; import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.service.AppUserReadPlatformService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; @Service +@RequiredArgsConstructor +@Slf4j public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { - private static final Logger LOG = LoggerFactory.getLogger(AuditReadPlatformServiceImpl.class); private static final Set supportedOrderByValues = new HashSet<>(Arrays.asList("id", "actionName", "entityName", "resourceId", "subresourceId", "madeOnDate", "checkedOnDate", "officeName", "groupName", "clientName", "loanAccountNo", "savingsAccountNo", "clientId", "loanId", "maker", "checker", "processingResult")); @@ -94,31 +94,6 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { private final DepositProductReadPlatformService depositProductReadPlatformService; private final ColumnValidator columnValidator; - @Autowired - public AuditReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate, - final FromJsonHelper fromApiJsonHelper, final AppUserReadPlatformService appUserReadPlatformService, - final OfficeReadPlatformService officeReadPlatformService, final ClientReadPlatformService clientReadPlatformService, - final LoanProductReadPlatformService loanProductReadPlatformService, final StaffReadPlatformService staffReadPlatformService, - final PaginationParametersDataValidator paginationParametersDataValidator, - final SavingsProductReadPlatformService savingsProductReadPlatformService, - final DepositProductReadPlatformService depositProductReadPlatformService, final ColumnValidator columnValidator, - DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper) { - this.context = context; - this.jdbcTemplate = jdbcTemplate; - this.fromApiJsonHelper = fromApiJsonHelper; - this.appUserReadPlatformService = appUserReadPlatformService; - this.officeReadPlatformService = officeReadPlatformService; - this.clientReadPlatformService = clientReadPlatformService; - this.loanProductReadPlatformService = loanProductReadPlatformService; - this.staffReadPlatformService = staffReadPlatformService; - this.paginationParametersDataValidator = paginationParametersDataValidator; - this.savingsProductReadPlatformService = savingsProductReadPlatformService; - this.depositProductReadPlatformService = depositProductReadPlatformService; - this.columnValidator = columnValidator; - this.paginationHelper = paginationHelper; - this.sqlGenerator = sqlGenerator; - } - private static final class AuditMapper implements RowMapper { public String schema(final boolean includeJson, final String hierarchy) { @@ -218,7 +193,7 @@ public Page retrievePaginatedAuditEntries(final SQLBuilder extraCrite this.columnValidator.validateSqlInjection(sqlBuilder.toString(), parameters.limitSql()); } - LOG.info("sql: {}", sqlBuilder); + log.info("sql: {}", sqlBuilder); return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlBuilder.toString(), extraCriteria.getArguments(), rm); } @@ -257,7 +232,7 @@ private Collection retrieveEntries(final String useType, final SQLBui } sql += extraCriteria.getSQLTemplate(); sql += groupAndOrderBySQL; - LOG.info("sql: {}", sql); + log.info("sql: {}", sql); return this.jdbcTemplate.query(sql, rm, extraCriteria.getArguments()); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java index 22c3df4a9d1..d6d3cd0a23e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java @@ -22,6 +22,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.security.SecureRandom; import java.time.ZonedDateTime; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.fineract.commands.domain.CommandSource; import org.apache.fineract.commands.domain.CommandSourceRepository; import org.apache.fineract.commands.domain.CommandWrapper; @@ -36,35 +38,23 @@ import org.apache.fineract.infrastructure.jobs.service.SchedulerJobRunnerReadService; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.useradministration.domain.AppUser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.CannotAcquireLockException; import org.springframework.orm.ObjectOptimisticLockingFailureException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service +@RequiredArgsConstructor +@Slf4j public class PortfolioCommandSourceWritePlatformServiceImpl implements PortfolioCommandSourceWritePlatformService { + private static final SecureRandom RANDOM = new SecureRandom(); + private final PlatformSecurityContext context; private final CommandSourceRepository commandSourceRepository; private final FromJsonHelper fromApiJsonHelper; private final CommandProcessingService processAndLogCommandService; private final SchedulerJobRunnerReadService schedulerJobRunnerReadService; - private static final Logger LOG = LoggerFactory.getLogger(PortfolioCommandSourceWritePlatformServiceImpl.class); - private static final SecureRandom random = new SecureRandom(); - - @Autowired - public PortfolioCommandSourceWritePlatformServiceImpl(final PlatformSecurityContext context, - final CommandSourceRepository commandSourceRepository, final FromJsonHelper fromApiJsonHelper, - final CommandProcessingService processAndLogCommandService, final SchedulerJobRunnerReadService schedulerJobRunnerReadService) { - this.context = context; - this.commandSourceRepository = commandSourceRepository; - this.fromApiJsonHelper = fromApiJsonHelper; - this.processAndLogCommandService = processAndLogCommandService; - this.schedulerJobRunnerReadService = schedulerJobRunnerReadService; - } @Override @SuppressWarnings("AvoidHidingCauseException") @@ -90,9 +80,9 @@ public CommandProcessingResult logCommandSource(final CommandWrapper wrapper) { final String json = wrapper.getJson(); CommandProcessingResult result = null; JsonCommand command = null; - Integer numberOfRetries = 0; - Integer maxNumberOfRetries = ThreadLocalContextUtil.getTenant().getConnection().getMaxRetriesOnDeadlock(); - Integer maxIntervalBetweenRetries = ThreadLocalContextUtil.getTenant().getConnection().getMaxIntervalBetweenRetries(); + int numberOfRetries = 0; + int maxNumberOfRetries = ThreadLocalContextUtil.getTenant().getConnection().getMaxRetriesOnDeadlock(); + int maxIntervalBetweenRetries = ThreadLocalContextUtil.getTenant().getConnection().getMaxIntervalBetweenRetries(); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json); command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(), wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getSavingsId(), @@ -103,12 +93,12 @@ public CommandProcessingResult logCommandSource(final CommandWrapper wrapper) { result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker); numberOfRetries = maxNumberOfRetries + 1; } catch (CannotAcquireLockException | ObjectOptimisticLockingFailureException exception) { - LOG.info("The following command {} has been retried {} time(s)", command.json(), numberOfRetries); + log.info("The following command {} has been retried {} time(s)", command.json(), numberOfRetries); /*** * Fail if the transaction has been retired for maxNumberOfRetries **/ if (numberOfRetries >= maxNumberOfRetries) { - LOG.warn("The following command {} has been retried for the max allowed attempts of {} and will be rolled back", + log.warn("The following command {} has been retried for the max allowed attempts of {} and will be rolled back", command.json(), numberOfRetries); throw exception; } @@ -116,7 +106,7 @@ public CommandProcessingResult logCommandSource(final CommandWrapper wrapper) { * Else sleep for a random time (between 1 to 10 seconds) and continue **/ try { - int randomNum = random.nextInt(maxIntervalBetweenRetries + 1); + int randomNum = RANDOM.nextInt(maxIntervalBetweenRetries + 1); Thread.sleep(1000 + (randomNum * 1000)); numberOfRetries = numberOfRetries + 1; } catch (InterruptedException e) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java index 90db86a8242..e577653b8de 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/SynchronousCommandProcessingService.java @@ -25,6 +25,8 @@ import java.time.ZonedDateTime; import java.util.HashMap; import java.util.Map; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.fineract.batch.exception.ErrorHandler; import org.apache.fineract.batch.exception.ErrorInfo; import org.apache.fineract.commands.domain.CommandSource; @@ -45,42 +47,23 @@ import org.apache.fineract.infrastructure.hooks.event.HookEventSource; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.useradministration.domain.AppUser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service +@Slf4j +@RequiredArgsConstructor public class SynchronousCommandProcessingService implements CommandProcessingService { - private static final Logger LOG = LoggerFactory.getLogger(SynchronousCommandProcessingService.class); - private PlatformSecurityContext context; + private final PlatformSecurityContext context; private final ApplicationContext applicationContext; private final ToApiJsonSerializer> toApiJsonSerializer; private final ToApiJsonSerializer toApiResultJsonSerializer; - private CommandSourceRepository commandSourceRepository; + private final CommandSourceRepository commandSourceRepository; private final ConfigurationDomainService configurationDomainService; private final CommandHandlerProvider commandHandlerProvider; - @Autowired - public SynchronousCommandProcessingService(final PlatformSecurityContext context, final ApplicationContext applicationContext, - final ToApiJsonSerializer> toApiJsonSerializer, - final ToApiJsonSerializer toApiResultJsonSerializer, - final CommandSourceRepository commandSourceRepository, final ConfigurationDomainService configurationDomainService, - final CommandHandlerProvider commandHandlerProvider) { - this.context = context; - this.context = context; - this.applicationContext = applicationContext; - this.toApiJsonSerializer = toApiJsonSerializer; - this.toApiResultJsonSerializer = toApiResultJsonSerializer; - this.commandSourceRepository = commandSourceRepository; - this.commandSourceRepository = commandSourceRepository; - this.configurationDomainService = configurationDomainService; - this.commandHandlerProvider = commandHandlerProvider; - } - @Transactional @Override public CommandProcessingResult processAndLogCommand(final CommandWrapper wrapper, final JsonCommand command, @@ -286,7 +269,7 @@ private void publishEvent(final String entityName, final String actionName, Json applicationContext.publishEvent(applicationEvent); } } catch (Exception e) { - LOG.error("Error", e); + log.error("Error", e); } }