Skip to content

Commit 98da533

Browse files
committed
fix: standardize String Locale usage in Command Infrastructure [FINERACT-2585]
1 parent 77518f7 commit 98da533

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;
@@ -2822,7 +2823,7 @@ public CommandWrapperBuilder closeRecurringDepositAccount(final Long accountId)
28222823
}
28232824

28242825
public CommandWrapperBuilder updateDepositAmountForRecurringDepositAccount(final Long accountId) {
2825-
this.actionName = DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT.toUpperCase();
2826+
this.actionName = DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT.toUpperCase(Locale.ROOT);
28262827
this.entityName = ENTITY_RECURRINGDEPOSITACCOUNT;
28272828
this.entityId = accountId;
28282829
this.savingsId = accountId;
@@ -2955,22 +2956,22 @@ public CommandWrapperBuilder rejectLoanRescheduleRequest(final String entityName
29552956

29562957
public CommandWrapperBuilder createAccountNumberFormat() {
29572958
this.actionName = ACTION_CREATE;
2958-
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase();
2959+
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase(Locale.ROOT);
29592960
this.href = AccountNumberFormatConstants.resourceRelativeURL;
29602961
return this;
29612962
}
29622963

29632964
public CommandWrapperBuilder updateAccountNumberFormat(final Long accountNumberFormatId) {
29642965
this.actionName = ACTION_UPDATE;
2965-
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase();
2966+
this.entityName = AccountNumberFormatConstants.ENTITY_NAME.toUpperCase(Locale.ROOT);
29662967
this.entityId = accountNumberFormatId;
29672968
this.href = AccountNumberFormatConstants.resourceRelativeURL + "/" + accountNumberFormatId;
29682969
return this;
29692970
}
29702971

29712972
public CommandWrapperBuilder deleteAccountNumberFormat(final Long accountNumberFormatId) {
29722973
this.actionName = ACTION_DELETE;
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
this.json = "{}";
@@ -3286,46 +3287,46 @@ public CommandWrapperBuilder deleteScheduleExceptions(final Long loanId) {
32863287
}
32873288

32883289
public CommandWrapperBuilder createProduct(String productType) {
3289-
this.entityName = productType.toUpperCase() + "PRODUCT"; // To Support
3290-
// different
3291-
// type of
3292-
// products
3290+
this.entityName = productType.toUpperCase(Locale.ROOT) + "PRODUCT"; // To Support
3291+
// different
3292+
// type of
3293+
// products
32933294
this.actionName = ACTION_CREATE;
32943295
this.entityId = null;
32953296
this.href = "/products/" + productType;
32963297
return this;
32973298
}
32983299

32993300
public CommandWrapperBuilder updateProduct(String productType, final Long productId) {
3300-
this.entityName = productType.toUpperCase() + "PRODUCT";
3301+
this.entityName = productType.toUpperCase(Locale.ROOT) + "PRODUCT";
33013302
this.actionName = ACTION_UPDATE;
33023303
this.entityId = productId;
33033304
this.href = "/products/" + productType + "/" + productId;
33043305
return this;
33053306
}
33063307

33073308
public CommandWrapperBuilder createAccount(String accountType) {
3308-
this.entityName = accountType.toUpperCase() + "ACCOUNT"; // To Support
3309-
// different
3310-
// type of
3311-
// Accounts
3309+
this.entityName = accountType.toUpperCase(Locale.ROOT) + "ACCOUNT"; // To Support
3310+
// different
3311+
// type of
3312+
// Accounts
33123313
this.actionName = ACTION_CREATE;
33133314
this.entityId = null;
33143315
this.href = "/accounts/" + accountType;
33153316
return this;
33163317
}
33173318

33183319
public CommandWrapperBuilder updateAccount(String accountType, final Long accountId) {
3319-
this.entityName = accountType.toUpperCase() + "ACCOUNT";
3320+
this.entityName = accountType.toUpperCase(Locale.ROOT) + "ACCOUNT";
33203321
this.actionName = ACTION_UPDATE;
33213322
this.entityId = accountId;
33223323
this.href = "/accounts/" + accountType + "/" + accountId;
33233324
return this;
33243325
}
33253326

33263327
public CommandWrapperBuilder createProductCommand(String productType, String command, final Long productId) {
3327-
this.entityName = productType.toUpperCase() + "PRODUCT";
3328-
this.actionName = ACTION_CREATE + "_" + command.toUpperCase();
3328+
this.entityName = productType.toUpperCase(Locale.ROOT) + "PRODUCT";
3329+
this.actionName = ACTION_CREATE + "_" + command.toUpperCase(Locale.ROOT);
33293330
this.entityId = productId;
33303331
this.href = "/products/" + productType + "/" + productId + "?command=" + command;
33313332
return this;
@@ -3356,8 +3357,8 @@ public CommandWrapperBuilder deleteShareProductDividendPayoutCommand(final Long
33563357
}
33573358

33583359
public CommandWrapperBuilder createAccountCommand(String accountType, final Long accountId, String command) {
3359-
this.entityName = accountType.toUpperCase() + "ACCOUNT";
3360-
this.actionName = command.toUpperCase();
3360+
this.entityName = accountType.toUpperCase(Locale.ROOT) + "ACCOUNT";
3361+
this.actionName = command.toUpperCase(Locale.ROOT);
33613362
this.entityId = accountId;
33623363
this.href = "/accounts/" + accountType + "/" + accountId + "?command=" + command;
33633364
return this;

0 commit comments

Comments
 (0)