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