Merge pull request #1626 from oldbig/develop

bugfix/connector_endpoint_404
This commit is contained in:
Marko Milić 2020-07-07 08:26:16 +02:00 committed by GitHub
commit 01db00b63e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 105 additions and 92 deletions

View File

@ -2,6 +2,7 @@ package code.api.util
import java.util.concurrent.ConcurrentHashMap
import code.api.v4_0_0.{DynamicEndpointHelper, DynamicEntityHelper}
import com.openbankproject.commons.util.ReflectUtils
sealed trait ApiRole{
@ -592,6 +593,10 @@ object ApiRole {
roles.find(_.toString == value) match {
case Some(x) => x // We find exactly one Role
case _ if dynamicApiRoles.containsKey(value) => dynamicApiRoles.get(value)
case _ if DynamicEntityHelper.dynamicEntityRoles.contains(value) ||
DynamicEndpointHelper.allDynamicEndpointRoles.exists(_.toString() == value)
=>
getOrCreateDynamicApiRole(value)
case _ => throw new IllegalArgumentException("Incorrect ApiRole value: " + value) // There is no Role
}
}

View File

@ -230,8 +230,8 @@ object FieldIgnoreSerializer extends Serializer[AnyRef] {
if(!ReflectUtils.isObpType(tp)) {
return Nil
}
memo.memoize(tp, it => {
val fields: List[universe.Symbol] = it.decls.filter(decl => decl.isTerm && (decl.asTerm.isVal || decl.asTerm.isVar)).toList
memo.memoize(tp){
val fields: List[universe.Symbol] = tp.decls.filter(decl => decl.isTerm && (decl.asTerm.isVal || decl.asTerm.isVar)).toList
val (ignoreFields, notIgnoreFields) = fields.partition(_.annotations.exists(_.tree.tpe <:< typeOf[ignore]))
val annotedFieldNames = ignoreFields.map(_.name.decodedName.toString.trim)
val subAnnotedFieldNames = notIgnoreFields.flatMap(it => {
@ -248,7 +248,7 @@ object FieldIgnoreSerializer extends Serializer[AnyRef] {
.map(it => s"$fieldName.$it")
})
annotedFieldNames ++ subAnnotedFieldNames
})
}
}
}

View File

@ -2069,7 +2069,6 @@ object NewStyle {
deleteEndpointResult: Box[Boolean] = if(deleteSuccess) {
val roles = DynamicEndpointHelper.getRoles(dynamicEndpointId).map(_.toString())
DynamicEndpointHelper.removeEndpoint(dynamicEndpointId)
val rolesDeleteResult: Box[Boolean] = Entitlement.entitlement.vend.deleteEntitlements(roles)
Box !! (rolesDeleteResult == Full(true))

View File

@ -357,7 +357,7 @@ object JSONFactory1_4_0 {
operation_id = s"${rd.implementedInApiVersion.fullyQualifiedVersion}-${rd.partialFunctionName.toString}",
request_verb = rd.requestVerb,
request_url = rd.requestUrl,
summary = rd.summary.replaceFirst("""\.(\s*)$""","$1"),//remove the ending dots in summary
summary = rd.summary.replaceFirst("""\.(\s*)$""", "$1"), // remove the ending dot in summary
// Strip the margin character (|) and line breaks and convert from markdown to html
description = PegdownOptions.convertPegdownToHtmlTweaked(rd.description.stripMargin), //.replaceAll("\n", ""),
description_markdown =rd.description.stripMargin,

View File

@ -2903,7 +2903,6 @@ trait APIMethods400 {
duplicatedUrl.isEmpty
}
(dynamicEndpoint, callContext) <- NewStyle.function.createDynamicEndpoint(postedJson.swaggerString, cc.callContext)
_ = DynamicEndpointHelper.addEndpoint(openAPI, dynamicEndpoint.dynamicEndpointId.get)
} yield {
val swaggerJson = parse(dynamicEndpoint.swaggerString)
val responseJson: JObject = ("dynamic_endpoint_id", dynamicEndpoint.dynamicEndpointId) ~ ("swagger_string", swaggerJson)

View File

@ -3,9 +3,8 @@ package code.api.v4_0_0
import java.io.File
import java.nio.charset.Charset
import java.util
import java.util.concurrent.CopyOnWriteArrayList
import java.util.regex.Pattern
import java.util.{Date, Optional, UUID}
import java.util.{Date, UUID}
import akka.http.scaladsl.model.{HttpMethods, HttpMethod => AkkaHttpMethod}
import code.DynamicEndpoint.{DynamicEndpointProvider, DynamicEndpointT}
@ -14,12 +13,14 @@ import code.api.util.ApiTag.{ResourceDocTag, apiTagApi, apiTagNewStyle}
import code.api.util.ErrorMessages.{UnknownError, UserHasMissingRoles, UserNotLoggedIn}
import code.api.util.{APIUtil, ApiRole, ApiTag, CustomJsonFormats}
import com.openbankproject.commons.util.ApiVersion
import com.openbankproject.commons.util.Functions.Memo
import io.swagger.v3.oas.models.PathItem.HttpMethod
import io.swagger.v3.oas.models.media._
import io.swagger.v3.oas.models.parameters.RequestBody
import io.swagger.v3.oas.models.responses.{ApiResponse, ApiResponses}
import io.swagger.v3.oas.models.{OpenAPI, Operation, PathItem}
import io.swagger.v3.parser.OpenAPIV3Parser
import net.liftweb.common.{Box, Full}
import net.liftweb.http.Req
import net.liftweb.http.rest.RestHelper
import net.liftweb.json
@ -44,25 +45,41 @@ object DynamicEndpointHelper extends RestHelper {
*/
val urlPrefix = APIUtil.getPropsValue("dynamic_endpoints_url_prefix", "dynamic")
private lazy val dynamicEndpointInfos: CopyOnWriteArrayList[DynamicEndpointInfo] = {
private def dynamicEndpointInfos: List[DynamicEndpointInfo] = {
val dynamicEndpoints: List[DynamicEndpointT] = DynamicEndpointProvider.connectorMethodProvider.vend.getAll()
val infos = dynamicEndpoints.map(it => swaggerToResourceDocs(it.swaggerString, it.dynamicEndpointId.get))
new CopyOnWriteArrayList(infos.asJava)
infos
}
def allDynamicEndpointRoles: List[ApiRole] = {
for {
dynamicEndpoint <- DynamicEndpointProvider.connectorMethodProvider.vend.getAll()
info = swaggerToResourceDocs(dynamicEndpoint.swaggerString, dynamicEndpoint.dynamicEndpointId.get)
role <- getRoles(info)
} yield role
}
def getRoles(dynamicEndpointId: String): List[ApiRole] = {
val foundInfos: Option[DynamicEndpointInfo] = dynamicEndpointInfos.asScala
.find(_.id == dynamicEndpointId)
val foundInfos: Box[DynamicEndpointInfo] = DynamicEndpointProvider.connectorMethodProvider.vend.get(dynamicEndpointId)
.map(dynamicEndpoint => swaggerToResourceDocs(dynamicEndpoint.swaggerString, dynamicEndpoint.dynamicEndpointId.get))
val roles = foundInfos.toList
.flatMap(_.resourceDocs)
.map(_.roles)
.collect {
case Some(role :: _) => role
}
val roles: List[ApiRole] = foundInfos match {
case Full(x) => getRoles(x)
case _ => Nil
}
roles
}
def getRoles(dynamicEndpointInfo: DynamicEndpointInfo): List[ApiRole] =
for {
resourceDoc <- dynamicEndpointInfo.resourceDocs.toList
rolesOption = resourceDoc.roles
if rolesOption.isDefined
role <- rolesOption.get
} yield role
/**
* extract request body, no matter GET, POST, PUT or DELETE method
*/
@ -89,13 +106,13 @@ object DynamicEndpointHelper extends RestHelper {
val httpMethod = HttpMethod.valueOf(r.requestType.method)
// url that match original swagger endpoint.
val url = partPath.tail.mkString("/", "/", "")
val foundDynamicEndpoint: Optional[(DynamicEndpointInfo, ResourceDoc, String)] = dynamicEndpointInfos.stream()
.map[Option[(DynamicEndpointInfo, ResourceDoc, String)]](_.findDynamicEndpoint(httpMethod, url))
.filter(_.isDefined)
.findFirst()
.map(_.get)
val foundDynamicEndpoint: Option[(DynamicEndpointInfo, ResourceDoc, String)] = dynamicEndpointInfos
.map(_.findDynamicEndpoint(httpMethod, url))
.collectFirst {
case Some(x) => x
}
foundDynamicEndpoint.asScala
foundDynamicEndpoint
.flatMap[(String, JValue, AkkaHttpMethod, Map[String, List[String]], Map[String, String], ApiRole)] { it =>
val (dynamicEndpointInfo, doc, originalUrl) = it
@ -118,31 +135,23 @@ object DynamicEndpointHelper extends RestHelper {
}
}
def addEndpoint(openAPI: OpenAPI, id: String): Boolean = {
val endpointInfo = swaggerToResourceDocs(openAPI, id)
dynamicEndpointInfos.add(endpointInfo)
}
def removeEndpoint(id: String): Boolean = {
dynamicEndpointInfos.asScala.find(_.id == id) match {
case Some(v) => dynamicEndpointInfos.remove(v)
case _ => false
}
}
def findExistsEndpoints(openAPI: OpenAPI): List[(HttpMethod, String)] = {
for {
(path, pathItem) <- openAPI.getPaths.asScala.toList
(method: HttpMethod, _) <- pathItem.readOperationsMap.asScala
if dynamicEndpointInfos.stream().anyMatch(_.existsEndpoint(method, path))
if dynamicEndpointInfos.exists(_.existsEndpoint(method, path))
} yield (method, path)
}
private def swaggerToResourceDocs(content: String, id: String): DynamicEndpointInfo = {
val openAPI: OpenAPI = parseSwaggerContent(content)
swaggerToResourceDocs(openAPI, id)
}
private val dynamicEndpointInfoMemo = new Memo[String, DynamicEndpointInfo]
private def swaggerToResourceDocs(content: String, id: String): DynamicEndpointInfo =
dynamicEndpointInfoMemo.memoize(content) {
val openAPI: OpenAPI = parseSwaggerContent(content)
swaggerToResourceDocs(openAPI, id)
}
private def swaggerToResourceDocs(openAPI: OpenAPI, id: String): DynamicEndpointInfo = {
val tags: List[ResourceDocTag] = List(ApiTag.apiTagDynamicEndpoint, apiTagApi, apiTagNewStyle)
@ -284,13 +293,12 @@ object DynamicEndpointHelper extends RestHelper {
}
def doc: ArrayBuffer[ResourceDoc] = {
val docs = ArrayBuffer[ResourceDoc]()
dynamicEndpointInfos.forEach { info =>
info.resourceDocs.foreach { doc =>
docs += doc
}
}
docs
val docs = for {
info <- dynamicEndpointInfos
doc <- info.resourceDocs
} yield doc
ArrayBuffer[ResourceDoc](docs:_*)
}
private def buildSummary(openAPI: OpenAPI, method: HttpMethod, op: Operation, path: String): String = {

View File

@ -18,18 +18,20 @@ import scala.collection.mutable.ArrayBuffer
object EntityName {
def unapply(entityName: String): Option[String] = MockerConnector.definitionsMap.keySet.find(entityName ==)
def unapply(entityName: String): Option[String] = DynamicEntityHelper.definitionsMap.keySet.find(entityName ==)
def unapply(url: List[String]): Option[(String, String)] = url match {
case entityName :: id :: Nil => MockerConnector.definitionsMap.keySet.find(entityName ==).map((_, id))
case entityName :: id :: Nil => DynamicEntityHelper.definitionsMap.keySet.find(entityName ==).map((_, id))
case _ => None
}
}
object MockerConnector {
object DynamicEntityHelper {
def definitionsMap = NewStyle.function.getDynamicEntities().map(it => (it.entityName, DynamicEntityInfo(it.metadataJson, it.entityName))).toMap
def definitionsMap: Map[String, DynamicEntityInfo] = NewStyle.function.getDynamicEntities().map(it => (it.entityName, DynamicEntityInfo(it.metadataJson, it.entityName))).toMap
def dynamicEntityRoles: List[String] = NewStyle.function.getDynamicEntities().flatMap(dEntity => DynamicEntityInfo.roleNames(dEntity.entityName))
def doc: ArrayBuffer[ResourceDoc] = {
val addPrefix = APIUtil.getPropsAsBoolValue("dynamic_entities_have_prefix", true)

View File

@ -67,7 +67,7 @@ object OBPAPI4_0_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
// if old version ResourceDoc objects have the same name endpoint with new version, omit old version ResourceDoc.
def allResourceDocs = collectResourceDocs(OBPAPI3_1_0.allResourceDocs,
Implementations4_0_0.resourceDocs,
MockerConnector.doc, DynamicEndpointHelper.doc)
DynamicEntityHelper.doc, DynamicEndpointHelper.doc)
.filterNot(it => it.partialFunctionName.matches(excludeEndpoints.mkString("|")))
//TODO exclude two endpoints, after training we need add logic to exclude endpoints

View File

@ -323,7 +323,7 @@ trait Connector extends MdcLoggable {
transactionRequestType: String,
currency: String,
userId: String,
userName: String,
username: String,
callContext: Option[CallContext]
): OBPReturnType[Box[AmountOfMoney]] =
LocalMappedConnector.getChallengeThreshold(
@ -333,7 +333,7 @@ trait Connector extends MdcLoggable {
transactionRequestType: String,
currency: String,
userId: String,
userName: String,
username: String,
callContext: Option[CallContext]
)
@ -342,7 +342,7 @@ trait Connector extends MdcLoggable {
accountId: AccountId,
viewId: ViewId,
userId: String,
userName: String,
username: String,
transactionRequestType: String,
currency: String,
callContext:Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] =
@ -351,7 +351,7 @@ trait Connector extends MdcLoggable {
accountId: AccountId,
viewId: ViewId,
userId: String,
userName: String,
username: String,
transactionRequestType: String,
currency: String,
callContext:Option[CallContext]
@ -413,11 +413,11 @@ trait Connector extends MdcLoggable {
/**
* This method is for checking external User via connector
* @param name
* @param username
* @param password
* @return
*/
def checkExternalUserCredentials(name: String, password: String, callContext: Option[CallContext]): Box[InboundExternalUser] = Failure(setUnimplementedError)
def checkExternalUserCredentials(username: String, password: String, callContext: Option[CallContext]): Box[InboundExternalUser] = Failure(setUnimplementedError)
/**
* This is a helper method

View File

@ -176,7 +176,7 @@ object ConnectorEndpoints extends RestHelper{
}
.sortBy(_._2.size)
.lastOption
.map(_._3)
.map(_._3)
}
def hashMethod(methodName: String, json: JValue): Boolean = getMethod(methodName, json).isDefined

View File

@ -187,7 +187,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
}
// Gets current challenge level for transaction request
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, userName: String, callContext: Option[CallContext]) = Future{
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, username: String, callContext: Option[CallContext]) = Future{
// Create argument list
val req = Map(
"north" -> "getChallengeThreshold",
@ -200,7 +200,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
"transactionRequestType" -> transactionRequestType,
"currency" -> currency,
"userId" -> userId,
"username" -> userName
"username" -> username
)
val r: Option[KafkaInboundChallengeLevel] = process(req).extractOpt[KafkaInboundChallengeLevel]
// Return result
@ -220,7 +220,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
accountId: AccountId,
viewId: ViewId,
userId: String,
userName: String,
username: String,
transactionRequestType: String,
currency: String,
callContext:Option[CallContext]) = Future{
@ -236,7 +236,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
"transactionRequestType" -> transactionRequestType,
"currency" -> currency,
"userId" -> userId,
"username" -> userName
"username" -> username
)
val r: Option[KafkaInboundChargeLevel] = process(req).extractOpt[KafkaInboundChargeLevel]
// Return result

View File

@ -127,7 +127,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
transactionRequestType: String,
currency: String,
userId: String,
userName: String,
username: String,
callContext: Option[CallContext]): Future[(Box[AmountOfMoney], Option[CallContext])] = Future {
val propertyName = "transactionRequests_challenge_threshold_" + transactionRequestType.toUpperCase
val threshold = BigDecimal(APIUtil.getPropsValue(propertyName, "1000"))
@ -296,7 +296,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
accountId: AccountId,
viewId: ViewId,
userId: String,
userName: String,
username: String,
transactionRequestType: String,
currency: String,
callContext: Option[CallContext]) = Future {

View File

@ -202,7 +202,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
}
// Gets current challenge level for transaction request
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, userName: String, callContext: Option[CallContext]) = Future{
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, username: String, callContext: Option[CallContext]) = Future{
val parameters = new JHashMap
parameters.put("accountId", accountId)

View File

@ -362,9 +362,9 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, userName: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, username: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
import com.openbankproject.commons.dto.{OutBoundGetChallengeThreshold => OutBound, InBoundGetChallengeThreshold => InBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, transactionRequestType, currency, userId, userName)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, transactionRequestType, currency, userId, username)
val response: Future[Box[InBound]] = (southSideActor ? req).mapTo[InBound].recoverWith(recoverFunction).map(Box !! _)
response.map(convertToTuple[AmountOfMoney](callContext))
}
@ -395,9 +395,9 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getChargeLevel(bankId: BankId, accountId: AccountId, viewId: ViewId, userId: String, userName: String, transactionRequestType: String, currency: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
override def getChargeLevel(bankId: BankId, accountId: AccountId, viewId: ViewId, userId: String, username: String, transactionRequestType: String, currency: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
import com.openbankproject.commons.dto.{OutBoundGetChargeLevel => OutBound, InBoundGetChargeLevel => InBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, userId, userName, transactionRequestType, currency)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, userId, username, transactionRequestType, currency)
val response: Future[Box[InBound]] = (southSideActor ? req).mapTo[InBound].recoverWith(recoverFunction).map(Box !! _)
response.map(convertToTuple[AmountOfMoney](callContext))
}

View File

@ -219,10 +219,10 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
// url example: /getChallengeThreshold
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, userName: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, username: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
import com.openbankproject.commons.dto.{OutBoundGetChallengeThreshold => OutBound, InBoundGetChallengeThreshold => InBound}
val url = getUrl(callContext, "getChallengeThreshold")
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull , bankId, accountId, viewId, transactionRequestType, currency, userId, userName)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull , bankId, accountId, viewId, transactionRequestType, currency, userId, username)
val result: OBPReturnType[Box[AmountOfMoney]] = sendRequest[InBound](url, HttpMethods.POST, req, callContext).map(convertToTuple(callContext))
result
}
@ -285,10 +285,10 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
// url example: /getChargeLevel
override def getChargeLevel(bankId: BankId, accountId: AccountId, viewId: ViewId, userId: String, userName: String, transactionRequestType: String, currency: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
override def getChargeLevel(bankId: BankId, accountId: AccountId, viewId: ViewId, userId: String, username: String, transactionRequestType: String, currency: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
import com.openbankproject.commons.dto.{OutBoundGetChargeLevel => OutBound, InBoundGetChargeLevel => InBound}
val url = getUrl(callContext, "getChargeLevel")
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull , bankId, accountId, viewId, userId, userName, transactionRequestType, currency)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull , bankId, accountId, viewId, userId, username, transactionRequestType, currency)
val result: OBPReturnType[Box[AmountOfMoney]] = sendRequest[InBound](url, HttpMethods.POST, req, callContext).map(convertToTuple(callContext))
result
}

View File

@ -135,9 +135,9 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, userName: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
override def getChallengeThreshold(bankId: String, accountId: String, viewId: String, transactionRequestType: String, currency: String, userId: String, username: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
import com.openbankproject.commons.dto.{OutBoundGetChallengeThreshold => OutBound, InBoundGetChallengeThreshold => InBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, transactionRequestType, currency, userId, userName)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, transactionRequestType, currency, userId, username)
val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_challenge_threshold", req, callContext)
response.map(convertToTuple[AmountOfMoney](callContext))
}
@ -168,9 +168,9 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getChargeLevel(bankId: BankId, accountId: AccountId, viewId: ViewId, userId: String, userName: String, transactionRequestType: String, currency: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
override def getChargeLevel(bankId: BankId, accountId: AccountId, viewId: ViewId, userId: String, username: String, transactionRequestType: String, currency: String, callContext: Option[CallContext]): OBPReturnType[Box[AmountOfMoney]] = {
import com.openbankproject.commons.dto.{OutBoundGetChargeLevel => OutBound, InBoundGetChargeLevel => InBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, userId, userName, transactionRequestType, currency)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankId, accountId, viewId, userId, username, transactionRequestType, currency)
val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_charge_level", req, callContext)
response.map(convertToTuple[AmountOfMoney](callContext))
}
@ -427,9 +427,9 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def checkExternalUserCredentials(name: String, password: String, callContext: Option[CallContext]): Box[InboundExternalUser] = {
override def checkExternalUserCredentials(username: String, password: String, callContext: Option[CallContext]): Box[InboundExternalUser] = {
import com.openbankproject.commons.dto.{OutBoundCheckExternalUserCredentials => OutBound, InBoundCheckExternalUserCredentials => InBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, name, password)
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, username, password)
val response: Future[Box[InBound]] = sendRequest[InBound]("obp_check_external_user_credentials", req, callContext)
response.map(convertToTuple[InboundExternalUser](callContext))
}

View File

@ -2314,20 +2314,20 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc
)
override def getChallengeThreshold(
bankId: String,
accountId: String,
viewId: String,
transactionRequestType: String,
currency: String,
userId: String,
userName: String,
callContext: Option[CallContext]
bankId: String,
accountId: String,
viewId: String,
transactionRequestType: String,
currency: String,
userId: String,
username: String,
callContext: Option[CallContext]
): OBPReturnType[Box[AmountOfMoney]] = saveConnectorMetric {
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
CacheKeyFromArguments.buildCacheKey {
Caching.memoizeWithProvider(Some(cacheKey.toString()))(atmTTL second){
val authInfo = getAuthInfo(callContext).openOrThrowException(attemptedToOpenAnEmptyBox)
val req = OutboundGetChallengeThreshold(authInfo, bankId, accountId, viewId, transactionRequestType, currency, userId, userName)
val req = OutboundGetChallengeThreshold(authInfo, bankId, accountId, viewId, transactionRequestType, currency, userId, username)
logger.debug(s"Kafka getChallengeThresholdFuture Req is: $req")
processRequest[InboundGetChallengeThreshold](req) map { inbound =>

View File

@ -71,9 +71,9 @@ object Functions {
class Memo[A, R] {
private val cache = new java.util.concurrent.atomic.AtomicReference(Map[A, R]())
def memoize(x: A, f: A => R): R = {
def addToCache() = {
val ret = f(x)
def memoize(x: A)(f: => R): R = {
def addToCache(): R = {
val ret = f
// if after execute f, the x not cached or cached but value changed, update cached value
val c: Map[A, R] = cache.get