FINERACT-2036: Fix code quality

This commit is contained in:
Aleksandar Vidakovic
2024-01-07 19:11:13 +01:00
committed by Aleksandar Vidakovic
parent 314929e692
commit 478fb55b0f
12 changed files with 28 additions and 26 deletions
@@ -73,8 +73,8 @@ class EmailService {
if(params.bcc) {
msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(params.bcc))
}
msg.setSubject(params.subject)
msg.setText(params.message);
msg.setSubject(params.subject, "UTF-8")
msg.setText(params.message, "UTF-8");
Transport.send(msg);
@@ -27,6 +27,8 @@ import org.apache.fineract.gradle.FineractPluginExtension
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.nio.charset.Charset
class TemplateService {
private static final Logger log = LoggerFactory.getLogger(TemplateService.class)
@@ -35,7 +37,7 @@ class TemplateService {
TemplateService(FineractPluginExtension.FineractPluginConfigTemplate config) {
def dir = new File(config.templateDir);
this.config = new Configuration(Configuration.VERSION_2_3_31);
this.config = new Configuration(Configuration.VERSION_2_3_32);
this.config.setDirectoryForTemplateLoading(dir)
this.config.setDefaultEncoding("UTF-8");
this.config.setLogTemplateExceptions(false);
@@ -58,7 +60,7 @@ class TemplateService {
Template template = null;
if(params.templateFile) {
template = new Template("template", new FileReader(new File(params.templateFile)), this.config)
template = new Template("template", new FileReader(new File(params.templateFile), Charset.forName("UTF-8")), this.config)
}
if(params.template) {
template = new Template("template", new StringReader(params.template), this.config)
@@ -69,7 +71,7 @@ class TemplateService {
def output = new File(params.outputFile)
output.createNewFile()
template.process(data, new FileWriter(output, false))
template.process(data, new FileWriter(output, Charset.forName("UTF-8"), false))
} else {
def output = new StringWriter()
@@ -36,4 +36,4 @@ ${project['fineract.config.name']}
🎉 Powered by Fineract Release Plugin 🎊
🎉 Powered by Fineract Release Plugin 🎊
@@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [PROPOSAL] 📦 New release ${project['fineract.release.version']}
[FINERACT] [PROPOSAL] 📦 New release ${project['fineract.release.version']}
@@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [ANNOUNCE] 🔀 ${project['fineract.release.version']} release branch
[FINERACT] [ANNOUNCE] 🔀 ${project['fineract.release.version']} release branch
@@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [VOTE] 🗳️ ${project['fineract.release.version']} for release
[FINERACT] [VOTE] 🗳️ ${project['fineract.release.version']} for release
@@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [VOTE] [RESULT] 🧾️ ${project['fineract.release.version']} for release
[FINERACT] [VOTE] [RESULT] 🧾️ ${project['fineract.release.version']} for release
@@ -40,4 +40,4 @@ https://issues.apache.org/jira/secure/ReleaseNote.jspa?version=${project['finera
For more information on Apache Fineract please visit
project home page: https://fineract.apache.org
The Apache Fineract Team
The Apache Fineract Team
@@ -18,4 +18,4 @@
under the License.
-->
[ANNOUNCE] Apache Fineract ${project['fineract.release.version']} Release
[ANNOUNCE] Apache Fineract ${project['fineract.release.version']} Release
@@ -18,4 +18,4 @@
under the License.
-->
Fineract ${project['fineract.release.version']} release
Fineract ${project['fineract.release.version']} release
@@ -219,7 +219,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
Object columnValue = SearchUtil.parseJdbcColumnValue(column, columnValueString, null, null, null, false, sqlGenerator);
String sql = sqlGenerator.buildSelect(selectColumns, null, false) + " " + sqlGenerator.buildFrom(datatable, null, false) + " WHERE "
+ EQ.formatPlaceholder(sqlGenerator, column.getColumnName(), 1, null);
SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql, columnValue);
SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql, columnValue); // NOSONAR
List<JsonObject> results = new ArrayList<>();
while (rowSet.next()) {
@@ -279,7 +279,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
// Execute the count Query
String countQuery = "SELECT COUNT(*)" + from + where;
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args);
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args); // NOSONAR
if (totalElements == null || totalElements == 0) {
return PageableExecutionUtils.getPage(results, pageable, () -> 0);
}
@@ -1012,7 +1012,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
String findFKSql = "SELECT count(*) FROM information_schema.TABLE_CONSTRAINTS i" + " WHERE i.CONSTRAINT_TYPE = 'FOREIGN KEY' AND "
+ schemaSql + " AND i.TABLE_NAME = '" + datatableName + "' AND i.CONSTRAINT_NAME = '" + fkName + "' ";
final Integer count = this.jdbcTemplate.queryForObject(findFKSql, Integer.class);
final Integer count = this.jdbcTemplate.queryForObject(findFKSql, Integer.class); // NOSONAR
if (count != null && count > 0) {
codeMappings.add(datatableAlias + "_" + name);
constrainBuilder.append(", DROP FOREIGN KEY ").append(sqlGenerator.escape(fkName)).append(" ");
@@ -1076,7 +1076,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
if (type != null && mandatory && type.isStringType()) {
String sql = "UPDATE " + sqlGenerator.escape(datatableName) + " SET " + sqlGenerator.escape(name) + " = '' WHERE "
+ sqlGenerator.escape(name) + " IS NULL";
this.jdbcTemplate.update(sql);
this.jdbcTemplate.update(sql); // NOSONAR
}
}
@@ -1141,12 +1141,12 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private void createUniqueConstraint(String datatableName, String columnName, String uniqueKeyName) {
String sql = "ALTER TABLE " + sqlGenerator.escape(datatableName) + " ADD CONSTRAINT " + sqlGenerator.escape(uniqueKeyName)
+ " UNIQUE (" + sqlGenerator.escape(columnName) + ");";
this.jdbcTemplate.execute(sql);
this.jdbcTemplate.execute(sql); // NOSONAR
}
private void dropUniqueConstraint(String datatableName, String uniqueKeyName) {
String sql = "ALTER TABLE " + sqlGenerator.escape(datatableName) + " DROP CONSTRAINT " + sqlGenerator.escape(uniqueKeyName) + ";";
this.jdbcTemplate.execute(sql);
this.jdbcTemplate.execute(sql); // NOSONAR
}
private void updateIndexesForTable(String datatableName, JsonArray changeColumns,
@@ -1430,7 +1430,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
params.add(primaryKey);
final String sql = sqlGenerator.buildUpdate(dataTableName, updateColumns, headersByName) + " WHERE " + pkColumn.getColumnName()
+ " = ?";
int updated = jdbcTemplate.update(sql, params.toArray(Object[]::new));
int updated = jdbcTemplate.update(sql, params.toArray(Object[]::new)); // NOSONAR
if (updated != 1) {
throw new PlatformDataIntegrityException("error.msg.invalid.update", "Expected one updated row.");
}
@@ -1486,7 +1486,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
String sql = "DELETE FROM " + sqlGenerator.escape(dataTableName) + " WHERE " + sqlGenerator.escape(whereColumn) + " = "
+ whereValue;
this.jdbcTemplate.update(sql);
this.jdbcTemplate.update(sql); // NOSONAR
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(whereValue) //
@@ -1643,7 +1643,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
String sql = "SELECT COUNT(edc.x_registered_table_name) FROM x_registered_table xrt"
+ " JOIN m_entity_datatable_check edc ON edc.x_registered_table_name = xrt.registered_table_name"
+ " WHERE edc.x_registered_table_name = '" + datatableName + "'";
final Long count = this.jdbcTemplate.queryForObject(sql, Long.class);
final Long count = this.jdbcTemplate.queryForObject(sql, Long.class); // NOSONAR
return count != null && count > 0;
}
@@ -1682,7 +1682,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private void validateDataTableExists(final String datatableName) {
final String sql = "select (CASE WHEN exists (select 1 from information_schema.tables where table_schema = "
+ sqlGenerator.currentSchema() + " and table_name = ?) THEN 'true' ELSE 'false' END)";
final boolean dataTableExists = Boolean.parseBoolean(this.jdbcTemplate.queryForObject(sql, String.class, datatableName));
final boolean dataTableExists = Boolean.parseBoolean(this.jdbcTemplate.queryForObject(sql, String.class, datatableName)); // NOSONAR
if (!dataTableExists) {
throw new PlatformDataIntegrityException("error.msg.invalid.datatable", "Invalid Data Table: " + datatableName, API_FIELD_NAME,
datatableName);
@@ -1716,7 +1716,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private int getDatatableRowCount(final String datatableName) {
final String sql = "select count(*) from " + sqlGenerator.escape(datatableName);
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class);
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class); // NOSONAR
return count == null ? 0 : count;
}
@@ -114,7 +114,7 @@ public class SavingsAccountTransactionsSearchServiceImpl implements SavingsAccou
Object[] args = params.toArray();
String countQuery = "SELECT COUNT(*) " + tm.from() + where;
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args);
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args); // NOSONAR
if (totalElements == null || totalElements == 0) {
return emptyResult;
}
@@ -266,7 +266,7 @@ public class SavingsAccountTransactionsSearchServiceImpl implements SavingsAccou
// Execute the count Query
String countQuery = "SELECT COUNT(*)" + from + where;
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args);
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args); // NOSONAR
if (totalElements == null || totalElements == 0) {
return PageableExecutionUtils.getPage(results, pageable, () -> 0);
}