FINERACT-821 Added and Enforced LeftCurly Checkstyle
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
7c689a81b9
commit
dedd3be1dc
@@ -174,7 +174,7 @@
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="LeftCurly" />
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
@@ -185,7 +186,6 @@
|
||||
|
||||
|
||||
|
||||
<module name="LeftCurly" />
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, STATIC_INIT, INSTANCE_INIT"/>
|
||||
|
||||
+9
-3
@@ -256,13 +256,19 @@ public class CenterDomain implements Comparable<CenterDomain> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) { return true; }
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof CenterDomain)) { return false; }
|
||||
if (!(obj instanceof CenterDomain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CenterDomain cd = (CenterDomain) obj;
|
||||
|
||||
if (this.hashCode() == cd.hashCode()) { return true; }
|
||||
if (this.hashCode() == cd.hashCode()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -58,7 +58,9 @@ public class CurrenciesHelper {
|
||||
final String code) {
|
||||
ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec);
|
||||
for (CurrencyDomain e : currenciesList) {
|
||||
if (e.getCode().equals(code)) { return e; }
|
||||
if (e.getCode().equals(code)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+6
-2
@@ -133,9 +133,13 @@ public class CurrencyDomain implements Comparable<CurrencyDomain> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) { return true; }
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof CurrencyDomain)) { return false; }
|
||||
if (!(obj instanceof CurrencyDomain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CurrencyDomain cd = (CurrencyDomain) obj;
|
||||
|
||||
|
||||
+6
-2
@@ -134,9 +134,13 @@ public class OfficeDomain {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) { return true; }
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof OfficeDomain)) { return false; }
|
||||
if (!(obj instanceof OfficeDomain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OfficeDomain od = (OfficeDomain) obj;
|
||||
|
||||
|
||||
+9
-3
@@ -166,7 +166,9 @@ public class SchedulerJobHelper {
|
||||
// jobRunStartTime >= beforeExecuteTime (or timeout)
|
||||
await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId), lastRunHistory -> {
|
||||
String jobRunStartText = lastRunHistory.get("jobRunStartTime");
|
||||
if (jobRunStartText == null) { return false; }
|
||||
if (jobRunStartText == null) {
|
||||
return false;
|
||||
}
|
||||
Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from);
|
||||
return jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime);
|
||||
});
|
||||
@@ -176,7 +178,9 @@ public class SchedulerJobHelper {
|
||||
Map<String, String> finalLastRunHistory = await().atMost(TIMEOUT).pollInterval(PAUSE).until(jobLastRunHistorySupplier(jobId),
|
||||
lastRunHistory -> {
|
||||
String jobRunEndText = lastRunHistory.get("jobRunEndTime");
|
||||
if (jobRunEndText == null) { return false; }
|
||||
if (jobRunEndText == null) {
|
||||
return false;
|
||||
}
|
||||
Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from);
|
||||
Instant jobRunStartTime = df.parse(lastRunHistory.get("jobRunStartTime"), Instant::from);
|
||||
return jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime);
|
||||
@@ -201,7 +205,9 @@ public class SchedulerJobHelper {
|
||||
private Callable<Map<String, String>> jobLastRunHistorySupplier(int jobId) {
|
||||
return () -> {
|
||||
Map<String, Object> job = getSchedulerJobById(jobId);
|
||||
if (job == null) { return null; }
|
||||
if (job == null) {
|
||||
return null;
|
||||
}
|
||||
return (Map<String, String>) job.get("lastRunHistory");
|
||||
};
|
||||
}
|
||||
|
||||
+6
-2
@@ -135,7 +135,9 @@ public class Utils {
|
||||
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
|
||||
if (jsonAttributeToGetBack == null) { return (T) json; }
|
||||
if (jsonAttributeToGetBack == null) {
|
||||
return (T) json;
|
||||
}
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
@@ -153,7 +155,9 @@ public class Utils {
|
||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
|
||||
.andReturn().asString();
|
||||
if (jsonAttributeToGetBack == null) { return (T) json; }
|
||||
if (jsonAttributeToGetBack == null) {
|
||||
return (T) json;
|
||||
}
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -465,7 +465,9 @@ public class FixedDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getDepositAmount() {
|
||||
if (this.newDepositAmount == null) { return DEPOSIT_AMOUNT; }
|
||||
if (this.newDepositAmount == null) {
|
||||
return DEPOSIT_AMOUNT;
|
||||
}
|
||||
return this.newDepositAmount;
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -82,19 +82,27 @@ public class FundsHelper {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this.name != null) { return this.name.hashCode(); }
|
||||
if (this.name != null) {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) { return true; }
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof FundsHelper)) { return false; }
|
||||
if (!(o instanceof FundsHelper)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FundsHelper fh = (FundsHelper) o;
|
||||
|
||||
if (this.name.equals(fh.name)) { return true; }
|
||||
if (this.name.equals(fh.name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-1
@@ -191,7 +191,9 @@ public class CampaignsHelper {
|
||||
|
||||
if (reports != null && !reports.isEmpty()) {
|
||||
for (ReportData reportData : reports) {
|
||||
if (reportName.equals(reportData.getReportName())) { return reportData.getReportId(); }
|
||||
if (reportName.equals(reportData.getReportName())) {
|
||||
return reportData.getReportId();
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.notNull(null, "null");
|
||||
|
||||
+6
-2
@@ -61,7 +61,9 @@ public final class AccrualAccountingDataValidator {
|
||||
}
|
||||
|
||||
public void validateLoanPeriodicAccrualData(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, LOAN_PERIODIC_REQUEST_DATA_PARAMETERS);
|
||||
|
||||
@@ -78,6 +80,8 @@ public final class AccrualAccountingDataValidator {
|
||||
}
|
||||
|
||||
public void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -43,7 +43,9 @@ public class GLClosureInvalidException extends AbstractPlatformDomainRuleExcepti
|
||||
public String errorCode() {
|
||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
return "error.msg.glclosure.invalid.future.date";
|
||||
} else if (name().toString().equalsIgnoreCase("ACCOUNTING_CLOSED")) { return "error.msg.glclosure.invalid.accounting.closed"; }
|
||||
} else if (name().toString().equalsIgnoreCase("ACCOUNTING_CLOSED")) {
|
||||
return "error.msg.glclosure.invalid.accounting.closed";
|
||||
}
|
||||
return name().toString();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -51,7 +51,9 @@ public final class GLClosureCommandFromApiJsonDeserializer extends AbstractFromA
|
||||
|
||||
@Override
|
||||
public GLClosureCommand commandFromApiJson(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
final Set<String> supportedParameters = GLClosureJsonInputParams.getAllValues();
|
||||
|
||||
+3
-1
@@ -75,7 +75,9 @@ public class GLClosureWritePlatformServiceJpaRepositoryImpl implements GLClosure
|
||||
// ensure closure date is not in the future
|
||||
final Date todaysDate = new Date();
|
||||
final Date closureDate = command.dateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue());
|
||||
if (closureDate.after(todaysDate)) { throw new GLClosureInvalidException(GlClosureInvalidReason.FUTURE_DATE, closureDate); }
|
||||
if (closureDate.after(todaysDate)) {
|
||||
throw new GLClosureInvalidException(GlClosureInvalidReason.FUTURE_DATE, closureDate);
|
||||
}
|
||||
// shouldn't be before an existing accounting closure
|
||||
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(officeId);
|
||||
if (latestGLClosure != null) {
|
||||
|
||||
+3
-1
@@ -45,7 +45,9 @@ public class FinancialActivityAccountRepositoryWrapper {
|
||||
|
||||
public FinancialActivityAccount findByFinancialActivityTypeWithNotFoundDetection(final int financialActivityType) {
|
||||
FinancialActivityAccount financialActivityAccount = this.repository.findByFinancialActivityType(financialActivityType);
|
||||
if (financialActivityAccount == null) { throw new FinancialActivityAccountNotFoundException(financialActivityType); }
|
||||
if (financialActivityAccount == null) {
|
||||
throw new FinancialActivityAccountNotFoundException(financialActivityType);
|
||||
}
|
||||
return financialActivityAccount;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -106,7 +106,9 @@ public final class FinancialActivityAccountDataValidator {
|
||||
}
|
||||
|
||||
private void validateJSONAndCheckForUnsupportedParams(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+3
-1
@@ -237,7 +237,9 @@ public class GLAccountData implements Serializable {
|
||||
}
|
||||
|
||||
public Integer getTypeId() {
|
||||
if (this.type != null) { return this.type.getId().intValue(); }
|
||||
if (this.type != null) {
|
||||
return this.type.getId().intValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -95,7 +95,9 @@ public class TrialBalance extends AbstractPersistableCustom {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof TrialBalance)) { return false; }
|
||||
if (!(obj instanceof TrialBalance)) {
|
||||
return false;
|
||||
}
|
||||
TrialBalance other = (TrialBalance) obj;
|
||||
return Objects.equals(other.officeId, officeId) && Objects.equals(other.glAccountId, glAccountId)
|
||||
&& Objects.equals(other.amount, amount) && Objects.equals(other.entryDate, entryDate)
|
||||
|
||||
+3
-1
@@ -35,7 +35,9 @@ public class TrialBalanceRepositoryWrapper {
|
||||
|
||||
public List<TrialBalance> findNewByOfficeAndAccount(final Long officeId, final Long accountId) {
|
||||
final List<TrialBalance> trialBalanceList = this.repository.findNewByOfficeAndAccount(officeId, accountId);
|
||||
if (trialBalanceList == null) { throw new TrialBalanceNotFoundException(officeId, accountId); }
|
||||
if (trialBalanceList == null) {
|
||||
throw new TrialBalanceNotFoundException(officeId, accountId);
|
||||
}
|
||||
return trialBalanceList;
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -50,7 +50,9 @@ public final class GLAccountCommandFromApiJsonDeserializer extends AbstractFromA
|
||||
|
||||
@Override
|
||||
public GLAccountCommand commandFromApiJson(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
final Set<String> supportedParameters = GLAccountJsonInputParams.getAllValues();
|
||||
|
||||
+9
-3
@@ -119,7 +119,9 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
|
||||
}
|
||||
|
||||
if (usage != null) {
|
||||
if (!checkValidGLAccountUsage(usage)) { throw new GLAccountInvalidClassificationException(accountClassification); }
|
||||
if (!checkValidGLAccountUsage(usage)) {
|
||||
throw new GLAccountInvalidClassificationException(accountClassification);
|
||||
}
|
||||
}
|
||||
|
||||
final GLAccountMapper rm = new GLAccountMapper(associationParametersData);
|
||||
@@ -240,14 +242,18 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
|
||||
|
||||
private static boolean checkValidGLAccountType(final int type) {
|
||||
for (final GLAccountType accountType : GLAccountType.values()) {
|
||||
if (accountType.getValue().equals(type)) { return true; }
|
||||
if (accountType.getValue().equals(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkValidGLAccountUsage(final int type) {
|
||||
for (final GLAccountUsage accountUsage : GLAccountUsage.values()) {
|
||||
if (accountUsage.getValue().equals(type)) { return true; }
|
||||
if (accountUsage.getValue().equals(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+9
-3
@@ -125,7 +125,9 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
validateForAttachedProduct(glAccountId);
|
||||
}
|
||||
final Long parentId = command.longValueOfParameterNamed(GLAccountJsonInputParams.PARENT_ID.getValue());
|
||||
if (glAccountId.equals(parentId)) { throw new InvalidParentGLAccountHeadException(glAccountId, parentId); }
|
||||
if (glAccountId.equals(parentId)) {
|
||||
throw new InvalidParentGLAccountHeadException(glAccountId, parentId);
|
||||
}
|
||||
// is the glAccount valid
|
||||
final GLAccount glAccount = this.glAccountRepository.findById(glAccountId)
|
||||
.orElseThrow(() -> new GLAccountNotFoundException(glAccountId));
|
||||
@@ -178,7 +180,9 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
String sql = "select count(*) from acc_product_mapping acc where acc.gl_account_id = ?";
|
||||
try {
|
||||
int count = this.jdbcTemplate.queryForObject(sql, Integer.class, glAccountId);
|
||||
if (count > 0) { throw new GLAccountDisableException(); }
|
||||
if (count > 0) {
|
||||
throw new GLAccountDisableException();
|
||||
}
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
LOG.error("Problem encountered in validateForAttachedProduct()", e);
|
||||
}
|
||||
@@ -215,7 +219,9 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
parentGLAccount = this.glAccountRepository.findById(parentAccountId)
|
||||
.orElseThrow(() -> new GLAccountNotFoundException(parentAccountId));
|
||||
// ensure parent is not a detail account
|
||||
if (parentGLAccount.isDetailAccount()) { throw new GLAccountInvalidParentException(parentAccountId); }
|
||||
if (parentGLAccount.isDetailAccount()) {
|
||||
throw new GLAccountInvalidParentException(parentAccountId);
|
||||
}
|
||||
}
|
||||
return parentGLAccount;
|
||||
}
|
||||
|
||||
+3
-1
@@ -56,7 +56,9 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
|
||||
|
||||
@Override
|
||||
public JournalEntryCommand commandFromApiJson(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
final Set<String> supportedParameters = JournalEntryJsonInputParams.getAllValues();
|
||||
|
||||
+6
-2
@@ -325,7 +325,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
.findUnReversedManualJournalEntriesByTransactionId(command.getTransactionId());
|
||||
String reversalComment = command.stringValueOfParameterNamed("comments");
|
||||
|
||||
if (journalEntries.size() <= 1) { throw new JournalEntriesNotFoundException(command.getTransactionId()); }
|
||||
if (journalEntries.size() <= 1) {
|
||||
throw new JournalEntriesNotFoundException(command.getTransactionId());
|
||||
}
|
||||
final String reversalTransactionId = revertJournalEntry(journalEntries, reversalComment);
|
||||
return new CommandProcessingResultBuilder().withTransactionId(reversalTransactionId).build();
|
||||
}
|
||||
@@ -792,7 +794,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof OfficeCurrencyKey)) { return false; }
|
||||
if (!(obj instanceof OfficeCurrencyKey)) {
|
||||
return false;
|
||||
}
|
||||
OfficeCurrencyKey copy = (OfficeCurrencyKey) obj;
|
||||
return Objects.equals(this.office.getId(), copy.office.getId()) && this.currency.equals(copy.currency);
|
||||
}
|
||||
|
||||
+9
-3
@@ -79,7 +79,9 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForLoanProductCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loanproduct");
|
||||
@@ -160,7 +162,9 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForSavingsProductCreate(final String json, DepositAccountType accountType) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
@@ -236,7 +240,9 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForShareProductCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
|
||||
+3
-1
@@ -120,7 +120,9 @@ public class LoanProductProvisioningEntry extends AbstractPersistableCustom {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof LoanProductProvisioningEntry)) { return false; }
|
||||
if (!(obj instanceof LoanProductProvisioningEntry)) {
|
||||
return false;
|
||||
}
|
||||
LoanProductProvisioningEntry other = (LoanProductProvisioningEntry) obj;
|
||||
return Objects.equals(other.entry.getId(), this.entry.getId()) && Objects.equals(other.criteriaId, this.criteriaId)
|
||||
&& Objects.equals(other.office.getId(), this.office.getId()) && Objects.equals(other.currencyCode, this.currencyCode)
|
||||
|
||||
+3
-1
@@ -74,6 +74,8 @@ public class ProvisioningEntriesDefinitionJsonDeserializer implements Provisioni
|
||||
Boolean bool = this.fromApiJsonHelper.extractBooleanNamed(JSON_CREATEJOURNALENTRIES_PARAM, element);
|
||||
baseDataValidator.reset().parameter(JSON_CREATEJOURNALENTRIES_PARAM).value(bool).validateForBooleanValue();
|
||||
}
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -181,7 +181,9 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
|
||||
try {
|
||||
Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService
|
||||
.retrieveAllProvisioningCriterias();
|
||||
if (criteriaCollection == null || criteriaCollection.size() == 0) { throw new NoProvisioningCriteriaDefinitionFound(); }
|
||||
if (criteriaCollection == null || criteriaCollection.size() == 0) {
|
||||
throw new NoProvisioningCriteriaDefinitionFound();
|
||||
}
|
||||
ProvisioningEntry requestedEntry = createProvsioningEntry(createdDate, addJournalEntries);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(requestedEntry.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
|
||||
+3
-1
@@ -43,7 +43,9 @@ public class AccountingRuleInvalidException extends AbstractPlatformDomainRuleEx
|
||||
public String errorCode() {
|
||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
return "error.msg.glclosure.invalid.future.date";
|
||||
} else if (name().toString().equalsIgnoreCase("ACCOUNTING_CLOSED")) { return "error.msg.glclosure.invalid.accounting.closed"; }
|
||||
} else if (name().toString().equalsIgnoreCase("ACCOUNTING_CLOSED")) {
|
||||
return "error.msg.glclosure.invalid.accounting.closed";
|
||||
}
|
||||
return name().toString();
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -53,7 +53,9 @@ public class AccountingRuleCommandFromApiJsonDeserializer {
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -141,7 +143,9 @@ public class AccountingRuleCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public void validateCreditOrDebitTagArray(final String[] creditOrDebitTagArray, final DataValidatorBuilder baseDataValidator,
|
||||
@@ -155,7 +159,9 @@ public class AccountingRuleCommandFromApiJsonDeserializer {
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+3
-1
@@ -179,7 +179,9 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
||||
final Map<Long, AccountingRuleData> extractedData = this.jdbcTemplate.query(sql, resultSetExtractor,
|
||||
new Object[] { accountingRuleId });
|
||||
final AccountingRuleData accountingRuleData = extractedData.get(accountingRuleId);
|
||||
if (accountingRuleData == null) { throw new AccountingRuleNotFoundException(accountingRuleId); }
|
||||
if (accountingRuleData == null) {
|
||||
throw new AccountingRuleNotFoundException(accountingRuleId);
|
||||
}
|
||||
return accountingRuleData;
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new AccountingRuleNotFoundException(accountingRuleId);
|
||||
|
||||
+3
-1
@@ -87,7 +87,9 @@ public class AccountingRuleWritePlatformServiceJpaRepositoryImpl implements Acco
|
||||
final Throwable realCause = dve.getMostSpecificCause();
|
||||
if (realCause.getMessage().contains("accounting_rule_name_unique")) {
|
||||
throw new AccountingRuleDuplicateException(command.stringValueOfParameterNamed(AccountingRuleJsonInputParams.NAME.getValue()));
|
||||
} else if (realCause.getMessage().contains("UNIQUE_ACCOUNT_RULE_TAGS")) { throw new AccountingRuleDuplicateException(); }
|
||||
} else if (realCause.getMessage().contains("UNIQUE_ACCOUNT_RULE_TAGS")) {
|
||||
throw new AccountingRuleDuplicateException();
|
||||
}
|
||||
|
||||
LOG.error("Error occured.", dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.accounting.rule.unknown.data.integrity.issue",
|
||||
|
||||
+9
-3
@@ -54,7 +54,9 @@ public final class AdHocDataValidator {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -94,7 +96,9 @@ public final class AdHocDataValidator {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -147,6 +151,8 @@ public final class AdHocDataValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-8
@@ -78,7 +78,9 @@ public class CommandContext {
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean matcher(CommandContext other) {
|
||||
if (this.resource.matches(other.resource) && this.method.equals(other.method)) { return true; }
|
||||
if (this.resource.matches(other.resource) && this.method.equals(other.method)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -93,16 +95,30 @@ public class CommandContext {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) { return true; }
|
||||
if (obj == null) { return false; }
|
||||
if (!(obj instanceof CommandContext)) { return false; }
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof CommandContext)) {
|
||||
return false;
|
||||
}
|
||||
CommandContext other = (CommandContext) obj;
|
||||
if (this.method == null) {
|
||||
if (other.method != null) { return false; }
|
||||
} else if (!this.method.equals(other.method)) { return false; }
|
||||
if (other.method != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.method.equals(other.method)) {
|
||||
return false;
|
||||
}
|
||||
if (this.resource == null) {
|
||||
if (other.resource != null) { return false; }
|
||||
} else if (!this.resource.equals(other.resource)) { return false; }
|
||||
if (other.resource != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.resource.equals(other.resource)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -203,7 +203,9 @@ public class CommandSource extends AbstractPersistableCustom {
|
||||
}
|
||||
|
||||
public boolean isMarkedAsAwaitingApproval() {
|
||||
if (this.processingResult.equals(CommandProcessingResultType.AWAITING_APPROVAL.getValue())) { return true; }
|
||||
if (this.processingResult.equals(CommandProcessingResultType.AWAITING_APPROVAL.getValue())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-1
@@ -76,7 +76,9 @@ public class CommandHandlerProvider implements ApplicationContextAware {
|
||||
Preconditions.checkArgument(StringUtils.isNoneEmpty(action), "An action must be given!");
|
||||
|
||||
final String key = entity + "|" + action;
|
||||
if (!this.registeredHandlers.containsKey(key)) { throw new UnsupportedCommandException(key); }
|
||||
if (!this.registeredHandlers.containsKey(key)) {
|
||||
throw new UnsupportedCommandException(key);
|
||||
}
|
||||
return (NewCommandSourceHandler) this.applicationContext.getBean(this.registeredHandlers.get(key));
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -168,7 +168,9 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
|
||||
final CommandSource commandSourceInput = this.commandSourceRepository.findById(makerCheckerId)
|
||||
.orElseThrow(() -> new CommandNotFoundException(makerCheckerId));
|
||||
if (!commandSourceInput.isMarkedAsAwaitingApproval()) { throw new CommandNotAwaitingApprovalException(makerCheckerId); }
|
||||
if (!commandSourceInput.isMarkedAsAwaitingApproval()) {
|
||||
throw new CommandNotAwaitingApprovalException(makerCheckerId);
|
||||
}
|
||||
|
||||
this.context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||
|
||||
|
||||
+6
-2
@@ -57,7 +57,9 @@ public class AccountNumberFormatDataValidator {
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ACCOUNT_NUMBER_FORMAT_CREATE_REQUEST_DATA_PARAMETERS);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
@@ -137,7 +139,9 @@ public class AccountNumberFormatDataValidator {
|
||||
|
||||
public void validateForUpdate(final String json, EntityAccountType entityAccountType) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, ACCOUNT_NUMBER_FORMAT_UPDATE_REQUEST_DATA_PARAMETERS);
|
||||
|
||||
+3
-1
@@ -81,7 +81,9 @@ public class BulkImportApiResource {
|
||||
}
|
||||
} else {
|
||||
final GlobalEntityType type = GlobalEntityType.fromCode(entityType);
|
||||
if (type == null) { throw new ImportTypeNotFoundException(entityType); }
|
||||
if (type == null) {
|
||||
throw new ImportTypeNotFoundException(entityType);
|
||||
}
|
||||
importData = this.bulkImportWorkbookService.getImports(type);
|
||||
}
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
+3
-1
@@ -37,7 +37,9 @@ public enum ImportFormatType {
|
||||
|
||||
public static ImportFormatType of(String name) {
|
||||
for (ImportFormatType type : ImportFormatType.values()) {
|
||||
if (type.name().equalsIgnoreCase(name)) { return type; }
|
||||
if (type.name().equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new GeneralPlatformDomainRuleException("error.msg.invalid.file.extension", "Uploaded file extension is not recognized.");
|
||||
}
|
||||
|
||||
+18
-6
@@ -64,7 +64,9 @@ public class ImportHandlerUtils {
|
||||
|
||||
public static Long readAsLong(int colIndex, Row row) {
|
||||
Cell c = row.getCell(colIndex);
|
||||
if (c == null || c.getCellType() == CellType.BLANK) { return null; }
|
||||
if (c == null || c.getCellType() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (eval != null) {
|
||||
@@ -87,7 +89,9 @@ public class ImportHandlerUtils {
|
||||
public static String readAsString(int colIndex, Row row) {
|
||||
|
||||
Cell c = row.getCell(colIndex);
|
||||
if (c == null || c.getCellType() == CellType.BLANK) { return null; }
|
||||
if (c == null || c.getCellType() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (eval != null) {
|
||||
@@ -134,7 +138,9 @@ public class ImportHandlerUtils {
|
||||
|
||||
public static LocalDate readAsDate(int colIndex, Row row) {
|
||||
Cell c = row.getCell(colIndex);
|
||||
if (c == null || c.getCellType() == CellType.BLANK) { return null; }
|
||||
if (c == null || c.getCellType() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalDate localDate = new LocalDate(c.getDateCellValue());
|
||||
return localDate;
|
||||
@@ -142,7 +148,9 @@ public class ImportHandlerUtils {
|
||||
|
||||
public static Boolean readAsBoolean(int colIndex, Row row) {
|
||||
Cell c = row.getCell(colIndex);
|
||||
if (c == null || c.getCellType() == CellType.BLANK) { return false; }
|
||||
if (c == null || c.getCellType() == CellType.BLANK) {
|
||||
return false;
|
||||
}
|
||||
FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (eval != null) {
|
||||
@@ -169,7 +177,9 @@ public class ImportHandlerUtils {
|
||||
|
||||
public static Integer readAsInt(int colIndex, Row row) {
|
||||
Cell c = row.getCell(colIndex);
|
||||
if (c == null || c.getCellType() == CellType.BLANK) { return null; }
|
||||
if (c == null || c.getCellType() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (eval != null) {
|
||||
@@ -191,7 +201,9 @@ public class ImportHandlerUtils {
|
||||
|
||||
public static Double readAsDouble(int colIndex, Row row) {
|
||||
Cell c = row.getCell(colIndex);
|
||||
if (c == null || c.getCellType() == CellType.BLANK) { return 0.0; }
|
||||
if (c == null || c.getCellType() == CellType.BLANK) {
|
||||
return 0.0;
|
||||
}
|
||||
FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (eval != null) {
|
||||
|
||||
+9
-3
@@ -129,7 +129,9 @@ public class CenterImportHandler implements ImportHandler {
|
||||
activationDate = submittedOn;
|
||||
}
|
||||
String centerName = ImportHandlerUtils.readAsString(CenterConstants.CENTER_NAME_COL, row);
|
||||
if (centerName == null || centerName.equals("")) { throw new IllegalArgumentException("Name is blank"); }
|
||||
if (centerName == null || centerName.equals("")) {
|
||||
throw new IllegalArgumentException("Name is blank");
|
||||
}
|
||||
List<GroupGeneralData> groupMembers = new ArrayList<GroupGeneralData>();
|
||||
for (int cellNo = CenterConstants.GROUP_NAMES_STARTING_COL; cellNo < CenterConstants.GROUP_NAMES_ENDING_COL; cellNo++) {
|
||||
String groupName = ImportHandlerUtils.readAsString(cellNo, row);
|
||||
@@ -150,7 +152,9 @@ public class CenterImportHandler implements ImportHandler {
|
||||
|
||||
private boolean containsGroupId(List<GroupGeneralData> groupMembers, Long groupId) {
|
||||
for (GroupGeneralData group : groupMembers) {
|
||||
if (group.getId().equals(groupId)) { return true; }
|
||||
if (group.getId().equals(groupId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -218,7 +222,9 @@ public class CenterImportHandler implements ImportHandler {
|
||||
|
||||
if (status == null || status.equals(TemplatePopulateImportConstants.STATUS_CREATION_FAILED)) {
|
||||
return 0;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_MEETING_FAILED)) { return 1; }
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_MEETING_FAILED)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -413,7 +413,9 @@ public class FixedDepositImportHandler implements ImportHandler {
|
||||
return 0;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_APPROVAL_FAILED)) {
|
||||
return 1;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_ACTIVATION_FAILED)) { return 2; }
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_ACTIVATION_FAILED)) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -132,7 +132,9 @@ public class GroupImportHandler implements ImportHandler {
|
||||
activationDate = submittedOnDate;
|
||||
}
|
||||
String groupName = ImportHandlerUtils.readAsString(GroupConstants.NAME_COL, row);
|
||||
if (groupName == null || groupName.equals("")) { throw new IllegalArgumentException("Name is blank"); }
|
||||
if (groupName == null || groupName.equals("")) {
|
||||
throw new IllegalArgumentException("Name is blank");
|
||||
}
|
||||
List<ClientData> clientMembers = new ArrayList<>();
|
||||
for (int cellNo = GroupConstants.CLIENT_NAMES_STARTING_COL; cellNo < GroupConstants.CLIENT_NAMES_ENDING_COL; cellNo++) {
|
||||
String clientName = ImportHandlerUtils.readAsString(cellNo, row);
|
||||
@@ -153,7 +155,9 @@ public class GroupImportHandler implements ImportHandler {
|
||||
|
||||
private boolean containsClientId(List<ClientData> clientMembers, Long clientId) {
|
||||
for (ClientData client : clientMembers) {
|
||||
if (client.getId().equals(clientId)) { return true; }
|
||||
if (client.getId().equals(clientId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -262,7 +266,9 @@ public class GroupImportHandler implements ImportHandler {
|
||||
private int getProgressLevel(String status) {
|
||||
if (status == null || status.equals(TemplatePopulateImportConstants.STATUS_CREATION_FAILED)) {
|
||||
return 0;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_MEETING_FAILED)) { return 1; }
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_MEETING_FAILED)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -132,7 +132,9 @@ public class LoanImportHandler implements ImportHandler {
|
||||
|
||||
private LoanApprovalData readLoanApproval(Row row, String locale, String dateFormat) {
|
||||
LocalDate approvedDate = ImportHandlerUtils.readAsDate(LoanConstants.APPROVED_DATE_COL, row);
|
||||
if (approvedDate != null) { return LoanApprovalData.importInstance(approvedDate, row.getRowNum(), locale, dateFormat); }
|
||||
if (approvedDate != null) {
|
||||
return LoanApprovalData.importInstance(approvedDate, row.getRowNum(), locale, dateFormat);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -503,7 +505,9 @@ public class LoanImportHandler implements ImportHandler {
|
||||
return 1;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_DISBURSAL_FAILED)) {
|
||||
return 2;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_DISBURSAL_REPAYMENT_FAILED)) { return 3; }
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_DISBURSAL_REPAYMENT_FAILED)) {
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -392,7 +392,9 @@ public class RecurringDepositImportHandler implements ImportHandler {
|
||||
return 0;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_APPROVAL_FAILED)) {
|
||||
return 1;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_ACTIVATION_FAILED)) { return 2; }
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_ACTIVATION_FAILED)) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -387,7 +387,9 @@ public class SavingsImportHandler implements ImportHandler {
|
||||
return 0;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_APPROVAL_FAILED)) {
|
||||
return 1;
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_ACTIVATION_FAILED)) { return 2; }
|
||||
} else if (status.equals(TemplatePopulateImportConstants.STATUS_ACTIVATION_FAILED)) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -34,11 +34,17 @@ public class LoanComparatorByStatusActive implements Comparator<LoanAccountData>
|
||||
boolean isData2StatusActive = o2.getStatusStringValue().equals("Active");
|
||||
|
||||
// if both status active, these have the same rank
|
||||
if (isData1StatusActive && isData2StatusActive) { return 0; }
|
||||
if (isData1StatusActive && isData2StatusActive) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isData1StatusActive) { return -1; }
|
||||
if (isData1StatusActive) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (isData2StatusActive) { return 1; }
|
||||
if (isData2StatusActive) {
|
||||
return 1;
|
||||
}
|
||||
// if no status active, these have the same rank
|
||||
return 0;
|
||||
}
|
||||
|
||||
+6
-2
@@ -61,7 +61,9 @@ public class UpdateCacheCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
final String json = command.json();
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
command.checkForUnsupportedParameters(typeOfMap, json, REQUEST_DATA_PARAMETERS);
|
||||
@@ -74,7 +76,9 @@ public class UpdateCacheCommandHandler implements NewCommandSourceHandler {
|
||||
baseDataValidator.reset().parameter(CacheApiConstants.cacheTypeParameter).value(Integer.valueOf(cacheTypeEnum)).notNull()
|
||||
.isOneOfTheseValues(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
|
||||
final CacheType cacheType = CacheType.fromInt(cacheTypeEnum);
|
||||
|
||||
|
||||
+6
-2
@@ -77,8 +77,12 @@ public class EmailBusinessRulesData {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) { return true; }
|
||||
if (o == null || !(o instanceof EmailBusinessRulesData)) { return false; }
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || !(o instanceof EmailBusinessRulesData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EmailBusinessRulesData that = (EmailBusinessRulesData) o;
|
||||
|
||||
|
||||
+21
-7
@@ -86,7 +86,9 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateCreate(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.supportedParams);
|
||||
@@ -137,7 +139,9 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateForUpdate(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.supportedParamsForUpdate);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
@@ -177,7 +181,9 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
public void validatePreviewMessage(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.PREVIEW_REQUEST_DATA_PARAMETERS);
|
||||
|
||||
@@ -198,7 +204,9 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateClosedDate(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.CLOSE_REQUEST_DATA_PARAMETERS);
|
||||
@@ -216,7 +224,9 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateActivation(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.ACTIVATION_REQUEST_DATA_PARAMETERS);
|
||||
@@ -235,7 +245,9 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateClosure(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.CLOSE_REQUEST_DATA_PARAMETERS);
|
||||
@@ -253,6 +265,8 @@ public class EmailCampaignValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-4
@@ -57,7 +57,9 @@ public class EmailConfigurationValidator {
|
||||
|
||||
public void validateUpdateConfiguration(String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailConfigurationValidator.supportedParams);
|
||||
@@ -85,20 +87,26 @@ public class EmailConfigurationValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidEmail(String email) {
|
||||
// this is the easiest check
|
||||
if (email == null) {
|
||||
return false;
|
||||
} else if (email.endsWith(".")) { return false; }
|
||||
} else if (email.endsWith(".")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the whole email address structure
|
||||
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
|
||||
|
||||
// check if the Matcher matches the email pattern
|
||||
if (!emailMatcher.matches()) { return false; }
|
||||
if (!emailMatcher.matches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+18
-6
@@ -69,7 +69,9 @@ public final class EmailDataValidator {
|
||||
final String jsonString = jsonCommand.json();
|
||||
final JsonElement jsonElement = jsonCommand.parsedJson();
|
||||
|
||||
if (StringUtils.isBlank(jsonString)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(jsonString)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeToken = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeToken, jsonString, ScheduledEmailConstants.CREATE_REQUEST_PARAMETERS);
|
||||
@@ -150,7 +152,9 @@ public final class EmailDataValidator {
|
||||
final String jsonString = jsonCommand.json();
|
||||
final JsonElement jsonElement = jsonCommand.parsedJson();
|
||||
|
||||
if (StringUtils.isBlank(jsonString)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(jsonString)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeToken = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeToken, jsonString, ScheduledEmailConstants.UPDATE_REQUEST_PARAMETERS);
|
||||
@@ -245,16 +249,22 @@ public final class EmailDataValidator {
|
||||
**/
|
||||
public boolean isValidEmail(String email) {
|
||||
// this is the easiest check
|
||||
if (email == null) { return false; }
|
||||
if (email == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// this is another easy check
|
||||
if (email.endsWith(".")) { return false; }
|
||||
if (email.endsWith(".")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the whole email address structure
|
||||
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
|
||||
|
||||
// check if the Matcher matches the email pattern
|
||||
if (!emailMatcher.matches()) { return false; }
|
||||
if (!emailMatcher.matches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -309,6 +319,8 @@ public final class EmailDataValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -365,19 +365,25 @@ public class EmailCampaign extends AbstractPersistableCustom {
|
||||
private void validate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
validateActivationDate(dataValidationErrors);
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateReactivate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
validateReactivationDate(dataValidationErrors);
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateClosureDate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
validateClosureDate(dataValidationErrors);
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateActivationDate(final List<ApiParameterError> dataValidationErrors) {
|
||||
|
||||
+6
-2
@@ -186,7 +186,9 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findById(resourceId)
|
||||
.orElseThrow(() -> new EmailCampaignNotFound(resourceId));
|
||||
|
||||
if (emailCampaign.isActive()) { throw new EmailCampaignMustBeClosedToEditException(emailCampaign.getId()); }
|
||||
if (emailCampaign.isActive()) {
|
||||
throw new EmailCampaignMustBeClosedToEditException(emailCampaign.getId());
|
||||
}
|
||||
final Map<String, Object> changes = emailCampaign.update(command);
|
||||
|
||||
if (changes.containsKey(EmailCampaignValidator.businessRuleId)) {
|
||||
@@ -218,7 +220,9 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findById(resourceId)
|
||||
.orElseThrow(() -> new EmailCampaignNotFound(resourceId));
|
||||
|
||||
if (emailCampaign.isActive()) { throw new EmailCampaignMustBeClosedToBeDeletedException(emailCampaign.getId()); }
|
||||
if (emailCampaign.isActive()) {
|
||||
throw new EmailCampaignMustBeClosedToBeDeletedException(emailCampaign.getId());
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not delete but set a boolean is_visible to zero
|
||||
|
||||
+9
-3
@@ -75,12 +75,18 @@ public class SmsBusinessRulesData {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) { return true; }
|
||||
if (o == null || !(o instanceof SmsBusinessRulesData)) { return false; }
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || !(o instanceof SmsBusinessRulesData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SmsBusinessRulesData that = (SmsBusinessRulesData) o;
|
||||
|
||||
if (reportId != null ? !reportId.equals(that.reportId) : that.reportId != null) { return false; }
|
||||
if (reportId != null ? !reportId.equals(that.reportId) : that.reportId != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+9
-3
@@ -375,19 +375,25 @@ public class SmsCampaign extends AbstractPersistableCustom {
|
||||
private void validate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
validateActivationDate(dataValidationErrors);
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateReactivate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
validateReactivationDate(dataValidationErrors);
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateClosureDate() {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
validateClosureDate(dataValidationErrors);
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateActivationDate(final List<ApiParameterError> dataValidationErrors) {
|
||||
|
||||
+21
-7
@@ -98,7 +98,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateCreate(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SmsCampaignValidator.supportedParams);
|
||||
@@ -171,7 +173,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateForUpdate(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SmsCampaignValidator.supportedParamsForUpdate);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
@@ -231,7 +235,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
public void validatePreviewMessage(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SmsCampaignValidator.PREVIEW_REQUEST_DATA_PARAMETERS);
|
||||
|
||||
@@ -257,7 +263,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateClosedDate(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SmsCampaignValidator.CLOSE_REQUEST_DATA_PARAMETERS);
|
||||
@@ -275,7 +283,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateActivation(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SmsCampaignValidator.ACTIVATION_REQUEST_DATA_PARAMETERS);
|
||||
@@ -294,7 +304,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
public void validateClosure(String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SmsCampaignValidator.CLOSE_REQUEST_DATA_PARAMETERS);
|
||||
@@ -312,7 +324,9 @@ public class SmsCampaignValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidNotificationOrSms(Client client, SmsCampaign smsCampaign, Object mobileNo) {
|
||||
|
||||
+9
-3
@@ -165,7 +165,9 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
|
||||
final SmsCampaign smsCampaign = this.smsCampaignRepository.findById(resourceId)
|
||||
.orElseThrow(() -> new SmsCampaignNotFound(resourceId));
|
||||
|
||||
if (smsCampaign.isActive()) { throw new SmsCampaignMustBeClosedToEditException(smsCampaign.getId()); }
|
||||
if (smsCampaign.isActive()) {
|
||||
throw new SmsCampaignMustBeClosedToEditException(smsCampaign.getId());
|
||||
}
|
||||
final Map<String, Object> changes = smsCampaign.update(command);
|
||||
|
||||
if (changes.containsKey(SmsCampaignValidator.runReportId)) {
|
||||
@@ -196,7 +198,9 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
|
||||
final SmsCampaign smsCampaign = this.smsCampaignRepository.findById(resourceId)
|
||||
.orElseThrow(() -> new SmsCampaignNotFound(resourceId));
|
||||
|
||||
if (smsCampaign.isActive()) { throw new SmsCampaignMustBeClosedToBeDeletedException(smsCampaign.getId()); }
|
||||
if (smsCampaign.isActive()) {
|
||||
throw new SmsCampaignMustBeClosedToBeDeletedException(smsCampaign.getId());
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not delete but set a boolean is_visible to zero
|
||||
@@ -250,7 +254,9 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
|
||||
@Override
|
||||
public void insertDirectCampaignIntoSmsOutboundTable(final Loan loan, final SmsCampaign smsCampaign) {
|
||||
try {
|
||||
if (loan.hasInvalidLoanType()) { throw new InvalidLoanTypeException("Loan Type cannot be 0 for the Triggered Sms Campaign"); }
|
||||
if (loan.hasInvalidLoanType()) {
|
||||
throw new InvalidLoanTypeException("Loan Type cannot be 0 for the Triggered Sms Campaign");
|
||||
}
|
||||
|
||||
Set<Client> clientSet = new HashSet<>();
|
||||
|
||||
|
||||
+3
-1
@@ -74,7 +74,9 @@ public class Code extends AbstractPersistableCustom {
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
|
||||
if (this.systemDefined) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
if (this.systemDefined) {
|
||||
throw new SystemDefinedCodeCannotBeChangedException();
|
||||
}
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<>(1);
|
||||
|
||||
|
||||
+6
-2
@@ -51,13 +51,17 @@ public class CodeValueRepositoryWrapper {
|
||||
|
||||
public CodeValue findOneByCodeNameAndIdWithNotFoundDetection(final String codeName, final Long id) {
|
||||
final CodeValue codeValue = this.repository.findByCodeNameAndId(codeName, id);
|
||||
if (codeValue == null) { throw new CodeValueNotFoundException(codeName, id); }
|
||||
if (codeValue == null) {
|
||||
throw new CodeValueNotFoundException(codeName, id);
|
||||
}
|
||||
return codeValue;
|
||||
}
|
||||
|
||||
public CodeValue findOneByCodeNameAndLabelWithNotFoundDetection(final String codeName, final String label) {
|
||||
final CodeValue codeValue = this.repository.findByCodeNameAndLabel(codeName, label);
|
||||
if (codeValue == null) { throw new CodeValueNotFoundException(codeName, label); }
|
||||
if (codeValue == null) {
|
||||
throw new CodeValueNotFoundException(codeName, label);
|
||||
}
|
||||
return codeValue;
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -54,7 +54,9 @@ public final class CodeCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -71,7 +73,9 @@ public final class CodeCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+6
-2
@@ -53,7 +53,9 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -86,7 +88,9 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+3
-1
@@ -120,7 +120,9 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final Code code = retrieveCodeBy(codeId);
|
||||
if (code.isSystemDefined()) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
if (code.isSystemDefined()) {
|
||||
throw new SystemDefinedCodeCannotBeChangedException();
|
||||
}
|
||||
|
||||
try {
|
||||
this.codeRepository.delete(code);
|
||||
|
||||
+6
-2
@@ -54,7 +54,9 @@ public class GlobalConfigurationDataValidator {
|
||||
|
||||
public void validateForUpdate(final JsonCommand command) {
|
||||
final String json = command.json();
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, UPDATE_CONFIGURATION_DATA_PARAMETERS);
|
||||
@@ -79,7 +81,9 @@ public class GlobalConfigurationDataValidator {
|
||||
baseDataValidator.reset().parameter(GlobalConfigurationApiConstant.DATE_VALUE).value(dateValue).notNull();
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+24
-8
@@ -52,10 +52,14 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
|
||||
@Override
|
||||
public boolean isMakerCheckerEnabledForTask(final String taskPermissionCode) {
|
||||
if (StringUtils.isBlank(taskPermissionCode)) { throw new PermissionNotFoundException(taskPermissionCode); }
|
||||
if (StringUtils.isBlank(taskPermissionCode)) {
|
||||
throw new PermissionNotFoundException(taskPermissionCode);
|
||||
}
|
||||
|
||||
final Permission thisTask = this.permissionRepository.findOneByCode(taskPermissionCode);
|
||||
if (thisTask == null) { throw new PermissionNotFoundException(taskPermissionCode); }
|
||||
if (thisTask == null) {
|
||||
throw new PermissionNotFoundException(taskPermissionCode);
|
||||
}
|
||||
|
||||
final String makerCheckerConfigurationProperty = "maker-checker";
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(makerCheckerConfigurationProperty);
|
||||
@@ -168,7 +172,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
public Integer retrieveFinancialYearBeginningMonth() {
|
||||
final String propertyName = "financial-year-beginning-month";
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
|
||||
if (property.isEnabled()) { return property.getValue().intValue(); }
|
||||
if (property.isEnabled()) {
|
||||
return property.getValue().intValue();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -176,7 +182,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
public Integer retrieveMinAllowedClientsInGroup() {
|
||||
final String propertyName = "min-clients-in-group";
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
|
||||
if (property.isEnabled()) { return property.getValue().intValue(); }
|
||||
if (property.isEnabled()) {
|
||||
return property.getValue().intValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -184,7 +192,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
public Integer retrieveMaxAllowedClientsInGroup() {
|
||||
final String propertyName = "max-clients-in-group";
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
|
||||
if (property.isEnabled()) { return property.getValue().intValue(); }
|
||||
if (property.isEnabled()) {
|
||||
return property.getValue().intValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -202,7 +212,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
|
||||
if (property.isEnabled()) {
|
||||
int value = property.getValue().intValue();
|
||||
if (value < 0 || value > 6) { return defaultValue; }
|
||||
if (value < 0 || value > 6) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return defaultValue;
|
||||
@@ -304,7 +316,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
|
||||
int defaultValue = 6;
|
||||
int value = property.getValue().intValue();
|
||||
if (value < 1) { return defaultValue; }
|
||||
if (value < 1) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -314,7 +328,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
|
||||
int defaultValue = 300;
|
||||
int value = property.getValue().intValue();
|
||||
if (value < 1) { return defaultValue; }
|
||||
if (value < 1) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -52,9 +52,15 @@ public class ExternalServicePropertiesPK implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) { return false; }
|
||||
if (obj == this) { return true; }
|
||||
if (!(obj instanceof ExternalServicePropertiesPK)) { return false; }
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ExternalServicePropertiesPK)) {
|
||||
return false;
|
||||
}
|
||||
final ExternalServicePropertiesPK rhs = (ExternalServicePropertiesPK) obj;
|
||||
return new EqualsBuilder() //
|
||||
.append(this.externalServiceId, rhs.externalServiceId) //
|
||||
|
||||
+3
-1
@@ -34,7 +34,9 @@ public class ExternalServicesPropertiesRepositoryWrapper {
|
||||
|
||||
public ExternalServicesProperties findOneByIdAndName(Long id, String name, String externalServiceName) {
|
||||
final ExternalServicesProperties externalServicesProperties = this.repository.findOneByExternalServicePropertiesPK(name, id);
|
||||
if (externalServicesProperties == null) { throw new ExternalServiceConfigurationNotFoundException(externalServiceName, name); }
|
||||
if (externalServicesProperties == null) {
|
||||
throw new ExternalServiceConfigurationNotFoundException(externalServiceName, name);
|
||||
}
|
||||
return externalServicesProperties;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -87,7 +87,9 @@ public class GlobalConfigurationProperty extends AbstractPersistableCustom {
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<>(7);
|
||||
|
||||
if (this.isTrapDoor == true) { throw new GlobalConfigurationPropertyCannotBeModfied(this.getId()); }
|
||||
if (this.isTrapDoor == true) {
|
||||
throw new GlobalConfigurationPropertyCannotBeModfied(this.getId());
|
||||
}
|
||||
|
||||
final String enabledParamName = "enabled";
|
||||
if (command.isChangeInBooleanParameterNamed(enabledParamName, this.enabled)) {
|
||||
|
||||
+3
-1
@@ -40,7 +40,9 @@ public class GlobalConfigurationRepositoryWrapper {
|
||||
|
||||
public GlobalConfigurationProperty findOneByNameWithNotFoundDetection(final String propertyName) {
|
||||
final GlobalConfigurationProperty property = this.repository.findOneByName(propertyName);
|
||||
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(propertyName); }
|
||||
if (property == null) {
|
||||
throw new GlobalConfigurationPropertyNotFoundException(propertyName);
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -48,7 +48,9 @@ public class ExternalServicesPropertiesCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json, final String externalServiceName) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
switch (externalServiceName) {
|
||||
|
||||
+3
-1
@@ -55,7 +55,9 @@ public final class GlobalConfigurationCommandFromApiJsonDeserializer
|
||||
@Override
|
||||
public UpdateGlobalConfigurationCommand commandFromApiJson(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+3
-1
@@ -39,7 +39,9 @@ public class DateAdapter implements JsonSerializer<Date> {
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
if (src == null) { return null; }
|
||||
if (src == null) {
|
||||
return null;
|
||||
}
|
||||
return new JsonPrimitive(formatter.format(src.toInstant()));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -191,7 +191,9 @@ public final class JsonCommand {
|
||||
}
|
||||
|
||||
public JsonElement jsonElement(final String paramName) {
|
||||
if (this.parsedCommand.getAsJsonObject().has(paramName)) { return this.parsedCommand.getAsJsonObject().get(paramName); }
|
||||
if (this.parsedCommand.getAsJsonObject().has(paramName)) {
|
||||
return this.parsedCommand.getAsJsonObject().get(paramName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -412,7 +414,9 @@ public final class JsonCommand {
|
||||
|
||||
public Date dateValueOfParameterNamed(final String parameterName) {
|
||||
final LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand);
|
||||
if (localDate == null) { return null; }
|
||||
if (localDate == null) {
|
||||
return null;
|
||||
}
|
||||
return localDate.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
|
||||
+117
-39
@@ -90,7 +90,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder andNotBlank(final String linkedParameterName, final String linkedValue) {
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(linkedValue)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
@@ -122,7 +124,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder equalToParameter(final String linkedParameterName, final Object linkedValue) {
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && !this.value.equals(linkedValue)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
@@ -137,7 +141,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notSameAsParameter(final String linkedParameterName, final Object linkedValue) {
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && linkedValue == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && this.value.equals(linkedValue)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
@@ -210,7 +216,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notBlank() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value == null || StringUtils.isBlank(this.value.toString())) {
|
||||
String realParameterName = this.parameter;
|
||||
@@ -233,7 +241,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notExceedingLengthOf(final Integer maxLength) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && this.value.toString().trim().length() > maxLength) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
@@ -248,7 +258,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder inMinMaxRange(final Integer min, final Integer max) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
@@ -266,7 +278,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isOneOfTheseValues(final Object... values) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final List<Object> valuesList = Arrays.asList(values);
|
||||
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
@@ -287,7 +301,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isOneOfTheseStringValues(final Object... values) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final List<Object> valuesList = Arrays.asList(values);
|
||||
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
@@ -308,7 +324,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isOneOfTheseStringValues(final List<String> valuesList) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||
|
||||
@@ -328,7 +346,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isNotOneOfTheseValues(final Object... values) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final List<Object> valuesList = Arrays.asList(values);
|
||||
@@ -350,7 +370,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder positiveAmount() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final BigDecimal number = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
@@ -371,7 +393,9 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder zeroOrPositiveAmount() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final BigDecimal number = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||
@@ -392,7 +416,9 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder integerZeroOrGreater() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
@@ -413,7 +439,9 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder integerGreaterThanZero() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
@@ -431,7 +459,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder integerGreaterThanNumber(Integer number) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer intValue = Integer.valueOf(this.value.toString());
|
||||
@@ -449,7 +479,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder integerEqualToOrGreaterThanNumber(Integer number) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer intValue = Integer.valueOf(this.value.toString());
|
||||
@@ -467,7 +499,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder integerSameAsNumber(Integer number) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer intValue = Integer.valueOf(this.value.toString());
|
||||
@@ -485,7 +519,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder integerInMultiplesOfNumber(Integer number) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Integer intValue = Integer.valueOf(this.value.toString());
|
||||
@@ -506,7 +542,9 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder longGreaterThanZero() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Long number = Long.valueOf(this.value.toString());
|
||||
@@ -527,7 +565,9 @@ public class DataValidatorBuilder {
|
||||
* should be used with .notNull() before it
|
||||
*/
|
||||
public DataValidatorBuilder longZeroOrGreater() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Long number = Long.valueOf(this.value.toString());
|
||||
@@ -545,7 +585,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder longGreaterThanNumber(Long number) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Long longValue = Long.valueOf(this.value.toString());
|
||||
@@ -563,7 +605,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder longGreaterThanNumber(String paramName, Long number, int index) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null) {
|
||||
final Long longValue = Long.valueOf(this.value.toString());
|
||||
@@ -581,7 +625,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder arrayNotEmpty() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final Object[] array = (Object[]) this.value;
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
@@ -597,7 +643,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder jsonArrayNotEmpty() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final JsonArray array = (JsonArray) this.value;
|
||||
if (this.value != null && !array.iterator().hasNext()) {
|
||||
@@ -653,9 +701,13 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder mustBeBlankWhenParameterProvided(final String parameterName, final Object parameterValue) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value == null && parameterValue != null) { return this; }
|
||||
if (this.value == null && parameterValue != null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && StringUtils.isBlank(this.value.toString()) && parameterValue != null
|
||||
&& StringUtils.isNotBlank(parameterValue.toString())) {
|
||||
@@ -673,9 +725,13 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder mustBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value == null && parameterValue != null) { return this; }
|
||||
if (this.value == null && parameterValue != null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && StringUtils.isBlank(this.value.toString()) && parameterValue != null
|
||||
&& StringUtils.isNotBlank(parameterValue.toString())) {
|
||||
@@ -694,7 +750,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder cantBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
||||
if (this.value != null && StringUtils.isNotBlank(this.value.toString())) { return this; }
|
||||
if (this.value != null && StringUtils.isNotBlank(this.value.toString())) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
.append(this.parameter).append(".must.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
||||
@@ -811,7 +869,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notLessThanMin(final Integer min) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && min != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
@@ -829,7 +889,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notGreaterThanMax(final Integer max) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && max != null) {
|
||||
final Integer number = Integer.valueOf(this.value.toString());
|
||||
@@ -847,7 +909,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder matchesRegularExpression(final String expression) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && !this.value.toString().matches(expression)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
@@ -865,7 +929,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder matchesRegularExpression(final String expression, final String Message) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && !this.value.toString().matches(expression)) {
|
||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||
@@ -882,7 +948,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
private DataValidatorBuilder validateStringFor(final String validInputs) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
final String[] inputs = validInputs.split(VALID_INPUT_SEPERATOR);
|
||||
boolean validationErr = true;
|
||||
for (final String input : inputs) {
|
||||
@@ -908,7 +976,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder validatePhoneNumber() {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
boolean validationErr = true;
|
||||
/*
|
||||
* supports numbers, parentheses(), hyphens and may contain + sign in
|
||||
@@ -947,7 +1017,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder validateDateAfter(final LocalDate date) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && date != null) {
|
||||
final LocalDate dateVal = (LocalDate) this.value;
|
||||
@@ -965,7 +1037,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder validateDateBefore(final LocalDate date) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && date != null) {
|
||||
final LocalDate dateVal = (LocalDate) this.value;
|
||||
@@ -983,7 +1057,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder validateDateBeforeOrEqual(final LocalDate date) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && date != null) {
|
||||
final LocalDate dateVal = (LocalDate) this.value;
|
||||
@@ -1001,7 +1077,9 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
|
||||
public DataValidatorBuilder validateDateForEqual(final LocalDate date) {
|
||||
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||
if (this.value == null && this.ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.value != null && date != null) {
|
||||
final LocalDate dateVal = (LocalDate) this.value;
|
||||
|
||||
+6
-2
@@ -52,8 +52,12 @@ public class EnumOptionData implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) { return true; }
|
||||
if (!(o instanceof EnumOptionData)) { return false; }
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof EnumOptionData)) {
|
||||
return false;
|
||||
}
|
||||
EnumOptionData that = (EnumOptionData) o;
|
||||
return id.equals(that.id) && code.equals(that.code) && value.equals(that.value);
|
||||
}
|
||||
|
||||
+3
-1
@@ -55,6 +55,8 @@ public class PaginationParametersDataValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -54,7 +54,9 @@ public class MultiException extends Exception {
|
||||
|
||||
public MultiException(List<Throwable> problems) {
|
||||
super("MultiException with " + problems.size() + " contained causes (details available)");
|
||||
if (problems.isEmpty()) { throw new IllegalArgumentException("List of Throwables must not be empty"); }
|
||||
if (problems.isEmpty()) {
|
||||
throw new IllegalArgumentException("List of Throwables must not be empty");
|
||||
}
|
||||
this.throwables = new ArrayList<>(problems);
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -103,7 +103,9 @@ public class DatatableCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParametersForCreate);
|
||||
@@ -147,7 +149,9 @@ public class DatatableCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
// Because all parameters are optional, a check to see if at least one
|
||||
// parameter
|
||||
// has been specified is necessary in order to avoid JSON requests with
|
||||
|
||||
+12
-4
@@ -80,7 +80,9 @@ public class FromJsonHelper {
|
||||
}
|
||||
|
||||
public void checkForUnsupportedParameters(final Type typeOfMap, final String json, final Collection<String> supportedParams) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Map<String, Object> requestMap = this.gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
@@ -91,11 +93,15 @@ public class FromJsonHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (!unsupportedParameterList.isEmpty()) { throw new UnsupportedParameterException(unsupportedParameterList); }
|
||||
if (!unsupportedParameterList.isEmpty()) {
|
||||
throw new UnsupportedParameterException(unsupportedParameterList);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForUnsupportedParameters(final JsonObject object, final Collection<String> supportedParams) {
|
||||
if (object == null) { throw new InvalidParameterException(); }
|
||||
if (object == null) {
|
||||
throw new InvalidParameterException();
|
||||
}
|
||||
|
||||
final Set<Entry<String, JsonElement>> entries = object.entrySet();
|
||||
final List<String> unsupportedParameterList = new ArrayList<>();
|
||||
@@ -106,7 +112,9 @@ public class FromJsonHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (!unsupportedParameterList.isEmpty()) { throw new UnsupportedParameterException(unsupportedParameterList); }
|
||||
if (!unsupportedParameterList.isEmpty()) {
|
||||
throw new UnsupportedParameterException(unsupportedParameterList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-2
@@ -48,7 +48,9 @@ import org.springframework.format.number.NumberStyleFormatter;
|
||||
public class JsonParserHelper {
|
||||
|
||||
public boolean parameterExists(final String parameterName, final JsonElement element) {
|
||||
if (element == null) { return false; }
|
||||
if (element == null) {
|
||||
return false;
|
||||
}
|
||||
return element.getAsJsonObject().has(parameterName);
|
||||
}
|
||||
|
||||
@@ -544,7 +546,9 @@ public class JsonParserHelper {
|
||||
final double parsedNumberDouble = parsedNumber.doubleValue();
|
||||
final int parsedNumberInteger = parsedNumber.intValue();
|
||||
|
||||
if (source.contains(Character.toString(symbols.getDecimalSeparator()))) { throw new ParseException(source, 0); }
|
||||
if (source.contains(Character.toString(symbols.getDecimalSeparator()))) {
|
||||
throw new ParseException(source, 0);
|
||||
}
|
||||
|
||||
if (!Double.valueOf(parsedNumberDouble).equals(Double.valueOf(Integer.valueOf(parsedNumberInteger)))) {
|
||||
throw new ParseException(source, 0);
|
||||
|
||||
+3
-1
@@ -443,7 +443,9 @@ public final class SearchParameters {
|
||||
}
|
||||
|
||||
public Boolean isOrphansOnly() {
|
||||
if (this.orphansOnly != null) { return this.orphansOnly; }
|
||||
if (this.orphansOnly != null) {
|
||||
return this.orphansOnly;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -121,7 +121,9 @@ public class TenantDatabaseUpgradeService {
|
||||
|
||||
private String getEnvVar(String name, String defaultValue) {
|
||||
String value = System.getenv(name);
|
||||
if (value == null) { return defaultValue; }
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -49,7 +49,9 @@ public class CreditBureauCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json, final Long creditBureauId) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -74,7 +76,9 @@ public class CreditBureauCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+6
-2
@@ -50,7 +50,9 @@ public class CreditBureauLoanProductCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json, final Long cb_id) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -110,7 +112,9 @@ public class CreditBureauLoanProductCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
+3
-1
@@ -124,7 +124,9 @@ public class RunreportsApiResource {
|
||||
parameterTypeValue = "report";
|
||||
String reportType = this.readExtraDataAndReportingService.getReportType(reportName, isSelfServiceUserReport);
|
||||
ReportingProcessService reportingProcessService = this.reportingProcessServiceProvider.findReportingProcessService(reportType);
|
||||
if (reportingProcessService != null) { return reportingProcessService.processRequest(reportName, queryParams); }
|
||||
if (reportingProcessService != null) {
|
||||
return reportingProcessService.processRequest(reportName, queryParams);
|
||||
}
|
||||
} else {
|
||||
parameterTypeValue = "parameter";
|
||||
}
|
||||
|
||||
+3
-1
@@ -64,7 +64,9 @@ public class DataTableValidator {
|
||||
baseDataValidator.reset().parameter(DataTableApiConstant.categoryParamName).value(category).isOneOfTheseValues(objectArray);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -50,7 +50,9 @@ public class DatatableData implements Serializable {
|
||||
|
||||
for (ResultsetColumnHeaderData c : this.columnHeaderData) {
|
||||
|
||||
if (c.getColumnName().equals(columnName)) { return true; }
|
||||
if (c.getColumnName().equals(columnName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+6
-2
@@ -56,9 +56,13 @@ public class EntityDataTableChecksTemplateData implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) { return true; }
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof EntityDataTableChecksTemplateData)) { return false; }
|
||||
if (!(o instanceof EntityDataTableChecksTemplateData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityDataTableChecksTemplateData that = (EntityDataTableChecksTemplateData) o;
|
||||
|
||||
|
||||
+3
-1
@@ -70,7 +70,9 @@ public enum EntityTables {
|
||||
}
|
||||
|
||||
public static ImmutableList<Integer> getStatus(String name) {
|
||||
if (lookup.get(name) != null) { return lookup.get(name).getCodes(); }
|
||||
if (lookup.get(name) != null) {
|
||||
return lookup.get(name).getCodes();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -251,7 +251,9 @@ public final class Report extends AbstractPersistableCustom {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public String getReportName() {
|
||||
@@ -259,7 +261,9 @@ public final class Report extends AbstractPersistableCustom {
|
||||
}
|
||||
|
||||
public boolean update(final Set<ReportParameterUsage> newReportParameterUsages) {
|
||||
if (newReportParameterUsages == null) { return false; }
|
||||
if (newReportParameterUsages == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean updated = false;
|
||||
|
||||
@@ -273,7 +277,9 @@ public final class Report extends AbstractPersistableCustom {
|
||||
|
||||
private boolean changeInReportParameters(final Set<ReportParameterUsage> newReportParameterUsages) {
|
||||
|
||||
if (!this.reportParameterUsages.equals(newReportParameterUsages)) { return true; }
|
||||
if (!this.reportParameterUsages.equals(newReportParameterUsages)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-1
@@ -47,7 +47,9 @@ public final class ReportCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
public void validate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
|
||||
|
||||
+6
-2
@@ -54,7 +54,9 @@ public final class EntityDatatableChecksDataValidator {
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
@@ -89,6 +91,8 @@ public final class EntityDatatableChecksDataValidator {
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-4
@@ -99,7 +99,9 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
||||
String datatableName = command.stringValueOfParameterNamed("datatableName");
|
||||
DatatableData datatableData = this.readWriteNonCoreDataService.retrieveDatatable(datatableName);
|
||||
|
||||
if (datatableData == null) { throw new DatatableNotFoundException(datatableName); }
|
||||
if (datatableData == null) {
|
||||
throw new DatatableNotFoundException(datatableName);
|
||||
}
|
||||
|
||||
final String entity = command.stringValueOfParameterNamed("entity");
|
||||
final String foreignKeyColumnName = EntityTables.getForeignKeyColumnNameOnDatatable(entity);
|
||||
@@ -107,7 +109,9 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
||||
|
||||
LOG.info("{} has column {} ? {}", new Object[] { datatableData.getRegisteredTableName(), foreignKeyColumnName, columnExist });
|
||||
|
||||
if (!columnExist) { throw new EntityDatatableCheckNotSupportedException(datatableData.getRegisteredTableName(), entity); }
|
||||
if (!columnExist) {
|
||||
throw new EntityDatatableCheckNotSupportedException(datatableData.getRegisteredTableName(), entity);
|
||||
}
|
||||
|
||||
final Long productId = command.longValueOfParameterNamed("productId");
|
||||
final Long status = command.longValueOfParameterNamed("status");
|
||||
@@ -171,7 +175,9 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
||||
reqDatatables.add(datatableName);
|
||||
}
|
||||
}
|
||||
if (reqDatatables.size() > 0) { throw new DatatableEntryRequiredException(reqDatatables.toString()); }
|
||||
if (reqDatatables.size() > 0) {
|
||||
throw new DatatableEntryRequiredException(reqDatatables.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -197,7 +203,9 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
||||
reqDatatables.add(datatableName);
|
||||
}
|
||||
}
|
||||
if (reqDatatables.size() > 0) { throw new DatatableEntryRequiredException(reqDatatables.toString()); }
|
||||
if (reqDatatables.size() > 0) {
|
||||
throw new DatatableEntryRequiredException(reqDatatables.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -303,7 +303,9 @@ public class GenericDataServiceImpl implements GenericDataService {
|
||||
+ "'order by ORDINAL_POSITION";
|
||||
|
||||
final SqlRowSet columnDefinitions = this.jdbcTemplate.queryForRowSet(sql);
|
||||
if (columnDefinitions.next()) { return columnDefinitions; }
|
||||
if (columnDefinitions.next()) {
|
||||
return columnDefinitions;
|
||||
}
|
||||
|
||||
throw new DatatableNotFoundException(datatable);
|
||||
}
|
||||
|
||||
+12
-4
@@ -226,7 +226,9 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
// the return statement contains the exact sql required
|
||||
final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(inputSqlWrapped);
|
||||
|
||||
if (rs.next() && rs.getString("the_sql") != null) { return rs.getString("the_sql"); }
|
||||
if (rs.next() && rs.getString("the_sql") != null) {
|
||||
return rs.getString("the_sql");
|
||||
}
|
||||
throw new ReportNotFoundException(name);
|
||||
}
|
||||
|
||||
@@ -242,7 +244,9 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
|
||||
final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sqlWrapped, new Object[] { isSelfServiceUserReport });
|
||||
|
||||
if (rs.next()) { return rs.getString("report_type"); }
|
||||
if (rs.next()) {
|
||||
return rs.getString("report_type");
|
||||
}
|
||||
throw new ReportNotFoundException(reportName);
|
||||
}
|
||||
|
||||
@@ -337,7 +341,9 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
final Collection<ReportParameterJoinData> rpJoins = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
|
||||
final Collection<ReportData> reportList = new ArrayList<>();
|
||||
if (rpJoins == null || rpJoins.size() == 0) { return reportList; }
|
||||
if (rpJoins == null || rpJoins.size() == 0) {
|
||||
return reportList;
|
||||
}
|
||||
|
||||
Collection<ReportParameterData> reportParameters = null;
|
||||
|
||||
@@ -615,6 +621,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
|
||||
private void validateReportName(final String name) {
|
||||
|
||||
if (!StringUtils.isBlank(name) && !name.matches(REPORT_NAME_REGEX_PATTERN)) { throw new SQLInjectionException(); }
|
||||
if (!StringUtils.isBlank(name) && !name.matches(REPORT_NAME_REGEX_PATTERN)) {
|
||||
throw new SQLInjectionException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+66
-22
@@ -932,7 +932,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
}
|
||||
}
|
||||
|
||||
if (changeColumns == null && addColumns == null && dropColumns == null) { return; }
|
||||
if (changeColumns == null && addColumns == null && dropColumns == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dropColumns != null) {
|
||||
if (rowCount > 0) {
|
||||
@@ -1058,7 +1060,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
if (!isRegisteredDataTable(datatableName)) { throw new DatatableNotFoundException(datatableName); }
|
||||
if (!isRegisteredDataTable(datatableName)) {
|
||||
throw new DatatableNotFoundException(datatableName);
|
||||
}
|
||||
validateDatatableName(datatableName);
|
||||
assertDataTableEmpty(datatableName);
|
||||
deregisterDatatable(datatableName);
|
||||
@@ -1123,7 +1127,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
|
||||
final GenericResultsetData grs = retrieveDataTableGenericResultSetForUpdate(appTable, dataTableName, appTableId, datatableId);
|
||||
|
||||
if (grs.hasNoEntries()) { throw new DatatableNotFoundException(dataTableName, appTableId); }
|
||||
if (grs.hasNoEntries()) {
|
||||
throw new DatatableNotFoundException(dataTableName, appTableId);
|
||||
}
|
||||
|
||||
if (grs.hasMoreThanOneEntry()) {
|
||||
throw new PlatformDataIntegrityException("error.msg.attempting.multiple.update",
|
||||
@@ -1179,7 +1185,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
final String deleteOneToOneEntrySql = getDeleteEntriesSql(dataTableName, getFKField(appTable), appTableId);
|
||||
|
||||
final int rowsDeleted = this.jdbcTemplate.update(deleteOneToOneEntrySql);
|
||||
if (rowsDeleted < 1) { throw new DatatableNotFoundException(dataTableName, appTableId); }
|
||||
if (rowsDeleted < 1) {
|
||||
throw new DatatableNotFoundException(dataTableName, appTableId);
|
||||
}
|
||||
|
||||
return commandProcessingResult;
|
||||
}
|
||||
@@ -1260,7 +1268,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
LOG.info("data scoped sql: {}", sql);
|
||||
final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sql);
|
||||
|
||||
if (!rs.next()) { throw new DatatableNotFoundException(appTable, appTableId); }
|
||||
if (!rs.next()) {
|
||||
throw new DatatableNotFoundException(appTable, appTableId);
|
||||
}
|
||||
|
||||
final Long officeId = getLongSqlRowSet(rs, "officeId");
|
||||
final Long groupId = getLongSqlRowSet(rs, "groupId");
|
||||
@@ -1269,7 +1279,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
final Long LoanId = getLongSqlRowSet(rs, "loanId");
|
||||
final Long entityId = getLongSqlRowSet(rs, "entityId");
|
||||
|
||||
if (rs.next()) { throw new DatatableSystemErrorException("System Error: More than one row returned from data scoping query"); }
|
||||
if (rs.next()) {
|
||||
throw new DatatableSystemErrorException("System Error: More than one row returned from data scoping query");
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withOfficeId(officeId) //
|
||||
@@ -1352,21 +1364,39 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
|
||||
private void validateAppTable(final String appTable) {
|
||||
|
||||
if (appTable.equalsIgnoreCase("m_loan")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_savings_account")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_client")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_group")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_center")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_office")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_product_loan")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_savings_product")) { return; }
|
||||
if (appTable.equalsIgnoreCase("m_loan")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_savings_account")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_client")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_group")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_center")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_office")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_product_loan")) {
|
||||
return;
|
||||
}
|
||||
if (appTable.equalsIgnoreCase("m_savings_product")) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new PlatformDataIntegrityException("error.msg.invalid.application.table", "Invalid Application Table: " + appTable, "name",
|
||||
appTable);
|
||||
}
|
||||
|
||||
private String mapToActualAppTable(final String appTable) {
|
||||
if (appTable.equalsIgnoreCase("m_center")) { return "m_group"; }
|
||||
if (appTable.equalsIgnoreCase("m_center")) {
|
||||
return "m_group";
|
||||
}
|
||||
return appTable;
|
||||
}
|
||||
|
||||
@@ -1517,7 +1547,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
// completeness but its okay to take this risk with additional fields
|
||||
// data
|
||||
|
||||
if (changedColumns.size() == 0) { return null; }
|
||||
if (changedColumns.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String pValue = null;
|
||||
String pValueWrite = "";
|
||||
@@ -1581,7 +1613,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
if (key.equals(grs.getColumnHeaders().get(i).getColumnName())) {
|
||||
columnValue = columnValues.get(i);
|
||||
|
||||
if (notTheSame(columnValue, keyValue, colType)) { return true; }
|
||||
if (notTheSame(columnValue, keyValue, colType)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1629,7 +1663,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
}
|
||||
|
||||
}
|
||||
if (notFound) { throw new PlatformDataIntegrityException("error.msg.column.not.found", "Column: " + key + " Not Found"); }
|
||||
if (notFound) {
|
||||
throw new PlatformDataIntegrityException("error.msg.column.not.found", "Column: " + key + " Not Found");
|
||||
}
|
||||
}
|
||||
}
|
||||
return affectedColumns;
|
||||
@@ -1765,11 +1801,17 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
}
|
||||
|
||||
private boolean notTheSame(final String currValue, final String pValue, final String colType) {
|
||||
if (StringUtils.isEmpty(currValue) && StringUtils.isEmpty(pValue)) { return false; }
|
||||
if (StringUtils.isEmpty(currValue) && StringUtils.isEmpty(pValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(currValue)) { return true; }
|
||||
if (StringUtils.isEmpty(currValue)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(pValue)) { return true; }
|
||||
if (StringUtils.isEmpty(pValue)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("DECIMAL".equalsIgnoreCase(colType)) {
|
||||
final BigDecimal currentDecimal = BigDecimal.valueOf(Double.valueOf(currValue));
|
||||
@@ -1778,7 +1820,9 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
return currentDecimal.compareTo(newDecimal) != 0;
|
||||
}
|
||||
|
||||
if (currValue.equals(pValue)) { return false; }
|
||||
if (currValue.equals(pValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+6
-2
@@ -161,7 +161,9 @@ public class ReportWritePlatformServiceImpl implements ReportWritePlatformServic
|
||||
}
|
||||
|
||||
final Permission permission = this.permissionRepository.findOneByCode("READ" + "_" + report.getReportName());
|
||||
if (permission == null) { throw new PermissionNotFoundException("READ" + "_" + report.getReportName()); }
|
||||
if (permission == null) {
|
||||
throw new PermissionNotFoundException("READ" + "_" + report.getReportName());
|
||||
}
|
||||
|
||||
this.reportRepository.delete(report);
|
||||
this.permissionRepository.delete(permission);
|
||||
@@ -217,7 +219,9 @@ public class ReportWritePlatformServiceImpl implements ReportWritePlatformServic
|
||||
if (id != null) {
|
||||
// existing report parameter usage
|
||||
reportParameterUsageItem = this.reportParameterUsageRepository.findById(id).orElse(null);
|
||||
if (reportParameterUsageItem == null) { throw new ReportParameterNotFoundException(id); }
|
||||
if (reportParameterUsageItem == null) {
|
||||
throw new ReportParameterNotFoundException(id);
|
||||
}
|
||||
|
||||
// check parameter
|
||||
if (jsonObject.has("parameterId")) {
|
||||
|
||||
+6
-2
@@ -220,12 +220,16 @@ public class ImagesApiResource {
|
||||
}
|
||||
|
||||
private void validateEntityTypeforImage(final String entityName) {
|
||||
if (!checkValidEntityType(entityName)) { throw new InvalidEntityTypeForImageManagementException(entityName); }
|
||||
if (!checkValidEntityType(entityName)) {
|
||||
throw new InvalidEntityTypeForImageManagementException(entityName);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkValidEntityType(final String entityType) {
|
||||
for (final EntityTypeForImages entities : EntityTypeForImages.values()) {
|
||||
if (entities.name().equalsIgnoreCase(entityType)) { return true; }
|
||||
if (entities.name().equalsIgnoreCase(entityType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user