FINERACT-1724

- [x] eliminate sonar security hotspots
- [x] eliminate sonar bugs
This commit is contained in:
Janos Haber
2022-11-28 15:26:49 +01:00
committed by Arnold Gálovics
parent 5210bf7412
commit 6f7f55a227
4 changed files with 11 additions and 5 deletions
@@ -385,9 +385,9 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final GLJournalEntryMapper rm = new GLJournalEntryMapper(associationParametersData); final GLJournalEntryMapper rm = new GLJournalEntryMapper(associationParametersData);
// Programmatic query, disable sonar issue // Programmatic query, disable sonar issue
final String sql = "select " + rm.schema() + " where journalEntry.id = ?"; // NOSONAR final String sql = "select " + rm.schema() + " where journalEntry.id = ?";
return this.jdbcTemplate.queryForObject(sql, rm, glJournalEntryId); return this.jdbcTemplate.queryForObject(sql, rm, glJournalEntryId); // NOSONAR
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new JournalEntriesNotFoundException(glJournalEntryId, e); throw new JournalEntriesNotFoundException(glJournalEntryId, e);
} }
@@ -110,8 +110,8 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
public ProvisioningEntryData retrieveProvisioningEntryData(Long entryId) { public ProvisioningEntryData retrieveProvisioningEntryData(Long entryId) {
ProvisioningEntryDataMapperWithSumReserved mapper1 = new ProvisioningEntryDataMapperWithSumReserved(); ProvisioningEntryDataMapperWithSumReserved mapper1 = new ProvisioningEntryDataMapperWithSumReserved();
// Programmatic query, disable sonar // Programmatic query, disable sonar
final String sql = "select" + mapper1.getSchema() + " where entry.id = ? group by entry.id, created.username, modified.username"; // NOSONAR final String sql = "select" + mapper1.getSchema() + " where entry.id = ? group by entry.id, created.username, modified.username";
return this.jdbcTemplate.queryForObject(sql, mapper1, entryId); return this.jdbcTemplate.queryForObject(sql, mapper1, entryId);// NOSONAR
} }
private static final class ProvisioningEntryDataMapper implements RowMapper<ProvisioningEntryData> { private static final class ProvisioningEntryDataMapper implements RowMapper<ProvisioningEntryData> {
@@ -65,6 +65,7 @@ import org.apache.fineract.portfolio.account.data.PortfolioAccountData;
import org.apache.fineract.portfolio.account.domain.AccountTransferDetailRepository; import org.apache.fineract.portfolio.account.domain.AccountTransferDetailRepository;
import org.apache.fineract.portfolio.account.domain.AccountTransferDetails; import org.apache.fineract.portfolio.account.domain.AccountTransferDetails;
import org.apache.fineract.portfolio.account.domain.AccountTransferType; import org.apache.fineract.portfolio.account.domain.AccountTransferType;
import org.apache.fineract.portfolio.account.exception.AccountTransferNotFoundException;
import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlatformService; import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlatformService;
import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType; import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
@@ -621,7 +622,8 @@ public class LoanChargeWritePlatformServiceImpl implements LoanChargeWritePlatfo
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, externalId, null, null, fromSavingsAccount, isRegularTransaction, AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, externalId, null, null, fromSavingsAccount, isRegularTransaction,
isExceptionForBalanceCheck); isExceptionForBalanceCheck);
Long transferTransactionId = this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO); Long transferTransactionId = this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
AccountTransferDetails transferDetails = this.accountTransferDetailRepository.findById(transferTransactionId).get(); AccountTransferDetails transferDetails = this.accountTransferDetailRepository.findById(transferTransactionId)
.orElseThrow(() -> new AccountTransferNotFoundException(transferTransactionId));
LoanTransaction loanTransaction = transferDetails.getAccountTransferTransactions().get(0).getToLoanTransaction(); LoanTransaction loanTransaction = transferDetails.getAccountTransferTransactions().get(0).getToLoanTransaction();
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -2113,6 +2113,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
LocalDate recalculateFrom = null; LocalDate recalculateFrom = null;
LoanTransaction writeOffTransaction = loan.findWriteOffTransaction(); LoanTransaction writeOffTransaction = loan.findWriteOffTransaction();
if (writeOffTransaction == null) {
throw new PlatformServiceUnavailableException("error.msg.loan.write.off.transaction.not.found",
"Loan :" + loanId + " write off transaction not found", loanId);
}
businessEventNotifierService.notifyPreBusinessEvent(new LoanUndoWrittenOffBusinessEvent(writeOffTransaction)); businessEventNotifierService.notifyPreBusinessEvent(new LoanUndoWrittenOffBusinessEvent(writeOffTransaction));
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);