Skip to content

Commit 3957c62

Browse files
authored
Merge pull request #5758
FINERACT-2585: Standardize String Locale usage in Command Infrastructure and Build Services
2 parents 9c69fc8 + 98da533 commit 3957c62

3 files changed

Lines changed: 23 additions & 20 deletions

File tree

buildSrc/src/main/groovy/org/apache/fineract/gradle/service/GpgService.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory
3636
import java.security.GeneralSecurityException
3737
import java.security.MessageDigest
3838
import java.security.Security
39+
import java.util.Locale
3940

4041
class GpgService {
4142
private static final Logger log = LoggerFactory.getLogger(GpgService.class)
@@ -64,7 +65,7 @@ class GpgService {
6465
def k = iterator.next();
6566

6667
if (k.isEncryptionKey()) {
67-
def keyName = Long.toHexString(k.keyID).toUpperCase()
68+
def keyName = Long.toHexString(k.keyID).toUpperCase(java.util.Locale.ROOT)
6869

6970
if(config.keyName.substring(config.keyName.length()-keyName.length()) == keyName) {
7071
publicKey = k;

fineract-core/src/main/java/org/apache/fineract/commands/service/CommandSourceService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.google.gson.JsonElement;
2424
import com.google.gson.JsonObject;
25+
import java.util.Locale;
2526
import java.util.Set;
2627
import lombok.RequiredArgsConstructor;
2728
import org.apache.fineract.batch.exception.ErrorInfo;
@@ -82,7 +83,7 @@ private CommandSource saveInitial(CommandWrapper wrapper, JsonCommand jsonComman
8283
return commandSourceRepository.saveAndFlush(initialCommandSource);
8384
} catch (JpaSystemException jse) {
8485
final String message = (jse.getRootCause() != null) ? jse.getRootCause().getMessage() : null;
85-
if (message != null && message.toUpperCase().contains("UNIQUE_PORTFOLIO_COMMAND_SOURCE")) {
86+
if (message != null && message.toUpperCase(Locale.ROOT).contains("UNIQUE_PORTFOLIO_COMMAND_SOURCE")) {
8687
throw new IdempotentCommandProcessUnderProcessingException(wrapper, idempotencyKey, jse);
8788
}
8889
throw jse;

fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249

250250
import java.util.Arrays;
251251
import java.util.HashSet;
252+
import java.util.Locale;
252253
import java.util.Set;
253254
import org.apache.fineract.commands.domain.CommandWrapper;
254255
import org.apache.fineract.infrastructure.accountnumberformat.service.AccountNumberFormatConstants;
@@ -2830,7 +2831,7 @@ public CommandWrapperBuilder closeRecurringDepositAccount(final Long accountId)
28302831
}
28312832

28322833
public CommandWrapperBuilder updateDepositAmountForRecurringDepositAccount(final Long accountId) {
2833-
this.actionName = DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT.toUpperCase();
2834+
this.actionName = DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT.toUpperCase(Locale.ROOT);
28342835
this.entityName = ENTITY_RECURRINGDEPOSITACCOUNT;
28352836
this.entityId = accountId;
28362837
this.savingsId = accountId;
@@ -2963,22 +2964,22 @@ public CommandWrapperBuilder rejectLoanRescheduleRequest(final String entityName
29632964

29642965
public CommandWrapperBuilder createAccountNumberFormat() {
29652966
this.actionName = ACTION_CREATE;
2966-
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase();
2967+
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase(Locale.ROOT);
29672968
this.href = AccountNumberFormatConstants.resourceRelativeURL;
29682969
return this;
29692970
}
29702971

29712972
public CommandWrapperBuilder updateAccountNumberFormat(final Long accountNumberFormatId) {
29722973
this.actionName = ACTION_UPDATE;
2973-
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase();
2974+
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase(Locale.ROOT);
29742975
this.entityId = accountNumberFormatId;
29752976
this.href = AccountNumberFormatConstants.resourceRelativeURL + "/" + accountNumberFormatId;
29762977
return this;
29772978
}
29782979

29792980
public CommandWrapperBuilder deleteAccountNumberFormat(final Long accountNumberFormatId) {
29802981
this.actionName = ACTION_DELETE;
2981-
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase();
2982+
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase(Locale.ROOT);
29822983
this.entityId = accountNumberFormatId;
29832984
this.href = "AccountNumberFormatConstants.resourceRelativeURL" + "/" + accountNumberFormatId;
29842985
this.json = "{}";
@@ -3294,46 +3295,46 @@ public CommandWrapperBuilder deleteScheduleExceptions(final Long loanId) {
32943295
}
32953296

32963297
public CommandWrapperBuilder createProduct(String productType) {
3297-
this.entityName = productType.toUpperCase() + "PRODUCT"; // To Support
3298-
// different
3299-
// type of
3300-
// products
3298+
this.entityName = productType.toUpperCase(Locale.ROOT) + "PRODUCT"; // To Support
3299+
// different
3300+
// type of
3301+
// products
33013302
this.actionName = ACTION_CREATE;
33023303
this.entityId = null;
33033304
this.href = "/products/" + productType;
33043305
return this;
33053306
}
33063307

33073308
public CommandWrapperBuilder updateProduct(String productType, final Long productId) {
3308-
this.entityName = productType.toUpperCase() + "PRODUCT";
3309+
this.entityName = productType.toUpperCase(Locale.ROOT) + "PRODUCT";
33093310
this.actionName = ACTION_UPDATE;
33103311
this.entityId = productId;
33113312
this.href = "/products/" + productType + "/" + productId;
33123313
return this;
33133314
}
33143315

33153316
public CommandWrapperBuilder createAccount(String accountType) {
3316-
this.entityName = accountType.toUpperCase() + "ACCOUNT"; // To Support
3317-
// different
3318-
// type of
3319-
// Accounts
3317+
this.entityName = accountType.toUpperCase(Locale.ROOT) + "ACCOUNT"; // To Support
3318+
// different
3319+
// type of
3320+
// Accounts
33203321
this.actionName = ACTION_CREATE;
33213322
this.entityId = null;
33223323
this.href = "/accounts/" + accountType;
33233324
return this;
33243325
}
33253326

33263327
public CommandWrapperBuilder updateAccount(String accountType, final Long accountId) {
3327-
this.entityName = accountType.toUpperCase() + "ACCOUNT";
3328+
this.entityName = accountType.toUpperCase(Locale.ROOT) + "ACCOUNT";
33283329
this.actionName = ACTION_UPDATE;
33293330
this.entityId = accountId;
33303331
this.href = "/accounts/" + accountType + "/" + accountId;
33313332
return this;
33323333
}
33333334

33343335
public CommandWrapperBuilder createProductCommand(String productType, String command, final Long productId) {
3335-
this.entityName = productType.toUpperCase() + "PRODUCT";
3336-
this.actionName = ACTION_CREATE + "_" + command.toUpperCase();
3336+
this.entityName = productType.toUpperCase(Locale.ROOT) + "PRODUCT";
3337+
this.actionName = ACTION_CREATE + "_" + command.toUpperCase(Locale.ROOT);
33373338
this.entityId = productId;
33383339
this.href = "/products/" + productType + "/" + productId + "?command=" + command;
33393340
return this;
@@ -3364,8 +3365,8 @@ public CommandWrapperBuilder deleteShareProductDividendPayoutCommand(final Long
33643365
}
33653366

33663367
public CommandWrapperBuilder createAccountCommand(String accountType, final Long accountId, String command) {
3367-
this.entityName = accountType.toUpperCase() + "ACCOUNT";
3368-
this.actionName = command.toUpperCase();
3368+
this.entityName = accountType.toUpperCase(Locale.ROOT) + "ACCOUNT";
3369+
this.actionName = command.toUpperCase(Locale.ROOT);
33693370
this.entityId = accountId;
33703371
this.href = "/accounts/" + accountType + "/" + accountId + "?command=" + command;
33713372
return this;

0 commit comments

Comments
 (0)