mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 18:26:50 +00:00
rest connector methods generate: fix builder errors
This commit is contained in:
parent
9f58235edd
commit
31768a5a8f
@ -377,6 +377,12 @@
|
||||
<artifactId>evo-inflector</artifactId>
|
||||
<version>1.2.2</version>
|
||||
</dependency>
|
||||
<!-- modify class dynamically-->
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.25.0-GA</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -147,7 +147,11 @@ object CodeGenerateUtils {
|
||||
val TypeRef(_, _, args: List[Type]) = tp
|
||||
args.map(createDocExample(_)).mkString("(", ", ", ")")
|
||||
} else if (isObpType) {
|
||||
val fields = tp.decls.find(it => it.isConstructor).toList.flatMap(_.asMethod.paramLists(0)).foldLeft("")((str, symbol) => {
|
||||
val concreteType = tp.typeSymbol.isAbstract match {
|
||||
case true => ReflectUtils.getTypeByName(tp.typeSymbol.fullName + "Commons") // if here not found the Commons type, must add one
|
||||
case false => tp
|
||||
}
|
||||
val fields = concreteType.decls.find(it => it.isConstructor).toList.flatMap(_.asMethod.paramLists(0)).foldLeft("")((str, symbol) => {
|
||||
val valName = symbol.name.toString
|
||||
val TypeRef(pre: Type, sym: Symbol, args: List[Type]) = symbol.info
|
||||
val value = if (pre <:< ru.typeOf[ProductAttributeType.type]) {
|
||||
|
||||
@ -16,6 +16,15 @@ import scala.reflect.runtime.{universe => ru}
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
|
||||
object RestConnectorBuilder extends App {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
import javassist.ClassPool
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
val genMethodNames = List(
|
||||
"getAdapterInfo",
|
||||
|
||||
@ -243,36 +243,15 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
|
||||
import com.openbankproject.commons.dto.{OutBoundGetBankAccountsBalances => OutBound, InBoundGetBankAccountsBalances => InBound}
|
||||
val url = getUrl(callContext,"getBankAccountsBalances" , ("bankIdAccountIds", bankIdAccountIds))
|
||||
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankIdAccountIds)
|
||||
sendGetRequest[InBound](url, req).map(convertToTuple(callContext))
|
||||
sendRequest[InBound](url, HttpMethods.GET, req).map(convertToTuple(callContext))
|
||||
}
|
||||
}
|
||||
}("getBankAccountsBalances")
|
||||
|
||||
//---------------- dynamic end ---------------------please don't modify this line
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private[this] def sendGetRequest[T: TypeTag : Manifest](url: String, outBound: TopicTrait) =
|
||||
sendRequest[T](url, HttpMethods.GET, outBound)
|
||||
|
||||
private[this] def sendPostRequest[T: TypeTag : Manifest](url: String, outBound: TopicTrait) =
|
||||
sendRequest[T](url, HttpMethods.POST, outBound)
|
||||
|
||||
private[this] def sendPutRequest[T: TypeTag : Manifest](url: String, outBound: TopicTrait) =
|
||||
sendRequest[T](url, HttpMethods.PUT, outBound)
|
||||
|
||||
private[this] def sendDelteRequest[T: TypeTag : Manifest](url: String, outBound: TopicTrait) =
|
||||
sendRequest[T](url, HttpMethods.DELETE, outBound)
|
||||
|
||||
//In RestConnector, we use the headers to propagate the parameters to Adapter. The parameters come from the CallContext.outboundAdapterAuthInfo.userAuthContext
|
||||
//We can set them from UserOauthContext or the http request headers.
|
||||
private[this] implicit def buildHeaders(outboundAdapterCallContext: OutboundAdapterCallContext): List[HttpHeader] = {
|
||||
@ -339,7 +318,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
|
||||
.foldLeft(s"$baseUrl/$methodName")((url, pair) => url.concat(s"/${pair._1}/${urlValueConverter(pair._2)}")) + queryParams.getOrElse("")
|
||||
}
|
||||
|
||||
private[this] def sendRequest[T <: InBoundTrait[_]: TypeTag : Manifest](url: String, method: HttpMethod, outBound: TopicTrait): Future[Box[T]] = {
|
||||
private[this] def sendRequest[T <: InBoundTrait[_]: TypeTag : Manifest](url: String, method: HttpMethod, outBound: {def outboundAdapterCallContext: OutboundAdapterCallContext}): Future[Box[T]] = {
|
||||
// TODO transfer accountId to accountReference in outBound
|
||||
val outBoundJson = net.liftweb.json.Serialization.write(outBound)
|
||||
val request = prepareHttpRequest(url, method, HttpProtocol("HTTP/1.1"), outBoundJson).withHeaders(outBound.outboundAdapterCallContext)
|
||||
|
||||
@ -19,6 +19,15 @@ import scala.reflect.runtime.{universe => ru}
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
|
||||
object KafkaConnectorBuilder extends App {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
import javassist.ClassPool
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
val needToGenerateMethodsNames = List(
|
||||
// "getKycChecks",
|
||||
|
||||
@ -33,19 +33,11 @@ object MappedWebUiPropsProvider extends WebUiPropsProvider {
|
||||
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
|
||||
CacheKeyFromArguments.buildCacheKey {
|
||||
Caching.memoizeSyncWithProvider(Some(cacheKey.toString()))(webUiPropsTTL second) {
|
||||
try { //We need call this method without database, so just catch exception and others will also throw exception.
|
||||
WebUiProps.find(By(WebUiProps.Name, nameOfProperty))
|
||||
.map(_.value)
|
||||
.openOr {
|
||||
APIUtil.getPropsValue(nameOfProperty, defaultValue)
|
||||
}
|
||||
} catch {
|
||||
//java.lang.NullPointerException: Looking for Connection Identifier ConnectionIdentifier(lift) but failed to find either a JNDI data
|
||||
// source with the name lift or a lift connection manager with the correct name
|
||||
// Only handle this exception. no others.
|
||||
case exception: NullPointerException if(exception.getMessage.contains("failed to find either a JNDI data source"))=>
|
||||
APIUtil.getPropsValue(nameOfProperty, defaultValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}("getWebUiProps")("MappedWebUiPropsProvider")
|
||||
|
||||
@ -451,7 +451,7 @@ case class OutBoundGetTransactionRequests210(outboundAdapterCallContext: Outboun
|
||||
|
||||
case class InBoundGetTransactionRequests210(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]]
|
||||
|
||||
case class OutBoundGetTransactionsCore(bankId: BankId, accountID: AccountId, limit: Int, offset: Int, fromDate: String, toDate: String) extends TopicTrait
|
||||
case class OutBoundGetTransactionsCore(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, accountID: AccountId, limit: Int, offset: Int, fromDate: String, toDate: String) extends TopicTrait
|
||||
case class InBoundGetTransactionsCore(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionCore]) extends InBoundTrait[List[TransactionCore]]
|
||||
|
||||
//-------- return type are not Future--------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -447,9 +447,9 @@ case class OrderObjectJson(
|
||||
)
|
||||
|
||||
case class ObpApiLoopback(
|
||||
connectorVersion: String,
|
||||
gitCommit: String,
|
||||
durationTime: String
|
||||
connectorVersion: String,
|
||||
gitCommit: String,
|
||||
durationTime: String
|
||||
) extends TopicTrait
|
||||
|
||||
case class CardObjectJson(
|
||||
|
||||
@ -343,9 +343,7 @@ trait RoutingT {
|
||||
// @see 'case request: TopicTrait' in code/bankconnectors/kafkaStreamsHelper.scala
|
||||
// This is for Kafka topics for both North and South sides.
|
||||
// In OBP-API, these topics will be created automatically.
|
||||
trait TopicTrait {
|
||||
def outboundAdapterCallContext: OutboundAdapterCallContext
|
||||
}
|
||||
trait TopicTrait
|
||||
|
||||
//high level of four different kinds of transaction request types: FREE_FROM, SANDBOXTAN, COUNTERPATY and SEPA.
|
||||
//They share the same AmountOfMoney and description fields
|
||||
|
||||
Loading…
Reference in New Issue
Block a user