FINERACT-1724: Loan product creation - duplicate short name fix
This commit is contained in:
committed by
Arnold Gálovics
parent
0109d24934
commit
573b4bb998
+10
-1
@@ -328,7 +328,8 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
||||
final String name = command.stringValueOfParameterNamed("name");
|
||||
throw new PlatformDataIntegrityException("error.msg.product.loan.duplicate.name",
|
||||
"Loan product with name `" + name + "` already exists", "name", name, realCause);
|
||||
} else if (realCause.getMessage().contains("'unq_short_name'")) {
|
||||
} else if (realCause.getMessage().contains("'unq_short_name'") || containsDuplicateShortnameErrorForPostgreSQL(realCause)
|
||||
|| containsDuplicateShortnameErrorForMySQL(realCause)) {
|
||||
|
||||
final String shortName = command.stringValueOfParameterNamed("shortName");
|
||||
throw new PlatformDataIntegrityException("error.msg.product.loan.duplicate.short.name",
|
||||
@@ -343,6 +344,14 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
||||
"Unknown data integrity issue with resource.", realCause);
|
||||
}
|
||||
|
||||
private static boolean containsDuplicateShortnameErrorForPostgreSQL(Throwable realCause) {
|
||||
return realCause.getMessage().contains("m_product_loan_short_name_key");
|
||||
}
|
||||
|
||||
private static boolean containsDuplicateShortnameErrorForMySQL(Throwable realCause) {
|
||||
return (realCause.getMessage().contains("short_name") && realCause.getMessage().toLowerCase().contains("duplicate"));
|
||||
}
|
||||
|
||||
private void validateInputDates(final JsonCommand command) {
|
||||
final LocalDate startDate = command.localDateValueOfParameterNamed("startDate");
|
||||
final LocalDate closeDate = command.localDateValueOfParameterNamed("closeDate");
|
||||
|
||||
Reference in New Issue
Block a user