From 2f18a31a0f8bbe30a8062d2ff8755e033f2148bc Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Tue, 12 Sep 2023 09:45:31 -0700 Subject: [PATCH] Revert "Fix #11715: Add Owner EntityRef type validation (#13126)" (#13159) This reverts commit ba1e930910f304e1b590bbf785d64aa8d04c2953. --- .../service/exception/CatalogExceptionMessage.java | 4 ---- .../openmetadata/service/jdbi3/EntityRepository.java | 7 ++----- .../service/resources/EntityResourceTest.java | 10 ---------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java b/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java index 66fda534714..757dea0eb26 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java @@ -188,10 +188,6 @@ public final class CatalogExceptionMessage { return String.format("Team of type %s can't own entities. Only Team of type Group can own entities.", teamType); } - public static String invalidOwnerType(String entityType) { - return String.format("Entity of type %s can't be the owner. Only Team of type Group or a User can own entities.", entityType); - } - public static String failedToParse(String message) { return String.format("Failed to parse - %s", message); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java index f6d2a466aa8..c212698e130 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java @@ -639,7 +639,6 @@ public abstract class EntityRepository { prepare(entity, update); setFullyQualifiedName(entity); validateExtension(entity); - validateOwner(entity.getOwner()); // Domain is already validated } @@ -1580,7 +1579,6 @@ public abstract class EntityRepository { public void updateOwner(T ownedEntity, EntityReference originalOwner, EntityReference newOwner) { // TODO inefficient use replace instead of delete and add and check for orig and new owners being the same - validateOwner(newOwner); removeOwner(ownedEntity, originalOwner); storeOwner(ownedEntity, newOwner); } @@ -1640,9 +1638,8 @@ public abstract class EntityRepository { if (owner == null) { return null; } - if (!owner.getType().equals(Entity.TEAM) && !owner.getType().equals(USER)) { - throw new IllegalArgumentException(CatalogExceptionMessage.invalidOwnerType(owner.getType())); - } else if (owner.getType().equals(Entity.TEAM)) { // Entities can be only owned by team of type 'group' + // Entities can be only owned by team of type 'group' + if (owner.getType().equals(Entity.TEAM)) { Team team = Entity.getEntity(Entity.TEAM, owner.getId(), "", ALL); if (!team.getTeamType().equals(CreateTeam.TeamType.GROUP)) { throw new IllegalArgumentException(CatalogExceptionMessage.invalidTeamOwner(team.getTeamType())); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java index a2ff1c1c129..3ceba7a059a 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java @@ -1164,16 +1164,6 @@ public abstract class EntityResourceTest patchEntity(newEntity.getId(), newJson, newEntity, ADMIN_AUTH_HEADERS), - BAD_REQUEST, - "Entity of type testDefinition can't be the owner. Only Team of type Group or a User can own entities."); } @Test