mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:36:54 +00:00
docfix/Improve error handling at function grantAccessToViews
This commit is contained in:
parent
cddadabe85
commit
40ecb3f6c5
@ -631,7 +631,7 @@ OBP-20055 = estos parámetros de consulta':
|
||||
OBP-20056 = está desactivado para esta instancia de la API.
|
||||
OBP-20057 = no encontrado por userId.
|
||||
OBP-20058 = consumidor está deshabilitado.
|
||||
OBP-20059 = se ha podido obtener el estado de bloqueo del usuario.
|
||||
OBP-20059 = No se pudo asignar el acceso a la cuenta.
|
||||
sOBP-20060 = usuario no tiene acceso a la vista $SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID.
|
||||
OBP-20061 = usuario actual no tiene acceso a la vista
|
||||
OBP-20062 = frecuencia por día debe ser mayor que 0.
|
||||
|
||||
@ -4,9 +4,9 @@ import java.text.SimpleDateFormat
|
||||
import java.util.{Date, UUID}
|
||||
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{ConsentAccessJson, PostConsentJson}
|
||||
import code.api.util.ApiRole.{canCreateEntitlementAtAnyBank, canCreateEntitlementAtOneBank}
|
||||
import code.api.util.ErrorMessages.InvalidConnectorResponse
|
||||
import code.api.util.ErrorMessages.{InvalidConnectorResponse, NoViewReadAccountsBerlinGroup, CouldNotAssignAccountAccess}
|
||||
import code.api.v3_1_0.{PostConsentBodyCommonJson, PostConsentEntitlementJsonV310, PostConsentViewJsonV310}
|
||||
import code.api.{Constant, RequestHeader}
|
||||
import code.api.{APIFailure, Constant, RequestHeader}
|
||||
import code.bankconnectors.Connector
|
||||
import code.consent
|
||||
import code.consent.{ConsentStatus, Consents, MappedConsent}
|
||||
@ -300,7 +300,7 @@ object Consent extends MdcLoggable {
|
||||
val bankIdAccountIdViewId = BankIdAccountIdViewId(BankId(view.bank_id), AccountId(view.account_id),ViewId(view.view_id))
|
||||
Views.views.vend.revokeAccess(bankIdAccountIdViewId, user)
|
||||
}
|
||||
val result =
|
||||
val result: List[Box[View]] = {
|
||||
for {
|
||||
view <- consent.views
|
||||
} yield {
|
||||
@ -312,9 +312,13 @@ object Consent extends MdcLoggable {
|
||||
// It's not system view
|
||||
Views.views.vend.grantAccessToCustomView(bankIdAccountIdViewId, user)
|
||||
}
|
||||
"Added"
|
||||
}
|
||||
if (result.forall(_ == "Added")) Full(user) else Failure("Cannot add permissions to the user with id: " + user.userId)
|
||||
}
|
||||
val errorMessages: List[String] = result.filterNot(_.isDefined).map {
|
||||
case ParamFailure(_, _, _, APIFailure(msg, httpCode)) => msg
|
||||
case Failure(message, _, _) => message
|
||||
}
|
||||
if (errorMessages.isEmpty) Full(user) else Failure(CouldNotAssignAccountAccess + errorMessages.mkString(", "))
|
||||
}
|
||||
|
||||
private def applyConsentRulesCommonOldStyle(consentIdAsJwt: String, calContext: CallContext): Box[User] = {
|
||||
|
||||
@ -206,7 +206,7 @@ object ErrorMessages {
|
||||
val ElasticSearchDisabled = "OBP-20056: Elasticsearch is disabled for this API instance."
|
||||
val UserNotFoundByUserId = "OBP-20057: User not found by userId."
|
||||
val ConsumerIsDisabled = "OBP-20058: Consumer is disabled."
|
||||
val CouldNotGetUserLockStatus = "OBP-20059: Could not get the lock status of the user."
|
||||
val CouldNotAssignAccountAccess = "OBP-20059: Could not assign account access. "
|
||||
val NoViewReadAccountsBerlinGroup = s"OBP-20060: User does not have access to the view:"
|
||||
val FrequencyPerDayError = "OBP-20062: Frequency per day must be greater than 0."
|
||||
val FrequencyPerDayMustBeOneError = "OBP-20063: Frequency per day must be equal to 1 in case of one-off access."
|
||||
|
||||
@ -145,7 +145,7 @@ object MapperViews extends Views with MdcLoggable {
|
||||
getOrGrantAccessToViewCommon(user, v, bankIdAccountIdViewId.bankId.value, bankIdAccountIdViewId.accountId.value) //accountAccess already exists, no need to create one
|
||||
}
|
||||
case _ => {
|
||||
Empty ~> APIFailure(s"View $bankIdAccountIdViewId. not found", 404) //TODO: move message + code logic to api level
|
||||
Empty ~> APIFailure(s"View ${bankIdAccountIdViewId.viewId} not found", 404) //TODO: move message + code logic to api level
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user