mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:56:46 +00:00
Merge pull request #1602 from constantine2nd/develop
Use UUID instead of primary key in case of Get top consumers endpoint; Add guard at endpoint createMethodRouting etc..
This commit is contained in:
commit
79fbb74898
@ -467,6 +467,7 @@ object ErrorMessages {
|
||||
// MethodRouting Exceptions (OBP-7XXXX)
|
||||
val InvalidBankIdRegex = "OBP-70001: Incorrect regex for bankIdPattern."
|
||||
val MethodRoutingNotFoundByMethodRoutingId = "OBP-70002: MethodRouting not found. Please specify a valid value for method_routing_id."
|
||||
val MethodRoutingNameAlreadyUsed = "OBP-70003: Method Routing Name already used."
|
||||
|
||||
// Cascade Deletion Exceptions (OBP-8XXXX)
|
||||
val CouldNotDeleteCascade = "OBP-80001: Could not delete cascade."
|
||||
|
||||
@ -1696,6 +1696,13 @@ object NewStyle {
|
||||
def getMethodRoutingsByMethdName(methodName: Box[String]): Future[List[MethodRoutingT]] = Future {
|
||||
this.getMethodRoutings(methodName.toOption)
|
||||
}
|
||||
def checkMethodRoutingAlreadyExists(methodName: String, callContext:Option[CallContext]): OBPReturnType[Boolean] = Future {
|
||||
val exists = this.getMethodRoutings(Some(methodName)).isEmpty match {
|
||||
case true => Full(true)
|
||||
case false => Empty
|
||||
}
|
||||
(unboxFullOrFail(exists, callContext, s"$MethodRoutingNameAlreadyUsed"), callContext)
|
||||
}
|
||||
def getCardAttributeById(cardAttributeId: String, callContext:Option[CallContext]) =
|
||||
Connector.connector.vend.getCardAttributeById(cardAttributeId: String, callContext:Option[CallContext]) map {
|
||||
i => (unboxFullOrFail(i._1, callContext, s"$CardAttributeNotFound Current CardAttributeId($cardAttributeId)"), i._2)
|
||||
|
||||
@ -4315,6 +4315,7 @@ trait APIMethods310 {
|
||||
Pattern.compile(postedData.bankIdPattern.get)
|
||||
}
|
||||
}
|
||||
_ <- NewStyle.function.checkMethodRoutingAlreadyExists(methodName, callContext)
|
||||
Full(methodRouting) <- NewStyle.function.createOrUpdateMethodRouting(postedData)
|
||||
} yield {
|
||||
val commonsData: MethodRoutingCommons = methodRouting
|
||||
|
||||
@ -32,7 +32,7 @@ object StoredProcedureUtils {
|
||||
val initialSize = APIUtil.getPropsAsIntValue("stored_procedure_connector.poolInitialSize", 5)
|
||||
val maxSize = APIUtil.getPropsAsIntValue("stored_procedure_connector.poolMaxSize", 20)
|
||||
val timeoutMillis = APIUtil.getPropsAsLongValue("stored_procedure_connector.poolConnectionTimeoutMillis", 3000L)
|
||||
val validationQuery = APIUtil.getPropsValue("stored_procedure_connector.poolValidationQuery", "select 1 from dual")
|
||||
val validationQuery = APIUtil.getPropsValue("stored_procedure_connector.poolValidationQuery", "select 1")
|
||||
val poolFactoryName = APIUtil.getPropsValue("stored_procedure_connector.poolFactoryName", "commons-dbcp2")
|
||||
|
||||
|
||||
|
||||
@ -450,7 +450,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
|
||||
val extedndedExcludeImplementedByPartialFunctionsQueries = extendCurrentQuery(excludeImplementedByPartialFunctionsNumberSet.size)
|
||||
|
||||
for {
|
||||
dbQuery <- Full("SELECT count(*) as count, consumer.id as consumerprimaryid, mappedmetric.appname as appname, consumer.developeremail as email " +
|
||||
dbQuery <- Full("SELECT count(*) as count, consumer.id as consumerprimaryid, mappedmetric.appname as appname, consumer.developeremail as email, consumer.consumerid as consumerid " +
|
||||
"FROM mappedmetric, consumer " +
|
||||
"WHERE mappedmetric.appname = consumer.name " +
|
||||
"AND date_c >= ? " +
|
||||
@ -509,10 +509,10 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
|
||||
topConsumers <- tryo(resultSet._2.map(
|
||||
a =>
|
||||
TopConsumer(
|
||||
if (a(0) != null) a(0).toInt else 0,
|
||||
if (a(1) != null) a(1).toString else "",
|
||||
if (a(2) != null) a(2).toString else "",
|
||||
if (a(3) != null) a(3).toString else ""
|
||||
count = if (a(0) != null) a(0).toInt else 0,
|
||||
consumerId = if (a(4) != null) a(4).toString else "",
|
||||
appName = if (a(2) != null) a(2).toString else "",
|
||||
developerEmail = if (a(3) != null) a(3).toString else ""
|
||||
))) ?~! {
|
||||
logger.error(s"getTopConsumersBox.create TopConsumer class error. Here is the result from database $resultSet ");
|
||||
s"$UnknownError getTopConsumersBox.create TopApi class error. "
|
||||
|
||||
@ -5,6 +5,7 @@ import code.api.APIFailureNewStyle
|
||||
import code.api.util.APIUtil.fullBoxOrException
|
||||
import code.api.util.ErrorMessages.CouldNotDeleteCascade
|
||||
import code.bankconnectors.Connector
|
||||
import code.cards.MappedPhysicalCard
|
||||
import code.model.dataAccess.{MappedBankAccount, MappedBankAccountData}
|
||||
import code.views.system.{AccountAccess, ViewDefinition}
|
||||
import code.webhook.MappedAccountWebhook
|
||||
@ -27,6 +28,7 @@ object DeleteAccountCascade {
|
||||
deleteAccountAttributes(bankId, accountId) ::
|
||||
deleteAccountWebhooks(bankId, accountId) ::
|
||||
deleteBankAccountData(bankId, accountId) ::
|
||||
deleteCards(accountId) ::
|
||||
deleteAccount(bankId, accountId) ::
|
||||
Nil
|
||||
doneTasks.forall(_ == true)
|
||||
@ -49,6 +51,17 @@ object DeleteAccountCascade {
|
||||
)
|
||||
}
|
||||
|
||||
private def deleteCards(accountId: AccountId): Boolean = {
|
||||
MappedBankAccount.findAll(
|
||||
By(MappedBankAccount.theAccountId, accountId.value)
|
||||
) map (
|
||||
account =>
|
||||
MappedPhysicalCard.bulkDelete_!!(
|
||||
By(MappedPhysicalCard.mAccount, account.id.get)
|
||||
)
|
||||
)
|
||||
}.forall(_ == true)
|
||||
|
||||
private def deleteBankAccountData(bankId: BankId, accountId: AccountId): Boolean = {
|
||||
MappedBankAccountData.bulkDelete_!!(
|
||||
By(MappedBankAccountData.bankId, bankId.value),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user