FINERACT-942 Added and Enforced AvoidHidingCauseException Checkstyle

This commit is contained in:
thesmallstar
2020-06-29 23:16:53 +02:00
committed by Michael Vorburger ⛑️
parent 649eb4f843
commit 022f214ad5
168 changed files with 602 additions and 192 deletions
@@ -50,6 +50,7 @@
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="com.github.sevntu.checkstyle.checks.coding.AvoidHidingCauseExceptionCheck" />
<module name="SuppressWarningsHolder" />
<module name="RegexpSinglelineJava">
<property name="format" value="System\.(out)|(err)\.print(ln)?\("/>
@@ -189,7 +190,7 @@
<module name="IllegalCatch"/>
<module name="com.github.sevntu.checkstyle.checks.coding.AvoidHidingCauseExceptionCheck" />
@@ -61,7 +61,7 @@ public class AccrualAccountingWritePlatformServiceImpl implements AccrualAccount
.resource(PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME);
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(PERIODIC_ACCRUAL_ACCOUNTING_EXECUTION_ERROR_CODE,
e.getMessage());
throw new PlatformApiDataValidationException(dataValidationErrors);
throw new PlatformApiDataValidationException(dataValidationErrors, e);
}
return CommandProcessingResult.empty();
}
@@ -19,6 +19,7 @@
package org.apache.fineract.accounting.closure.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when GL account closure resources are not found.
@@ -28,4 +29,8 @@ public class GLClosureNotFoundException extends AbstractPlatformResourceNotFound
public GLClosureNotFoundException(final Long id) {
super("error.msg.glclosure.id.invalid", "Accounting Closure with identifier " + id + " does not exist", id);
}
public GLClosureNotFoundException(final Long id, EmptyResultDataAccessException e) {
super("error.msg.glclosure.id.invalid", "Accounting Closure with identifier " + id + " does not exist", id, e);
}
}
@@ -106,7 +106,7 @@ public class GLClosureReadPlatformServiceImpl implements GLClosureReadPlatformSe
return glAccountData;
} catch (final EmptyResultDataAccessException e) {
throw new GLClosureNotFoundException(glClosureId);
throw new GLClosureNotFoundException(glClosureId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.accounting.financialactivityaccount.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when product to GL account mapping are not found.
@@ -29,6 +30,10 @@ public class FinancialActivityAccountNotFoundException extends AbstractPlatformR
super("error.msg.financialActivityAccount.not.found", "Financial Activity account with Id " + id + " does not exist", id);
}
public FinancialActivityAccountNotFoundException(final Long id, EmptyResultDataAccessException e) {
super("error.msg.financialActivityAccount.not.found", "Financial Activity account with Id " + id + " does not exist", id, e);
}
public FinancialActivityAccountNotFoundException(final Integer financialActivityType) {
super("error.msg.financialActivityAccount.not.found",
"Financial Activity account with for the financial Activity with Id " + financialActivityType + " does not exist",
@@ -67,7 +67,7 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), this.financialActivityAccountMapper,
new Object[] { financialActivityAccountId });
} catch (final EmptyResultDataAccessException e) {
throw new FinancialActivityAccountNotFoundException(financialActivityAccountId);
throw new FinancialActivityAccountNotFoundException(financialActivityAccountId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.accounting.glaccount.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when GL account resources are not found.
@@ -28,4 +29,8 @@ public class GLAccountNotFoundException extends AbstractPlatformResourceNotFound
public GLAccountNotFoundException(final Long id) {
super("error.msg.glaccount.id.invalid", "General Ledger account with identifier " + id + " does not exist ", id);
}
public GLAccountNotFoundException(final Long id, EmptyResultDataAccessException e) {
super("error.msg.glaccount.id.invalid", "General Ledger account with identifier " + id + " does not exist ", id, e);
}
}
@@ -224,7 +224,7 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
return glAccountData;
} catch (final EmptyResultDataAccessException e) {
throw new GLAccountNotFoundException(glAccountId);
throw new GLAccountNotFoundException(glAccountId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.accounting.journalentry.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when journal entry resources are not found.
@@ -34,4 +35,8 @@ public class JournalEntriesNotFoundException extends AbstractPlatformResourceNot
public JournalEntriesNotFoundException(final Long entryId) {
super("error.msg.journalEntries.id.invalid", "Journal Entry with entry Id " + entryId + " does not exist ", entryId);
}
public JournalEntriesNotFoundException(final Long entryId, EmptyResultDataAccessException e) {
super("error.msg.journalEntries.id.invalid", "Journal Entry with entry Id " + entryId + " does not exist ", entryId, e);
}
}
@@ -391,7 +391,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
return glJournalEntryData;
} catch (final EmptyResultDataAccessException e) {
throw new JournalEntriesNotFoundException(glJournalEntryId);
throw new JournalEntriesNotFoundException(glJournalEntryId, e);
}
}
@@ -534,7 +534,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
Object[] data = { transactionId, entityId, entityType };
return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sql, data, rm);
} catch (final EmptyResultDataAccessException e) {
throw new JournalEntriesNotFoundException(entityId);
throw new JournalEntriesNotFoundException(entityId, e);
}
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.accounting.rule.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when Accounting rule resources are not found.
@@ -28,4 +29,8 @@ public class AccountingRuleNotFoundException extends AbstractPlatformResourceNot
public AccountingRuleNotFoundException(final Long id) {
super("error.msg.accounting.rule.id.invalid", "Accounting Rule with identifier " + id + " does not exist", id);
}
public AccountingRuleNotFoundException(final Long id, EmptyResultDataAccessException e) {
super("error.msg.accounting.rule.id.invalid", "Accounting Rule with identifier " + id + " does not exist", id, e);
}
}
@@ -184,7 +184,7 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
}
return accountingRuleData;
} catch (final EmptyResultDataAccessException e) {
throw new AccountingRuleNotFoundException(accountingRuleId);
throw new AccountingRuleNotFoundException(accountingRuleId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.adhocquery.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when AdHoc resources are not found.
@@ -28,4 +29,8 @@ public class AdHocNotFoundException extends AbstractPlatformResourceNotFoundExce
public AdHocNotFoundException(final Long id) {
super("error.msg.adhocquery.adhoc.id.invalid", "Adhoc Record with identifier " + id + " does not exist", id);
}
public AdHocNotFoundException(final Long id, EmptyResultDataAccessException e) {
super("error.msg.adhocquery.adhoc.id.invalid", "Adhoc Record with identifier " + id + " does not exist", id, e);
}
}
@@ -66,7 +66,7 @@ public class AdHocReadPlatformServiceImpl implements AdHocReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, this.adHocRowMapper, new Object[] { id });
} catch (final EmptyResultDataAccessException e) {
throw new AdHocNotFoundException(id);
throw new AdHocNotFoundException(id, e);
}
}
@@ -139,7 +139,7 @@ public class AdHocWritePlatformServiceJpaRepositoryImpl implements AdHocWritePla
return new CommandProcessingResultBuilder().withEntityId(adHocId).build();
} catch (final DataIntegrityViolationException e) {
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
"Unknown data integrity issue with resource: " + e.getMostSpecificCause(), e);
}
}
@@ -160,7 +160,7 @@ public class AdHocWritePlatformServiceJpaRepositoryImpl implements AdHocWritePla
} catch (final DataIntegrityViolationException e) {
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
"Unknown data integrity issue with resource: " + e.getMostSpecificCause(), e);
}
}
@@ -181,7 +181,7 @@ public class AdHocWritePlatformServiceJpaRepositoryImpl implements AdHocWritePla
} catch (final DataIntegrityViolationException e) {
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
"Unknown data integrity issue with resource: " + e.getMostSpecificCause(), e);
}
}
}
@@ -64,6 +64,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
}
@Override
@SuppressWarnings("AvoidHidingCauseException")
public CommandProcessingResult logCommandSource(final CommandWrapper wrapper) {
boolean isApprovedByChecker = false;
@@ -20,6 +20,7 @@ package org.apache.fineract.infrastructure.accountnumberformat.exception;
import org.apache.fineract.infrastructure.accountnumberformat.service.AccountNumberFormatConstants;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when client resources are not found.
@@ -31,4 +32,9 @@ public class AccountNumberFormatNotFoundException extends AbstractPlatformResour
"AccountNumber format with identifier " + id + " does not exist", id);
}
public AccountNumberFormatNotFoundException(final Long id, EmptyResultDataAccessException e) {
super(AccountNumberFormatConstants.EXCEPTION_ACCOUNT_NUMBER_FORMAT_NOT_FOUND,
"AccountNumber format with identifier " + id + " does not exist", id, e);
}
}
@@ -101,7 +101,7 @@ public class AccountNumberFormatReadPlatformServiceImpl implements AccountNumber
new Object[] { id });
return accountNumberFormatData;
} catch (final EmptyResultDataAccessException e) {
throw new AccountNumberFormatNotFoundException(id);
throw new AccountNumberFormatNotFoundException(id, e);
}
}
@@ -85,7 +85,7 @@ public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
row.createCell(colIndex).setCellValue(dateWithoutTime);
row.getCell(colIndex).setCellStyle(dateCellStyle);
} catch (ParseException pe) {
throw new IllegalArgumentException("ParseException");
throw new IllegalArgumentException(pe);
}
}
@@ -176,7 +176,7 @@ public class BulkImportWorkbookServiceImpl implements BulkImportWorkbookService
} catch (IOException e) {
LOG.error("Problem occurred in importWorkbook function", e);
throw new GeneralPlatformDomainRuleException("error.msg.io.exception",
"IO exception occured with " + fileDetail.getFileName() + " " + e.getMessage());
"IO exception occured with " + fileDetail.getFileName() + " " + e.getMessage(), e);
}
}
@@ -26,4 +26,9 @@ public class EmailBusinessRuleNotFound extends AbstractPlatformResourceNotFoundE
super("error.msg.email.business.rule.not.found", "Email business rule with identifier `" + resourceId + "` does not exist",
resourceId);
}
public EmailBusinessRuleNotFound(final Long resourceId, IndexOutOfBoundsException e) {
super("error.msg.email.business.rule.not.found", "Email business rule with identifier `" + resourceId + "` does not exist",
resourceId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.campaigns.email.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class EmailCampaignNotFound extends AbstractPlatformResourceNotFoundException {
@@ -26,4 +27,9 @@ public class EmailCampaignNotFound extends AbstractPlatformResourceNotFoundExcep
super("error.msg.email.campaign.identifier.not.found", "EMAIL_CAMPAIGN with identifier `" + resourceId + "` does not exist",
resourceId);
}
public EmailCampaignNotFound(final Long resourceId, EmptyResultDataAccessException e) {
super("error.msg.email.campaign.identifier.not.found", "EMAIL_CAMPAIGN with identifier `" + resourceId + "` does not exist",
resourceId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.campaigns.email.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when a code is not found.
@@ -28,4 +29,9 @@ public class EmailConfigurationNotFoundException extends AbstractPlatformResourc
public EmailConfigurationNotFoundException(final String name) {
super("error.msg.email.configuration.name.not.found", "Email configuration with name " + name + " does not exist", name);
}
public EmailConfigurationNotFoundException(String name, EmptyResultDataAccessException e) {
super("error.msg.email.configuration.name.not.found", "Email configuration with name " + name + " does not exist", name, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.campaigns.email.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when a code is not found.
@@ -28,4 +29,8 @@ public class EmailNotFoundException extends AbstractPlatformResourceNotFoundExce
public EmailNotFoundException(final Long resourceId) {
super("error.msg.email.identifier.not.found", "Email with identifier `" + resourceId + "` does not exist", resourceId);
}
public EmailNotFoundException(Long resourceId, EmptyResultDataAccessException e) {
super("error.msg.email.identifier.not.found", "Email with identifier `" + resourceId + "` does not exist", resourceId, e);
}
}
@@ -246,7 +246,7 @@ public class EmailCampaignReadPlatformServiceImpl implements EmailCampaignReadPl
EmailBusinessRulesData emailBusinessRulesData = retrieveOne.get(0);
return emailBusinessRulesData;
} catch (final IndexOutOfBoundsException e) {
throw new EmailBusinessRuleNotFound(resourceId);
throw new EmailBusinessRuleNotFound(resourceId, e);
}
}
@@ -258,7 +258,7 @@ public class EmailCampaignReadPlatformServiceImpl implements EmailCampaignReadPl
final String sql = "select " + this.emailCampaignMapper.schema + " where ec.id = ? and ec.is_visible = ?";
return this.jdbcTemplate.queryForObject(sql, this.emailCampaignMapper, resourceId, isVisible);
} catch (final EmptyResultDataAccessException e) {
throw new EmailCampaignNotFound(resourceId);
throw new EmailCampaignNotFound(resourceId, e);
}
}
@@ -91,7 +91,7 @@ public class EmailConfigurationReadPlatformServiceImpl implements EmailConfigura
catch (final EmptyResultDataAccessException e) {
throw new EmailConfigurationNotFoundException(name);
throw new EmailConfigurationNotFoundException(name, e);
}
}
@@ -123,7 +123,7 @@ public class EmailReadPlatformServiceImpl implements EmailReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, this.emailRowMapper, resourceId);
} catch (final EmptyResultDataAccessException e) {
throw new EmailNotFoundException(resourceId);
throw new EmailNotFoundException(resourceId, e);
}
}
@@ -27,4 +27,9 @@ public class ConnectionFailureException extends AbstractPlatformServiceUnavailab
"Unable to connect to the server with connection name - " + connectionName, connectionName);
}
public ConnectionFailureException(String connectionName, Exception e) {
super("error.msg.unable.to.connect.to.intermediate.server",
"Unable to connect to the server with connection name - " + connectionName, connectionName, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.campaigns.sms.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class SmsCampaignNotFound extends AbstractPlatformResourceNotFoundException {
@@ -26,4 +27,9 @@ public class SmsCampaignNotFound extends AbstractPlatformResourceNotFoundExcepti
super("error.msg.sms.campaign.identifier.not.found", "Sms Campaign with identifier `" + resourceId + "` does not exist",
resourceId);
}
public SmsCampaignNotFound(final Long resourceId, EmptyResultDataAccessException e) {
super("error.msg.sms.campaign.identifier.not.found", "Sms Campaign with identifier `" + resourceId + "` does not exist", resourceId,
e);
}
}
@@ -79,7 +79,7 @@ public class SmsCampaignReadPlatformServiceImpl implements SmsCampaignReadPlatfo
final String sql = "select " + this.smsCampaignMapper.schema + " where sc.id = ? and sc.is_visible = ?";
return this.jdbcTemplate.queryForObject(sql, this.smsCampaignMapper, new Object[] { campaignId, isVisible });
} catch (final EmptyResultDataAccessException e) {
throw new SmsCampaignNotFound(campaignId);
throw new SmsCampaignNotFound(campaignId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.codes.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when a code is not found.
@@ -32,4 +33,13 @@ public class CodeNotFoundException extends AbstractPlatformResourceNotFoundExcep
public CodeNotFoundException(final Long codeId) {
super("error.msg.code.identifier.not.found", "Code with identifier `" + codeId + "` does not exist", codeId);
}
public CodeNotFoundException(final String name, EmptyResultDataAccessException e) {
super("error.msg.code.not.found", "Code with name `" + name + "` does not exist", name, e);
}
public CodeNotFoundException(final Long codeId, EmptyResultDataAccessException e) {
super("error.msg.code.identifier.not.found", "Code with identifier `" + codeId + "` does not exist", codeId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.codes.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when client resources are not found.
@@ -38,4 +39,8 @@ public class CodeValueNotFoundException extends AbstractPlatformResourceNotFound
super("error.msg.codevalue.codename.id.combination.invalid",
"Code value with label " + label + " does not exist for a code with name " + codeName, label, codeName);
}
public CodeValueNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.codevalue.id.invalid", "Code value with identifier " + id + " does not exist", id, e);
}
}
@@ -82,7 +82,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeId });
} catch (final EmptyResultDataAccessException e) {
throw new CodeNotFoundException(codeId);
throw new CodeNotFoundException(codeId, e);
}
}
@@ -96,7 +96,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeName });
} catch (final EmptyResultDataAccessException e) {
throw new CodeNotFoundException(codeName);
throw new CodeNotFoundException(codeName, e);
}
}
}
@@ -99,7 +99,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeValueId });
} catch (final EmptyResultDataAccessException e) {
throw new CodeValueNotFoundException(codeValueId);
throw new CodeValueNotFoundException(codeValueId, e);
}
}
@@ -161,10 +161,10 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
LOG.error("Error occured.", dve);
final Throwable realCause = dve.getMostSpecificCause();
if (realCause.getMessage().contains("code_value")) {
throw new PlatformDataIntegrityException("error.msg.codeValue.in.use", "This code value is in use", codeValueId);
throw new PlatformDataIntegrityException("error.msg.codeValue.in.use", "This code value is in use", codeValueId, dve);
}
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + dve.getMostSpecificCause().getMessage());
"Unknown data integrity issue with resource: " + dve.getMostSpecificCause().getMessage(), dve);
}
}
}
@@ -129,7 +129,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
this.codeRepository.flush();
} catch (final DataIntegrityViolationException e) {
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
"Unknown data integrity issue with resource: " + e.getMostSpecificCause(), e);
}
return new CommandProcessingResultBuilder().withEntityId(codeId).build();
}
@@ -0,0 +1,45 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.exception;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractPlatformException {
protected static Throwable findThrowableCause(Object[] defaultUserMessageArgs) {
for (Object defaultUserMessageArg : defaultUserMessageArgs) {
if (defaultUserMessageArg instanceof Throwable) {
return (Throwable) defaultUserMessageArg;
}
}
return null;
}
protected static Object[] filterThrowableCause(Object[] defaultUserMessageArgs) {
List<Object> filteredDefaultUserMessageArgs = new ArrayList<>(defaultUserMessageArgs.length);
for (Object defaultUserMessageArg : defaultUserMessageArgs) {
if (!(defaultUserMessageArg instanceof Throwable)) {
filteredDefaultUserMessageArgs.add(defaultUserMessageArg);
}
}
return filteredDefaultUserMessageArgs.toArray();
}
}
@@ -18,9 +18,6 @@
*/
package org.apache.fineract.infrastructure.core.exception;
import java.util.ArrayList;
import java.util.List;
/**
* A {@link RuntimeException} thrown when resources that are queried for are not found.
*/
@@ -32,29 +29,10 @@ public abstract class AbstractPlatformResourceNotFoundException extends RuntimeE
protected AbstractPlatformResourceNotFoundException(final String globalisationMessageCode, final String defaultUserMessage,
final Object... defaultUserMessageArgs) {
super(findThrowableCause(defaultUserMessageArgs));
super(AbstractPlatformException.findThrowableCause(defaultUserMessageArgs));
this.globalisationMessageCode = globalisationMessageCode;
this.defaultUserMessage = defaultUserMessage;
this.defaultUserMessageArgs = filterThrowableCause(defaultUserMessageArgs);
}
private static Throwable findThrowableCause(Object[] defaultUserMessageArgs) {
for (Object defaultUserMessageArg : defaultUserMessageArgs) {
if (defaultUserMessageArg instanceof Throwable) {
return (Throwable) defaultUserMessageArg;
}
}
return null;
}
private static Object[] filterThrowableCause(Object[] defaultUserMessageArgs) {
List<Object> filteredDefaultUserMessageArgs = new ArrayList<>(defaultUserMessageArgs.length);
for (Object defaultUserMessageArg : defaultUserMessageArgs) {
if (!(defaultUserMessageArg instanceof Throwable)) {
filteredDefaultUserMessageArgs.add(defaultUserMessageArg);
}
}
return filteredDefaultUserMessageArgs.toArray();
this.defaultUserMessageArgs = AbstractPlatformException.filterThrowableCause(defaultUserMessageArgs);
}
public String getGlobalisationMessageCode() {
@@ -43,6 +43,21 @@ public class PlatformApiDataValidationException extends RuntimeException {
this.errors = errors;
}
public PlatformApiDataValidationException(final String globalisationMessageCode, final String defaultUserMessage,
final List<ApiParameterError> errors, Throwable cause) {
super(cause);
this.globalisationMessageCode = globalisationMessageCode;
this.defaultUserMessage = defaultUserMessage;
this.errors = errors;
}
public PlatformApiDataValidationException(final List<ApiParameterError> errors, Throwable cause) {
super(cause);
this.globalisationMessageCode = "validation.msg.validation.errors.exist";
this.defaultUserMessage = "Validation errors exist.";
this.errors = errors;
}
public String getGlobalisationMessageCode() {
return this.globalisationMessageCode;
}
@@ -30,18 +30,20 @@ public class PlatformDataIntegrityException extends RuntimeException {
public PlatformDataIntegrityException(final String globalisationMessageCode, final String defaultUserMessage,
final Object... defaultUserMessageArgs) {
super(AbstractPlatformException.findThrowableCause(defaultUserMessageArgs));
this.globalisationMessageCode = globalisationMessageCode;
this.defaultUserMessage = defaultUserMessage;
this.parameterName = null;
this.defaultUserMessageArgs = defaultUserMessageArgs;
this.defaultUserMessageArgs = AbstractPlatformException.filterThrowableCause(defaultUserMessageArgs);
}
public PlatformDataIntegrityException(final String globalisationMessageCode, final String defaultUserMessage,
final String parameterName, final Object... defaultUserMessageArgs) {
super(AbstractPlatformException.findThrowableCause(defaultUserMessageArgs));
this.globalisationMessageCode = globalisationMessageCode;
this.defaultUserMessage = defaultUserMessage;
this.parameterName = parameterName;
this.defaultUserMessageArgs = defaultUserMessageArgs;
this.defaultUserMessageArgs = AbstractPlatformException.filterThrowableCause(defaultUserMessageArgs);
}
public String getGlobalisationMessageCode() {
@@ -124,6 +124,7 @@ public class FromJsonHelper {
* @param object
* @param supportedParams
*/
@SuppressWarnings("AvoidHidingCauseException")
public void checkForUnsupportedNestedParameters(final String parentPropertyName, final JsonObject object,
final Set<String> supportedParams) {
try {
@@ -347,7 +347,7 @@ public class JsonParserHelper {
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
}
@@ -420,7 +420,7 @@ public class JsonParserHelper {
parameterName);
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
@@ -474,7 +474,7 @@ public class JsonParserHelper {
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
@@ -568,7 +568,7 @@ public class JsonParserHelper {
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
@@ -592,7 +592,7 @@ public class JsonParserHelper {
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
@@ -648,7 +648,7 @@ public class JsonParserHelper {
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
@@ -95,7 +95,7 @@ public class DateUtils {
"The parameter date (" + stringDate + ") is invalid w.r.t. pattern " + pattern, "date", stringDate, pattern);
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
dataValidationErrors, e);
}
}
@@ -86,7 +86,7 @@ public class TenantDatabaseUpgradeService {
} catch (FlywayException e) {
String betterMessage = e.getMessage() + "; for Tenant DB URL: " + connectionProtocol + ", username: "
+ connection.getSchemaUsername();
throw new FlywayException(betterMessage, e.getCause());
throw new FlywayException(betterMessage, e);
}
}
}
@@ -86,7 +86,7 @@ public class GenericDataServiceImpl implements GenericDataService {
return new GenericResultsetData(columnHeaders, resultsetDataRows);
} catch (DataAccessException e) {
throw new PlatformDataIntegrityException("error.msg.report.unknown.data.integrity.issue", e.getClass().getName());
throw new PlatformDataIntegrityException("error.msg.report.unknown.data.integrity.issue", e.getClass().getName(), e);
}
}
@@ -116,7 +116,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
// out.flush();
// out.close();
} catch (final Exception e) {
throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage());
throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage(), e);
}
}
};
@@ -313,7 +313,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
return genaratePdf;
} catch (final Exception e) {
LOG.error("error.msg.reporting.error:", e);
throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage());
throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage(), e);
}
}
@@ -273,21 +273,21 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
if (realCause.getMessage().contains("Duplicate entry") || cause.getMessage().contains("Duplicate entry")) {
throw new PlatformDataIntegrityException("error.msg.datatable.registered",
"Datatable `" + dataTableName + "` is already registered against an application table.", "dataTableName",
dataTableName);
dataTableName, dve);
}
logAsErrorUnexpectedDataIntegrityException(dve);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
} catch (final PersistenceException dve) {
final Throwable cause = dve.getCause();
if (cause.getMessage().contains("Duplicate entry")) {
throw new PlatformDataIntegrityException("error.msg.datatable.registered",
"Datatable `" + dataTableName + "` is already registered against an application table.", "dataTableName",
dataTableName);
dataTableName, dve);
}
logAsErrorUnexpectedDataIntegrityException(dve);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
}
}
@@ -394,35 +394,35 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
throw new PlatformDataIntegrityException(
"error.msg.datatable.entry.duplicate", "An entry already exists for datatable `" + dataTableName
+ "` and application table with identifier `" + appTableId + "`.",
"dataTableName", dataTableName, appTableId);
"dataTableName", dataTableName, appTableId, dve);
} else if (realCause.getMessage().contains("doesn't have a default value")
|| cause.getMessage().contains("doesn't have a default value")) {
throw new PlatformDataIntegrityException(
"error.msg.datatable.no.value.provided.for.required.fields", "No values provided for the datatable `"
+ dataTableName + "` and application table with identifier `" + appTableId + "`.",
"dataTableName", dataTableName, appTableId);
"dataTableName", dataTableName, appTableId, dve);
}
logAsErrorUnexpectedDataIntegrityException(dve);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
} catch (final PersistenceException e) {
final Throwable cause = e.getCause();
if (cause.getMessage().contains("Duplicate entry")) {
throw new PlatformDataIntegrityException(
"error.msg.datatable.entry.duplicate", "An entry already exists for datatable `" + dataTableName
+ "` and application table with identifier `" + appTableId + "`.",
"dataTableName", dataTableName, appTableId);
"dataTableName", dataTableName, appTableId, e);
} else if (cause.getMessage().contains("doesn't have a default value")) {
throw new PlatformDataIntegrityException(
"error.msg.datatable.no.value.provided.for.required.fields", "No values provided for the datatable `"
+ dataTableName + "` and application table with identifier `" + appTableId + "`.",
"dataTableName", dataTableName, appTableId);
"dataTableName", dataTableName, appTableId, e);
}
logAsErrorUnexpectedDataIntegrityException(e);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", e);
}
}
@@ -452,24 +452,24 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
throw new PlatformDataIntegrityException(
"error.msg.datatable.entry.duplicate", "An entry already exists for datatable `" + dataTableName
+ "` and application table with identifier `" + appTableId + "`.",
"dataTableName", dataTableName, appTableId);
"dataTableName", dataTableName, appTableId, dve);
}
logAsErrorUnexpectedDataIntegrityException(dve);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
} catch (final PersistenceException dve) {
final Throwable cause = dve.getCause();
if (cause.getMessage().contains("Duplicate entry")) {
throw new PlatformDataIntegrityException(
"error.msg.datatable.entry.duplicate", "An entry already exists for datatable `" + dataTableName
+ "` and application table with identifier `" + appTableId + "`.",
"dataTableName", dataTableName, appTableId);
"dataTableName", dataTableName, appTableId, dve);
}
logAsErrorUnexpectedDataIntegrityException(dve);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
}
}
@@ -1008,7 +1008,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
} catch (final Exception e) {
if (e.getMessage().contains("Error on rename")) {
throw new PlatformServiceUnavailableException("error.msg.datatable.column.update.not.allowed",
"One of the column name modification not allowed");
"One of the column name modification not allowed", e);
}
// handle all other exceptions in here
@@ -1018,7 +1018,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
// PlatformServiceUnavailableException
if (e.getMessage().toLowerCase().contains("invalid use of null value")) {
throw new PlatformServiceUnavailableException("error.msg.datatable.column.update.not.allowed",
"One of the data table columns contains null values");
"One of the data table columns contains null values", e);
}
}
}
@@ -84,7 +84,7 @@ public class FileSystemContentRepository implements ContentRepository {
out.flush();
out.close();
} catch (final IOException ioe) {
throw new ContentManagementException(imageName, ioe.getMessage());
throw new ContentManagementException(imageName, ioe.getMessage(), ioe);
} catch (IllegalArgumentException iae) {
LOG.error("IllegalArgumentException due to invalid Base64 encoding: {}", base64EncodedImageString, iae);
throw iae;
@@ -173,7 +173,7 @@ public class FileSystemContentRepository implements ContentRepository {
} catch (final IOException ioException) {
LOG.warn("writeFileToFileSystem() IOException (logged because cause is not propagated in ContentManagementException)",
ioException);
throw new ContentManagementException(fileName, ioException.getMessage());
throw new ContentManagementException(fileName, ioException.getMessage(), ioException);
}
}
}
@@ -76,7 +76,7 @@ public class S3ContentRepository implements ContentRepository {
try {
deleteObjectFromS3(documentPath);
} catch (final AmazonClientException ace) {
throw new ContentManagementException(documentName, ace.getMessage());
throw new ContentManagementException(documentName, ace.getMessage(), ace);
}
}
@@ -129,7 +129,8 @@ public class S3ContentRepository implements ContentRepository {
fileData = new FileData(s3object.getObjectContent(), fileName, documentData.contentType());
} catch (final AmazonClientException ace) {
LOG.error("Error occured.", ace);
throw new DocumentNotFoundException(documentData.getParentEntityType(), documentData.getParentEntityId(), documentData.getId());
throw new DocumentNotFoundException(documentData.getParentEntityType(), documentData.getParentEntityId(), documentData.getId(),
ace);
}
return fileData;
}
@@ -177,7 +178,7 @@ public class S3ContentRepository implements ContentRepository {
this.s3Client.putObject(new PutObjectRequest(this.s3BucketName, s3UploadLocation, inputStream, new ObjectMetadata()));
} catch (final AmazonClientException ace) {
final String message = ace.getMessage();
throw new ContentManagementException(filename, message);
throw new ContentManagementException(filename, message, ace);
}
}
}
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.infrastructure.documentmanagement.exception;
import com.amazonaws.AmazonClientException;
import java.io.IOException;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
public class ContentManagementException extends AbstractPlatformDomainRuleException {
@@ -32,4 +34,19 @@ public class ContentManagementException extends AbstractPlatformDomainRuleExcept
+ fileSize / (1024 * 1024) + " MB exceeds the max permissable file size of " + maxFileSize + " MB", name, fileSize);
}
public ContentManagementException(String filename, String message, IOException ioException) {
super("error.msg.document.save", "Error while manipulating file " + filename + " due to a File system / Amazon S3 issue " + message,
filename, message, ioException);
}
public ContentManagementException(String filename, String message, AmazonClientException ace) {
super("error.msg.document.save", "Error while manipulating file " + filename + " due to a File system / Amazon S3 issue " + message,
filename, message, ace);
}
public ContentManagementException(String filename, String message, ContentManagementException cme) {
super("error.msg.document.save", "Error while manipulating file " + filename + " due to a File system / Amazon S3 issue " + message,
filename, message, cme);
}
}
@@ -18,7 +18,9 @@
*/
package org.apache.fineract.infrastructure.documentmanagement.exception;
import com.amazonaws.AmazonClientException;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class DocumentNotFoundException extends AbstractPlatformResourceNotFoundException {
@@ -26,4 +28,14 @@ public class DocumentNotFoundException extends AbstractPlatformResourceNotFoundE
super("error.msg.document.id.invalid",
"Document with identifier " + id + " does not exist for the " + entityType + " with Identifier " + entityId, id);
}
public DocumentNotFoundException(String entityType, Long entityId, Long id, EmptyResultDataAccessException e) {
super("error.msg.document.id.invalid",
"Document with identifier " + id + " does not exist for the " + entityType + " with Identifier " + entityId, id, e);
}
public DocumentNotFoundException(String entityType, Long entityId, Long id, AmazonClientException ace) {
super("error.msg.document.id.invalid",
"Document with identifier " + id + " does not exist for the " + entityType + " with Identifier " + entityId, id, ace);
}
}
@@ -71,7 +71,7 @@ public class DocumentReadPlatformServiceImpl implements DocumentReadPlatformServ
final ContentRepository contentRepository = this.contentRepositoryFactory.getRepository(documentData.storageType());
return contentRepository.fetchFile(documentData);
} catch (final EmptyResultDataAccessException e) {
throw new DocumentNotFoundException(entityType, entityId, documentId);
throw new DocumentNotFoundException(entityType, entityId, documentId, e);
}
}
@@ -81,7 +81,7 @@ public class DocumentReadPlatformServiceImpl implements DocumentReadPlatformServ
final DocumentMapper mapper = new DocumentMapper(true, true);
return fetchDocumentDetails(entityType, entityId, documentId, mapper);
} catch (final EmptyResultDataAccessException e) {
throw new DocumentNotFoundException(entityType, entityId, documentId);
throw new DocumentNotFoundException(entityType, entityId, documentId, e);
}
}
@@ -82,7 +82,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
} catch (final DataIntegrityViolationException dve) {
LOG.error("Error occured.", dve);
throw new PlatformDataIntegrityException("error.msg.document.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
}
}
@@ -136,10 +136,10 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
} catch (final DataIntegrityViolationException dve) {
LOG.error("Error occured.", dve);
throw new PlatformDataIntegrityException("error.msg.document.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
"Unknown data integrity issue with resource.", dve);
} catch (final ContentManagementException cme) {
LOG.error("Error occured.", cme);
throw new ContentManagementException(documentCommand.getName(), cme.getMessage());
throw new ContentManagementException(documentCommand.getName(), cme.getMessage(), cme);
}
}
@@ -113,7 +113,7 @@ public class ImageReadPlatformServiceImpl implements ImageReadPlatformService {
return result;
} catch (final EmptyResultDataAccessException e) {
throw new ImageNotFoundException("clients", entityId);
throw new ImageNotFoundException("clients", entityId, e);
}
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.gcm.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class DeviceRegistrationNotFoundException extends AbstractPlatformResourceNotFoundException {
@@ -31,4 +32,13 @@ public class DeviceRegistrationNotFoundException extends AbstractPlatformResourc
"Device registration with " + value + " identifier " + clientId + " does not exist", clientId);
}
public DeviceRegistrationNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.device.registration.id.invalid", "Device registration with identifier " + id + " does not exist", id, e);
}
public DeviceRegistrationNotFoundException(Long clientId, String value, EmptyResultDataAccessException e) {
super("error.msg.device.registration." + value + ".invalid",
"Device registration with " + value + " identifier " + clientId + " does not exist", clientId, e);
}
}
@@ -92,7 +92,7 @@ public class DeviceRegistrationReadPlatformServiceImpl implements DeviceRegistra
String sql = "select " + drm.schema() + " where cdr.id = ? ";
return this.jdbcTemplate.queryForObject(sql, drm, new Object[] { id });
} catch (final EmptyResultDataAccessException e) {
throw new DeviceRegistrationNotFoundException(id);
throw new DeviceRegistrationNotFoundException(id, e);
}
}
@@ -104,7 +104,7 @@ public class DeviceRegistrationReadPlatformServiceImpl implements DeviceRegistra
String sql = "select " + drm.schema() + " where c.id = ? ";
return this.jdbcTemplate.queryForObject(sql, drm, new Object[] { clientId });
} catch (final EmptyResultDataAccessException e) {
throw new DeviceRegistrationNotFoundException(clientId, "client");
throw new DeviceRegistrationNotFoundException(clientId, "client", e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.hooks.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class HookNotFoundException extends AbstractPlatformResourceNotFoundException {
@@ -29,4 +30,8 @@ public class HookNotFoundException extends AbstractPlatformResourceNotFoundExcep
public HookNotFoundException(final Long hookId) {
super("error.msg.hook.identifier.not.found", "Hook with identifier `" + hookId + "` does not exist", hookId);
}
public HookNotFoundException(Long hookId, EmptyResultDataAccessException e) {
super("error.msg.hook.identifier.not.found", "Hook with identifier `" + hookId + "` does not exist", hookId, e);
}
}
@@ -75,7 +75,7 @@ public class HookReadPlatformServiceImpl implements HookReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { hookId });
} catch (final EmptyResultDataAccessException e) {
throw new HookNotFoundException(hookId);
throw new HookNotFoundException(hookId, e);
}
}
@@ -200,7 +200,7 @@ public class HookWritePlatformServiceJpaRepositoryImpl implements HookWritePlatf
this.hookRepository.delete(hook);
} catch (final DataIntegrityViolationException e) {
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
"Unknown data integrity issue with resource: " + e.getMostSpecificCause(), e);
}
return new CommandProcessingResultBuilder().withEntityId(hookId).build();
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.jobs.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when Job resources are not found.
@@ -28,4 +29,8 @@ public class JobNotFoundException extends AbstractPlatformResourceNotFoundExcept
public JobNotFoundException(final String identifier) {
super("error.msg.sheduler.job.id.invalid", "Job with identifier " + identifier + " does not exist", identifier);
}
public JobNotFoundException(String identifier, EmptyResultDataAccessException e) {
super("error.msg.sheduler.job.id.invalid", "Job with identifier " + identifier + " does not exist", identifier, e);
}
}
@@ -164,7 +164,7 @@ public class JobRegisterServiceImpl implements JobRegisterService, ApplicationLi
} catch (final Exception e) {
final String msg = "Job execution failed for job with id:" + scheduledJobDetail.getId();
LOG.error("{}", msg, e);
throw new PlatformInternalServerException("error.msg.sheduler.job.execution.failed", msg, scheduledJobDetail.getId());
throw new PlatformInternalServerException("error.msg.sheduler.job.execution.failed", msg, scheduledJobDetail.getId(), e);
}
}
@@ -67,7 +67,7 @@ public class SchedulerJobRunnerReadServiceImpl implements SchedulerJobRunnerRead
final String sql = detailMapper.schema() + " where job.id=?";
return this.jdbcTemplate.queryForObject(sql, detailMapper, new Object[] { jobId });
} catch (final EmptyResultDataAccessException e) {
throw new JobNotFoundException(String.valueOf(jobId));
throw new JobNotFoundException(String.valueOf(jobId), e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.reportmailingjob.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when report mailing job configuration resources are not found.
@@ -30,4 +31,9 @@ public class ReportMailingJobConfigurationNotFoundException extends AbstractPlat
super("error.msg.report.mailing.job.configuration.name.invalid",
"Report mailing job configuration with name " + name + " does not exist", name);
}
public ReportMailingJobConfigurationNotFoundException(String name, EmptyResultDataAccessException ex) {
super("error.msg.report.mailing.job.configuration.name.invalid",
"Report mailing job configuration with name " + name + " does not exist", name, ex);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.reportmailingjob.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when report mailing job resources are not found.
@@ -30,4 +31,9 @@ public class ReportMailingJobNotFoundException extends AbstractPlatformResourceN
super("error.msg.report.mailing.job.id.invalid", "Report mailing job with identifier " + reportMailingJobId + " does not exist",
reportMailingJobId);
}
public ReportMailingJobNotFoundException(Long reportMailingJobId, EmptyResultDataAccessException ex) {
super("error.msg.report.mailing.job.id.invalid", "Report mailing job with identifier " + reportMailingJobId + " does not exist",
reportMailingJobId, ex);
}
}
@@ -62,7 +62,7 @@ public class ReportMailingJobConfigurationReadPlatformServiceImpl implements Rep
}
catch (final EmptyResultDataAccessException ex) {
throw new ReportMailingJobConfigurationNotFoundException(name);
throw new ReportMailingJobConfigurationNotFoundException(name, ex);
}
}
@@ -109,7 +109,7 @@ public class ReportMailingJobReadPlatformServiceImpl implements ReportMailingJob
}
catch (final EmptyResultDataAccessException ex) {
throw new ReportMailingJobNotFoundException(reportMailingJobId);
throw new ReportMailingJobNotFoundException(reportMailingJobId, ex);
}
}
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.infrastructure.security.exception;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* {@link RuntimeException} thrown when an invalid tenant identifier is used in request to platform.
*
@@ -28,4 +30,8 @@ public class InvalidTenantIdentiferException extends RuntimeException {
public InvalidTenantIdentiferException(final String message) {
super(message);
}
public InvalidTenantIdentiferException(String message, EmptyResultDataAccessException e) {
super(message, e);
}
}
@@ -140,7 +140,7 @@ public class BasicAuthTenantDetailsServiceJdbc implements BasicAuthTenantDetails
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { tenantIdentifier });
} catch (final EmptyResultDataAccessException e) {
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.");
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.", e);
}
}
}
@@ -133,7 +133,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { tenantIdentifier });
} catch (final EmptyResultDataAccessException e) {
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.");
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.", e);
}
}
@@ -68,7 +68,7 @@ public class ColumnValidator {
}
}
} catch (SQLException e) {
throw new SQLInjectionException();
throw new SQLInjectionException(e);
} finally {
if (connection != null) {
DataSourceUtils.releaseConnection(connection, jdbcTemplate.getDataSource());
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.infrastructure.security.utils;
import java.sql.SQLException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
public class SQLInjectionException extends PlatformApiDataValidationException {
@@ -26,4 +27,8 @@ public class SQLInjectionException extends PlatformApiDataValidationException {
super("error.msg.found.sql.injection", "Unexpected SQL Commands found", null);
}
public SQLInjectionException(SQLException e) {
super("error.msg.found.sql.injection", "Unexpected SQL Commands found", null, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.sms.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when a code is not found.
@@ -28,4 +29,8 @@ public class SmsNotFoundException extends AbstractPlatformResourceNotFoundExcept
public SmsNotFoundException(final Long resourceId) {
super("error.msg.sms.identifier.not.found", "SMS with identifier `" + resourceId + "` does not exist", resourceId);
}
public SmsNotFoundException(Long resourceId, EmptyResultDataAccessException e) {
super("error.msg.sms.identifier.not.found", "SMS with identifier `" + resourceId + "` does not exist", resourceId, e);
}
}
@@ -140,7 +140,7 @@ public class SmsMessageScheduledJobServiceImpl implements SmsMessageScheduledJob
// apiQueueResourceDatas).start();
}
} catch (Exception e) {
throw new ConnectionFailureException(SmsCampaignConstants.SMS);
throw new ConnectionFailureException(SmsCampaignConstants.SMS, e);
}
page++;
totalRecords = pendingMessages.getTotalPages();
@@ -124,7 +124,7 @@ public class SmsReadPlatformServiceImpl implements SmsReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, this.smsRowMapper, new Object[] { resourceId });
} catch (final EmptyResultDataAccessException e) {
throw new SmsNotFoundException(resourceId);
throw new SmsNotFoundException(resourceId, e);
}
}
@@ -166,7 +166,7 @@ public class XBRLResultServiceImpl implements XBRLResultService {
}
} catch (final ScriptException e) {
LOG.error("Problem occurred in processMappingString function", e);
throw new IllegalArgumentException(e.getMessage());
throw new IllegalArgumentException(e.getMessage(), e);
}
return new BigDecimal(eval);
@@ -19,6 +19,7 @@
package org.apache.fineract.notification.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when topic resources are not found.
@@ -29,4 +30,8 @@ public class TopicNotFoundException extends AbstractPlatformResourceNotFoundExce
super("error.msg.topic.id.invalid", "Topic with identifier " + id + " does not exist", id);
}
public TopicNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.topic.id.invalid", "Topic with identifier " + id + " does not exist", id, e);
}
}
@@ -91,7 +91,7 @@ public class TopicReadPlatformServiceImpl implements TopicReadPlatformService {
final String sql = "select " + tm.schema() + " where t.id = ?";
return this.jdbcTemplate.queryForObject(sql, tm, new Object[] { topicId });
} catch (final EmptyResultDataAccessException e) {
throw new TopicNotFoundException(topicId);
throw new TopicNotFoundException(topicId, e);
}
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.organisation.holiday.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when holiday resources are not found.
@@ -28,4 +29,8 @@ public class HolidayNotFoundException extends AbstractPlatformResourceNotFoundEx
public HolidayNotFoundException(final Long id) {
super("error.msg.holiday.id.invalid", "Holiday with identifier " + id + " does not exist", id);
}
public HolidayNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.holiday.id.invalid", "Holiday with identifier " + id + " does not exist", id, e);
}
}
@@ -133,7 +133,7 @@ public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformServic
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { holidayId });
} catch (final EmptyResultDataAccessException e) {
throw new HolidayNotFoundException(holidayId);
throw new HolidayNotFoundException(holidayId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.organisation.office.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when office resources are not found.
@@ -28,4 +29,8 @@ public class OfficeNotFoundException extends AbstractPlatformResourceNotFoundExc
public OfficeNotFoundException(final Long id) {
super("error.msg.office.id.invalid", "Office with identifier " + id + " does not exist", id);
}
public OfficeNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.office.id.invalid", "Office with identifier " + id + " does not exist", id, e);
}
}
@@ -200,7 +200,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
return selectedOffice;
} catch (final EmptyResultDataAccessException e) {
throw new OfficeNotFoundException(officeId);
throw new OfficeNotFoundException(officeId, e);
}
}
@@ -19,10 +19,15 @@
package org.apache.fineract.organisation.provisioning.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class ProvisioningCriteriaNotFoundException extends AbstractPlatformResourceNotFoundException {
public ProvisioningCriteriaNotFoundException(final Long id) {
super("error.msg.provisioning.criteria.id.invalid", "Provisioning Criteria with identifier " + id + " does not exist", id);
}
public ProvisioningCriteriaNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.provisioning.criteria.id.invalid", "Provisioning Criteria with identifier " + id + " does not exist", id, e);
}
}
@@ -123,7 +123,7 @@ public class ProvisioningCriteriaReadPlatformServiceImpl implements Provisioning
List<ProvisioningCriteriaDefinitionData> definitions = retrieveProvisioningDefinitions(criteriaId);
return ProvisioningCriteriaData.toLookup(criteriaId, criteriaName, loanProducts, definitions);
} catch (EmptyResultDataAccessException e) {
throw new ProvisioningCriteriaNotFoundException(criteriaId);
throw new ProvisioningCriteriaNotFoundException(criteriaId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.organisation.staff.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when staff resources are not found.
@@ -28,4 +29,8 @@ public class StaffNotFoundException extends AbstractPlatformResourceNotFoundExce
public StaffNotFoundException(final Long id) {
super("error.msg.staff.id.invalid", "Staff with identifier " + id + " does not exist", id);
}
public StaffNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.staff.id.invalid", "Staff with identifier " + id + " does not exist", id, e);
}
}
@@ -199,7 +199,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { staffId, hierarchy });
} catch (final EmptyResultDataAccessException e) {
throw new StaffNotFoundException(staffId);
throw new StaffNotFoundException(staffId, e);
}
}
@@ -219,7 +219,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.queryForObject(sql, tm, new Object[] { tellerId });
} catch (final EmptyResultDataAccessException e) {
throw new StaffNotFoundException(tellerId);
throw new StaffNotFoundException(tellerId, e);
}
}
@@ -332,7 +332,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.queryForObject(sql, cm, new Object[] { cashierId });
} catch (final EmptyResultDataAccessException e) {
throw new StaffNotFoundException(cashierId);
throw new StaffNotFoundException(cashierId, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.organisation.workingdays.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when Calendar resources are not found.
@@ -29,4 +30,8 @@ public class WorkingDaysNotFoundException extends AbstractPlatformResourceNotFou
super("error.msg.working.days.not.configured", "Must configure the Working days for the organisation.");
}
public WorkingDaysNotFoundException(EmptyResultDataAccessException e) {
super("error.msg.working.days.not.configured", "Must configure the Working days for the organisation.", e);
}
}
@@ -86,7 +86,7 @@ public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatfo
Collection<EnumOptionData> repaymentRescheduleOptions = repaymentRescheduleTypeOptions();
return new WorkingDaysData(data, repaymentRescheduleOptions);
} catch (final EmptyResultDataAccessException e) {
throw new WorkingDaysNotFoundException();
throw new WorkingDaysNotFoundException(e);
}
}
@@ -66,10 +66,10 @@ public class WorkingDaysWritePlatformServiceJpaRepositoryImpl implements Working
.build();
} catch (final ValidationException e) {
throw new PlatformDataIntegrityException("error.msg.invalid.recurring.rule",
"The Recurring Rule value: " + recurrence + " is not valid.", "recurrence", recurrence);
"The Recurring Rule value: " + recurrence + " is not valid.", "recurrence", recurrence, e);
} catch (final IllegalArgumentException | ParseException e) {
throw new PlatformDataIntegrityException("error.msg.recurring.rule.parsing.error",
"Error in passing the Recurring Rule value: " + recurrence, "recurrence", e.getMessage());
"Error in passing the Recurring Rule value: " + recurrence, "recurrence", e.getMessage(), e);
}
}
@@ -19,10 +19,15 @@
package org.apache.fineract.portfolio.account.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class AccountTransferNotFoundException extends AbstractPlatformResourceNotFoundException {
public AccountTransferNotFoundException(final Long id) {
super("error.msg.accounttransfer.id.invalid", "Account transfer with identifier " + id + " does not exist", id);
}
public AccountTransferNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.accounttransfer.id.invalid", "Account transfer with identifier " + id + " does not exist", id, e);
}
}
@@ -252,7 +252,7 @@ public class AccountTransfersReadPlatformServiceImpl implements AccountTransfers
return this.jdbcTemplate.queryForObject(sql, this.accountTransfersMapper, new Object[] { transferId });
} catch (final EmptyResultDataAccessException e) {
throw new AccountTransferNotFoundException(transferId);
throw new AccountTransferNotFoundException(transferId, e);
}
}
@@ -92,7 +92,7 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
break;
}
} catch (final EmptyResultDataAccessException e) {
throw new AccountTransferNotFoundException(accountId);
throw new AccountTransferNotFoundException(accountId, e);
}
return accountData;
@@ -389,7 +389,7 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
accountData = this.jdbcTemplate.queryForObject(sql, this.accountRefundByTransferMapper, sqlParams);
} catch (final EmptyResultDataAccessException e) {
throw new AccountTransferNotFoundException(accountId);
throw new AccountTransferNotFoundException(accountId, e);
}
return accountData;
@@ -347,7 +347,7 @@ public class StandingInstructionReadPlatformServiceImpl implements StandingInstr
return this.jdbcTemplate.queryForObject(sql, this.standingInstructionMapper, new Object[] { instructionId });
} catch (final EmptyResultDataAccessException e) {
throw new AccountTransferNotFoundException(instructionId);
throw new AccountTransferNotFoundException(instructionId, e);
}
}
@@ -112,7 +112,7 @@ public class AccountsApiResource {
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, accountData, service.getResponseDataParams());
} catch (BeansException e) {
throw new ResourceNotFoundException();
throw new ResourceNotFoundException(e);
}
}
@@ -133,7 +133,7 @@ public class AccountsApiResource {
AccountData data = service.retrieveOne(accountId, settings.isTemplate());
return this.toApiJsonSerializer.serialize(settings, data, service.getResponseDataParams());
} catch (BeansException e) {
throw new ResourceNotFoundException();
throw new ResourceNotFoundException(e);
}
}
@@ -154,7 +154,7 @@ public class AccountsApiResource {
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, data, service.getResponseDataParams());
} catch (BeansException e) {
throw new ResourceNotFoundException();
throw new ResourceNotFoundException(e);
}
}
@@ -19,10 +19,15 @@
package org.apache.fineract.portfolio.accounts.exceptions;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class ShareAccountNotFoundException extends AbstractPlatformResourceNotFoundException {
public ShareAccountNotFoundException(final Long id) {
super("error.msg.shareaccount.id.invalid", " Account with identifier " + id + " does not exist", id);
}
public ShareAccountNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.shareaccount.id.invalid", " Account with identifier " + id + " does not exist", id, e);
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.calendar.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when Calendar resources are not found.
@@ -28,4 +29,8 @@ public class CalendarNotFoundException extends AbstractPlatformResourceNotFoundE
public CalendarNotFoundException(final Long id) {
super("error.msg.calendar.id.invalid", "Calendar with identifier " + id + " does not exist", id);
}
public CalendarNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.calendar.id.invalid", "Calendar with identifier " + id + " does not exist", id, e);
}
}
@@ -128,7 +128,7 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { calendarId, entityId, entityTypeId });
} catch (final EmptyResultDataAccessException e) {
throw new CalendarNotFoundException(calendarId);
throw new CalendarNotFoundException(calendarId, e);
}
}
@@ -243,10 +243,10 @@ public class CalendarUtils {
recur = rrule.getRecur();
} catch (final ValidationException e) {
throw new PlatformDataIntegrityException("error.msg.invalid.recurring.rule",
"The Recurring Rule value: " + recurringRule + " is not valid.", "recurrence", recurringRule);
"The Recurring Rule value: " + recurringRule + " is not valid.", "recurrence", recurringRule, e);
} catch (final ParseException e) {
throw new PlatformDataIntegrityException("error.msg.recurring.rule.parsing.error",
"Error in pasring the Recurring Rule value: " + recurringRule, "recurrence", recurringRule);
"Error in pasring the Recurring Rule value: " + recurringRule, "recurrence", recurringRule, e);
}
if (recur == null) {
@@ -19,10 +19,15 @@
package org.apache.fineract.portfolio.charge.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
public class ChargeNotFoundException extends AbstractPlatformResourceNotFoundException {
public ChargeNotFoundException(final Long id) {
super("error.msg.charge.id.invalid", "Charge with identifier " + id + " does not exist", id);
}
public ChargeNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.charge.id.invalid", "Charge with identifier " + id + " does not exist", id, e);
}
}
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.charge.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* {@link AbstractPlatformDomainRuleException} thrown when savings account charge does not exist.
@@ -35,4 +36,8 @@ public class SavingsAccountChargeNotFoundException extends AbstractPlatformResou
"Savings Account charge with identifier " + id + " does not exist for Savings Account " + savingsAccountId, id,
savingsAccountId);
}
public SavingsAccountChargeNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.savings.account.charge.id.invalid", "Savings Account charge with identifier " + id + " does not exist", id, e);
}
}

Some files were not shown because too many files have changed in this diff Show More