From 34623632285485498c4e0bb5b49063ff64ec2a13 Mon Sep 17 00:00:00 2001 From: simonredfern Date: Thu, 22 Jan 2026 06:51:14 +0100 Subject: [PATCH] rebasefix: fixing errors introduced during rebase merging --- .../scala/code/api/v6_0_0/APIMethods600.scala | 16 +++---- .../code/api/v6_0_0/JSONFactory6.0.0.scala | 43 +------------------ .../code/api/v6_0_0/DynamicEntityTest.scala | 4 +- 3 files changed, 11 insertions(+), 52 deletions(-) diff --git a/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala b/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala index c9bfb4e1a..6f436a023 100644 --- a/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala +++ b/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala @@ -4643,7 +4643,7 @@ trait APIMethods600 { ), List( $BankNotFound, - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UserHasMissingRoles, UnknownError ), @@ -4789,7 +4789,7 @@ trait APIMethods600 { schema = net.liftweb.json.parse("""{"description": "User preferences", "required": ["theme"], "properties": {"theme": {"type": "string", "example": "dark"}, "language": {"type": "string", "example": "en"}}}""").asInstanceOf[net.liftweb.json.JsonAST.JObject] ), List( - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UserHasMissingRoles, InvalidJsonFormat, UnknownError @@ -4871,7 +4871,7 @@ trait APIMethods600 { ), List( $BankNotFound, - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UserHasMissingRoles, InvalidJsonFormat, UnknownError @@ -4940,7 +4940,7 @@ trait APIMethods600 { schema = net.liftweb.json.parse("""{"description": "User preferences updated", "required": ["theme"], "properties": {"theme": {"type": "string", "example": "dark"}, "language": {"type": "string", "example": "en"}, "notifications_enabled": {"type": "boolean", "example": "true"}}}""").asInstanceOf[net.liftweb.json.JsonAST.JObject] ), List( - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UserHasMissingRoles, InvalidJsonFormat, UnknownError @@ -5010,7 +5010,7 @@ trait APIMethods600 { ), List( $BankNotFound, - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UserHasMissingRoles, InvalidJsonFormat, UnknownError @@ -5079,7 +5079,7 @@ trait APIMethods600 { schema = net.liftweb.json.parse("""{"description": "User preferences updated", "required": ["theme"], "properties": {"theme": {"type": "string", "example": "dark"}, "language": {"type": "string", "example": "en"}, "notifications_enabled": {"type": "boolean", "example": "true"}}}""").asInstanceOf[net.liftweb.json.JsonAST.JObject] ), List( - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, InvalidJsonFormat, UnknownError ), @@ -6929,7 +6929,7 @@ trait APIMethods600 { ) ), List( - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UnknownError ), List(apiTagManageDynamicEntity, apiTagApi) @@ -6984,7 +6984,7 @@ trait APIMethods600 { ) ), List( - $UserNotLoggedIn, + $AuthenticatedUserIsRequired, UnknownError ), List(apiTagDynamicEntity, apiTagPersonalDynamicEntity, apiTagApi) diff --git a/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala b/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala index adf3865c1..fed14e065 100644 --- a/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala +++ b/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala @@ -1428,48 +1428,7 @@ object JSONFactory600 extends CustomJsonFormats with MdcLoggable { user_id = entity.userId, bank_id = entity.bankId, has_personal_entity = entity.hasPersonalEntity, - definition = schema, - record_count = recordCount - ) - } - ) - } - - /** - * Create v6.0.0 response for management GET endpoints (includes record_count) - */ - def createDynamicEntitiesWithCountJson( - entitiesWithCounts: List[(code.dynamicEntity.DynamicEntityCommons, Long)] - ): DynamicEntitiesWithCountJsonV600 = { - import net.liftweb.json.JsonAST._ - import net.liftweb.json.parse - - DynamicEntitiesWithCountJsonV600( - dynamic_entities = entitiesWithCounts.map { case (entity, recordCount) => - // metadataJson contains the full internal format: { "EntityName": { schema }, "hasPersonalEntity": true } - // We need to extract just the schema part using the entity name as key - val fullJson = parse(entity.metadataJson).asInstanceOf[JObject] - val schemaOption = fullJson.obj.find(_.name == entity.entityName).map(_.value.asInstanceOf[JObject]) - - // Validate that the dynamic key matches entity_name - val dynamicKeyName = fullJson.obj.find(_.name != "hasPersonalEntity").map(_.name) - if (dynamicKeyName.exists(_ != entity.entityName)) { - throw new IllegalStateException( - s"Dynamic entity key mismatch: stored entityName='${entity.entityName}' but dynamic key='${dynamicKeyName.getOrElse("none")}'" - ) - } - - val schemaObj = schemaOption.getOrElse( - throw new IllegalStateException(s"Could not extract schema for entity '${entity.entityName}' from metadataJson") - ) - - DynamicEntityDefinitionWithCountJsonV600( - dynamic_entity_id = entity.dynamicEntityId.getOrElse(""), - entity_name = entity.entityName, - user_id = entity.userId, - bank_id = entity.bankId, - has_personal_entity = entity.hasPersonalEntity, - schema = schemaObj, + schema = schema, record_count = recordCount ) } diff --git a/obp-api/src/test/scala/code/api/v6_0_0/DynamicEntityTest.scala b/obp-api/src/test/scala/code/api/v6_0_0/DynamicEntityTest.scala index d2dcd0a75..f4e402eca 100644 --- a/obp-api/src/test/scala/code/api/v6_0_0/DynamicEntityTest.scala +++ b/obp-api/src/test/scala/code/api/v6_0_0/DynamicEntityTest.scala @@ -175,8 +175,8 @@ class DynamicEntityTest extends V600ServerSetup { val response = makePostRequest(request, write(rightEntityV600)) Then("We should get a 401") response.code should equal(401) - And("error should be " + UserNotLoggedIn) - response.body.extract[ErrorMessage].message should equal(UserNotLoggedIn) + And("error should be " + AuthenticatedUserIsRequired) + response.body.extract[ErrorMessage].message should equal(AuthenticatedUserIsRequired) } scenario("Create System Dynamic Entity - without proper role", ApiEndpoint1, VersionOfApi) {