From a3ef74920da47ea21a788609c58c4620020c8812 Mon Sep 17 00:00:00 2001 From: hongwei1 Date: Mon, 19 Feb 2018 09:37:19 +0100 Subject: [PATCH] added some comments --- src/main/scala/code/model/BankingData.scala | 11 +++++++++-- src/main/scala/code/model/User.scala | 9 +++++++-- src/main/scala/code/model/dataAccess/view.scala | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/scala/code/model/BankingData.scala b/src/main/scala/code/model/BankingData.scala index e20d9f4b36..63f85ebeb0 100644 --- a/src/main/scala/code/model/BankingData.scala +++ b/src/main/scala/code/model/BankingData.scala @@ -358,8 +358,15 @@ trait BankAccount extends MdcLoggable { } } - private def viewNotAllowed(view : View ) = Failure("user does not have access to the " + view.name + " view") - + private def viewNotAllowed(view : View ) = Failure(s"${UserNoPermissionAccessView} Current VIEW_ID (${view.viewId.value})") + + /** + * + * Check search for the bankaccount private views which the user have access to ++ public views. + * @param user a user + * @return a list of views, the user can access + * + */ final def permittedViews(user: Box[User]) : List[View] = { user match { case Full(u) => u.permittedViews(this) diff --git a/src/main/scala/code/model/User.scala b/src/main/scala/code/model/User.scala index bac190b05d..48edc9ac2d 100644 --- a/src/main/scala/code/model/User.scala +++ b/src/main/scala/code/model/User.scala @@ -77,9 +77,14 @@ trait User { Failure("user doesn't have access to any view that allows initiating transactions") } } - - + + /** + * return all the views the user has the access to. + */ def views: List[View] + /** + * Check the User have this `view` or not. + */ def permittedView(v: View): Boolean = views.contains(v) diff --git a/src/main/scala/code/model/dataAccess/view.scala b/src/main/scala/code/model/dataAccess/view.scala index 3ce43d35d3..997235b7cf 100644 --- a/src/main/scala/code/model/dataAccess/view.scala +++ b/src/main/scala/code/model/dataAccess/view.scala @@ -33,6 +33,7 @@ Berlin 13359, Germany package code.model.dataAccess import code.api.APIFailure +import code.api.util.ErrorMessages import code.util.{AccountIdString, UUIDString} import net.liftweb.common.{Box, Full} import net.liftweb.mapper._ @@ -522,7 +523,7 @@ object ViewImpl extends ViewImpl with LongKeyedMetaMapper[ViewImpl]{ def find(viewUID : ViewIdBankIdAccountId) : Box[ViewImpl] = { find(By(permalink_, viewUID.viewId.value) :: accountFilter(viewUID.bankId, viewUID.accountId): _*) ~> - APIFailure(s"View with permalink $viewId not found", 404) + APIFailure(s"${ErrorMessages.ViewNotFound}. Current ACCOUNT_ID(${viewUID.accountId.value}) and VIEW_ID (${viewUID.viewId.value})", 404) //TODO: APIFailures with http response codes belong at a higher level in the code }