diff --git a/obp-api/pom.xml b/obp-api/pom.xml
index 97313d66f..627fe59bc 100644
--- a/obp-api/pom.xml
+++ b/obp-api/pom.xml
@@ -8,7 +8,7 @@
com.tesobe
obp-parent
../pom.xml
- 1.6.4
+ 1.7.0
obp-api
war
diff --git a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala
index b526f09b3..731cae9b5 100644
--- a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala
+++ b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala
@@ -287,7 +287,10 @@ object ErrorMessages {
val AttributeNotFound = "OBP-30071: Attribute Definition not found. Please specify a valid value for ATTRIBUTE_DEFINITION_ID."
val CreateCounterpartyError = "OBP-30072: Could not create the Counterparty."
-
+
+ val BankAccountNotFoundByAccountRouting = "OBP-30073: Bank Account not found. Please specify valid values for account routing scheme and address."
+ val BankAccountNotFoundByIban = "OBP-30074: Bank Account not found. Please specify a valid value for iban."
+
// Meetings
val MeetingsNotSupported = "OBP-30101: Meetings are not supported on this server."
val MeetingApiKeyNotConfigured = "OBP-30102: Meeting provider API Key is not configured."
diff --git a/obp-api/src/main/scala/code/api/util/NewStyle.scala b/obp-api/src/main/scala/code/api/util/NewStyle.scala
index 6e6cab7dd..48630fa0b 100644
--- a/obp-api/src/main/scala/code/api/util/NewStyle.scala
+++ b/obp-api/src/main/scala/code/api/util/NewStyle.scala
@@ -218,13 +218,13 @@ object NewStyle {
def getBankAccountByRouting(scheme: String, address: String, callContext: Option[CallContext]) : OBPReturnType[BankAccount] = {
Future(Connector.connector.vend.getBankAccountByRouting(scheme: String, address : String, callContext: Option[CallContext])) map { i =>
- unboxFullOrFail(i, callContext,s"${BankAccountNotFound.replaceAll("BANK_ID and ACCOUNT_ID. ", s"scheme and address.")} Current scheme is $scheme, current address is $address", 404 )
+ unboxFullOrFail(i, callContext,s"$BankAccountNotFoundByAccountRouting Current scheme is $scheme, current address is $address", 404 )
}
}
def getBankAccountByIban(iban : String, callContext: Option[CallContext]) : OBPReturnType[BankAccount] = {
Connector.connector.vend.getBankAccountByIban(iban : String, callContext: Option[CallContext]) map { i =>
- (unboxFullOrFail(i._1, callContext,s"${BankAccountNotFound.replaceAll("BANK_ID and ACCOUNT_ID. ", "IBAN.")} Current IBAN is $iban", 404 ), i._2)
+ (unboxFullOrFail(i._1, callContext,s"$BankAccountNotFoundByIban Current IBAN is $iban", 404 ), i._2)
}
}
diff --git a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala
index 1f2c6c1de..61a88c150 100644
--- a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala
+++ b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala
@@ -4821,9 +4821,11 @@ trait APIMethods310 {
case _ => None
} fallbackTo Future.successful(None)
))
- alreadyExistingAccountRouting = alreadyExistAccountRoutings.find(_.nonEmpty).flatten
- _ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.map(_.scheme).getOrElse("")}, ${alreadyExistingAccountRouting.map(_.address).getOrElse("")})") {
- alreadyExistAccountRoutings.forall(_.isEmpty)
+ alreadyExistingAccountRouting = alreadyExistAccountRoutings.collect {
+ case Some(accountRouting) => s"scheme: ${accountRouting.scheme}, address: ${accountRouting.address}"
+ }
+ _ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.mkString("; ")})") {
+ alreadyExistingAccountRouting.isEmpty
}
(bankAccount,callContext) <- NewStyle.function.updateBankAccount(
bankId,
@@ -5478,9 +5480,11 @@ trait APIMethods310 {
alreadyExistAccountRoutings <- Future.sequence(createAccountJson.account_routings.map(accountRouting =>
NewStyle.function.getBankAccountByRouting(accountRouting.scheme, accountRouting.address, callContext).map(_ => Some(accountRouting)).fallbackTo(Future.successful(None))
))
- alreadyExistingAccountRouting = alreadyExistAccountRoutings.find(_.nonEmpty).flatten
- _ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.map(_.scheme).getOrElse("")}, ${alreadyExistingAccountRouting.map(_.address).getOrElse("")})") {
- alreadyExistAccountRoutings.forall(_.isEmpty)
+ alreadyExistingAccountRouting = alreadyExistAccountRoutings.collect {
+ case Some(accountRouting) => s"scheme: ${accountRouting.scheme}, address: ${accountRouting.address}"
+ }
+ _ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.mkString("; ")})") {
+ alreadyExistingAccountRouting.isEmpty
}
(bankAccount,callContext) <- NewStyle.function.createBankAccount(
bankId,
diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala
index 907f6d529..7e924f34e 100644
--- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala
+++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala
@@ -1269,9 +1269,11 @@ trait APIMethods400 {
alreadyExistAccountRoutings <- Future.sequence(createAccountJson.account_routings.map(accountRouting =>
NewStyle.function.getBankAccountByRouting(accountRouting.scheme, accountRouting.address, callContext).map(_ => Some(accountRouting)).fallbackTo(Future.successful(None))
))
- alreadyExistingAccountRouting = alreadyExistAccountRoutings.find(_.nonEmpty).flatten
- _ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.map(_.scheme).getOrElse("")}, ${alreadyExistingAccountRouting.map(_.address).getOrElse("")})") {
- alreadyExistAccountRoutings.forall(_.isEmpty)
+ alreadyExistingAccountRouting = alreadyExistAccountRoutings.collect {
+ case Some(accountRouting) => s"scheme: ${accountRouting.scheme}, address: ${accountRouting.address}"
+ }
+ _ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.mkString("; ")})") {
+ alreadyExistingAccountRouting.isEmpty
}
(bankAccount,callContext) <- NewStyle.function.addBankAccount(
bankId,
diff --git a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala
index 21d1545f6..d23dc7354 100644
--- a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala
+++ b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala
@@ -1297,18 +1297,14 @@ object LocalMappedConnector extends Connector with MdcLoggable {
callContext: Option[CallContext]
): OBPReturnType[Box[BankAccount]] = Future {
- val oldAccountRoutings = BankAccountRouting.findAll(By(BankAccountRouting.BankId, bankId.value),
+ val oldAccountRoutings: List[BankAccountRouting] = BankAccountRouting.findAll(By(BankAccountRouting.BankId, bankId.value),
By(BankAccountRouting.AccountId, accountId.value))
- .map(_.accountRouting)
// Add or update new routing schemes
accountRoutings.foreach(accountRouting =>
- oldAccountRoutings.find(_.scheme == accountRouting.scheme) match {
- case Some(_) =>
- BankAccountRouting
- .find(By(BankAccountRouting.BankId, bankId.value), By(BankAccountRouting.AccountId, accountId.value),
- By(BankAccountRouting.AccountRoutingScheme, accountRouting.scheme))
- .map(_.AccountRoutingAddress(accountRouting.address).saveMe())
+ oldAccountRoutings.find(_.accountRouting.scheme == accountRouting.scheme) match {
+ case Some(updatedAccountRouting) =>
+ updatedAccountRouting.AccountRoutingAddress(accountRouting.address).saveMe()
case None =>
BankAccountRouting.create
.BankId(bankId.value)
@@ -1320,18 +1316,11 @@ object LocalMappedConnector extends Connector with MdcLoggable {
)
// Delete non-present routing schemes
- oldAccountRoutings.foreach(accountRouting =>
- accountRoutings.find(_.scheme == accountRouting.scheme)
- .getOrElse(
- BankAccountRouting
- .find(By(BankAccountRouting.BankId, bankId.value), By(BankAccountRouting.AccountId, accountId.value),
- By(BankAccountRouting.AccountRoutingScheme, accountRouting.scheme))
- .map(_.delete_!)
- )
- )
+ oldAccountRoutings.filterNot(accountRouting => accountRoutings.exists(_.scheme == accountRouting.accountRouting.scheme))
+ .foreach(_.delete_!)
(for {
- (account, callContext) <- LocalMappedConnector.getBankAccountCommon(bankId, accountId, callContext)
+ (account, _) <- LocalMappedConnector.getBankAccountCommon(bankId, accountId, callContext)
} yield {
account
.kind(accountType)
diff --git a/obp-api/src/test/scala/code/api/berlin/group/v1_3/ConfirmationOfFundsServicePIISApiTest.scala b/obp-api/src/test/scala/code/api/berlin/group/v1_3/ConfirmationOfFundsServicePIISApiTest.scala
index 20a2155d7..57885795c 100644
--- a/obp-api/src/test/scala/code/api/berlin/group/v1_3/ConfirmationOfFundsServicePIISApiTest.scala
+++ b/obp-api/src/test/scala/code/api/berlin/group/v1_3/ConfirmationOfFundsServicePIISApiTest.scala
@@ -3,7 +3,7 @@ package code.api.berlin.group.v1_3
import com.openbankproject.commons.model.ErrorMessage
import code.api.builder.ConfirmationOfFundsServicePIISApi.APIMethods_ConfirmationOfFundsServicePIISApi
import code.api.util.APIUtil.OAuth._
-import code.api.util.ErrorMessages.{BankAccountNotFound, InvalidJsonContent, InvalidJsonFormat}
+import code.api.util.ErrorMessages.{BankAccountNotFound, BankAccountNotFoundByIban, InvalidJsonContent, InvalidJsonFormat}
import code.model.dataAccess.{BankAccountRouting, MappedBankAccount}
import code.setup.{APIResponse, DefaultUsers}
import com.github.dwickern.macros.NameOf.nameOf
@@ -34,7 +34,7 @@ class ConfirmationOfFundsServicePIISApiTest extends BerlinGroupServerSetupV1_3 w
Then("We should get a 404 ")
response.code should equal(404)
response.body.extract[ErrorMessage]
- .message should startWith(s"${BankAccountNotFound.replaceAll("BANK_ID and ACCOUNT_ID. ", "IBAN.")}")
+ .message should startWith(BankAccountNotFoundByIban)
}
scenario("Failed Case, invalid post json", BerlinGroupV1_3, PIIS, checkAvailabilityOfFunds) {
diff --git a/obp-commons/pom.xml b/obp-commons/pom.xml
index 734ddfb78..7d4f4bb8b 100644
--- a/obp-commons/pom.xml
+++ b/obp-commons/pom.xml
@@ -7,7 +7,7 @@
com.tesobe
obp-parent
../pom.xml
- 1.6.4
+ 1.7.0
obp-commons
jar
diff --git a/pom.xml b/pom.xml
index 6020d79e4..2008ce9a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.tesobe
obp-parent
- 1.6.4
+ 1.7.0
pom
Open Bank Project API Parent
2011