Merge pull request #2213 from constantine2nd/develop

Web UI Props caching does not work
This commit is contained in:
Simon Redfern 2023-04-04 14:25:55 +02:00 committed by GitHub
commit 9f4a56a2ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 20 deletions

View File

@ -147,52 +147,52 @@ trait APIMethods500 {
cc =>
val failMsg = s"$InvalidJsonFormat The Json body should be the $PostBankJson500 "
for {
bank <- NewStyle.function.tryons(failMsg, 400, cc.callContext) {
postJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) {
json.extract[PostBankJson500]
}
_ <- Helper.booleanToFuture(failMsg = ErrorMessages.InvalidConsumerCredentials, cc=cc.callContext) {
cc.callContext.map(_.consumer.isDefined == true).isDefined
}
_ <- Helper.booleanToFuture(failMsg = s"$InvalidJsonFormat Min length of BANK_ID should be greater than 3 characters.", cc=cc.callContext) {
bank.id.forall(_.length > 3)
postJson.id.forall(_.length > 3)
}
_ <- Helper.booleanToFuture(failMsg = s"$InvalidJsonFormat BANK_ID can not contain space characters", cc=cc.callContext) {
!bank.id.contains(" ")
!postJson.id.contains(" ")
}
_ <- Helper.booleanToFuture(failMsg = s"$InvalidJsonFormat BANK_ID can not contain `::::` characters", cc=cc.callContext) {
!`checkIfContains::::`(bank.id.getOrElse(""))
!`checkIfContains::::`(postJson.id.getOrElse(""))
}
(banks, callContext) <- NewStyle.function.getBanks(cc.callContext)
_ <- Helper.booleanToFuture(failMsg = ErrorMessages.bankIdAlreadyExists, cc=cc.callContext) {
!banks.exists { b => Some(b.bankId.value) == bank.id }
!banks.exists { b => Some(b.bankId.value) == postJson.id }
}
(success, callContext) <- NewStyle.function.createOrUpdateBank(
bank.id.getOrElse(APIUtil.generateUUID()),
bank.full_name.getOrElse(""),
bank.bank_code,
bank.logo.getOrElse(""),
bank.website.getOrElse(""),
bank.bank_routings.getOrElse(Nil).find(_.scheme == "BIC").map(_.address).getOrElse(""),
postJson.id.getOrElse(APIUtil.generateUUID()),
postJson.full_name.getOrElse(""),
postJson.bank_code,
postJson.logo.getOrElse(""),
postJson.website.getOrElse(""),
postJson.bank_routings.getOrElse(Nil).find(_.scheme == "BIC").map(_.address).getOrElse(""),
"",
bank.bank_routings.getOrElse(Nil).filterNot(_.scheme == "BIC").headOption.map(_.scheme).getOrElse(""),
bank.bank_routings.getOrElse(Nil).filterNot(_.scheme == "BIC").headOption.map(_.address).getOrElse(""),
postJson.bank_routings.getOrElse(Nil).filterNot(_.scheme == "BIC").headOption.map(_.scheme).getOrElse(""),
postJson.bank_routings.getOrElse(Nil).filterNot(_.scheme == "BIC").headOption.map(_.address).getOrElse(""),
callContext
)
entitlements <- NewStyle.function.getEntitlementsByUserId(cc.userId, callContext)
entitlementsByBank = entitlements.filter(_.bankId==bank.id.getOrElse(""))
entitlementsByBank = entitlements.filter(_.bankId==postJson.id.getOrElse(""))
_ <- entitlementsByBank.filter(_.roleName == CanCreateEntitlementAtOneBank.toString()).size > 0 match {
case true =>
// Already has entitlement
Future()
case false =>
Future(Entitlement.entitlement.vend.addEntitlement(bank.id.getOrElse(""), cc.userId, CanCreateEntitlementAtOneBank.toString()))
Future(Entitlement.entitlement.vend.addEntitlement(postJson.id.getOrElse(""), cc.userId, CanCreateEntitlementAtOneBank.toString()))
}
_ <- entitlementsByBank.filter(_.roleName == CanReadDynamicResourceDocsAtOneBank.toString()).size > 0 match {
case true =>
// Already has entitlement
Future()
case false =>
Future(Entitlement.entitlement.vend.addEntitlement(bank.id.getOrElse(""), cc.userId, CanReadDynamicResourceDocsAtOneBank.toString()))
Future(Entitlement.entitlement.vend.addEntitlement(postJson.id.getOrElse(""), cc.userId, CanReadDynamicResourceDocsAtOneBank.toString()))
}
} yield {
(JSONFactory500.createBankJSON500(success), HttpCode.`201`(callContext))

View File

@ -349,7 +349,6 @@ class WebUI extends MdcLoggable{
def apiDocumentation: CssSel = {
val title = "Sandbox Introduction"
val propsValue = getWebUiPropsValue("webui_sandbox_introduction", "")
val htmlDescription = if (APIUtil.glossaryDocsRequireRole){
val userId = AuthUser.getCurrentResourceUserUserId

View File

@ -37,7 +37,7 @@ object MappedWebUiPropsProvider extends WebUiPropsProvider {
// 2) Get requested + language if any
// 3) Get requested if any
// 4) Get default value
override def getWebUiPropsValue(requestedPropertyName: String, defaultValue: String): String = saveConnectorMetric {
override def getWebUiPropsValue(requestedPropertyName: String, defaultValue: String, language: String = I18NUtil.currentLocale().toString()): String = saveConnectorMetric {
import scala.concurrent.duration._
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
CacheKeyFromArguments.buildCacheKey {
@ -49,7 +49,6 @@ object MappedWebUiPropsProvider extends WebUiPropsProvider {
}
// In case there is a translation we must use it
val language = I18NUtil.currentLocale().toString()
val webUiPropsPropertyName = s"${brandSpecificPropertyName}_${language}"
val translatedAndOrBrandPropertyName = WebUiProps.find(By(WebUiProps.Name, webUiPropsPropertyName)).isDefined match {
case true => webUiPropsPropertyName

View File

@ -23,7 +23,7 @@ trait WebUiPropsProvider {
def delete(webUiPropsId: String):Box[Boolean]
def getWebUiPropsValue(nameOfProperty: String, defaultValue: String): String
def getWebUiPropsValue(nameOfProperty: String, defaultValue: String, language: String): String
}