From 7f10cfb22b8c9f9583986905119de11c6feb20ae Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Mon, 20 Sep 2021 16:01:24 -0700 Subject: [PATCH] =?UTF-8?q?Issue=20#535:=20User=20is=20not=20able=20to=20c?= =?UTF-8?q?laim=20ownership=20of=20the=20Topics=20and=20das=E2=80=A6=20(#5?= =?UTF-8?q?36)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Issue #535: User is not able to claim ownership of the Topics and dashboards entity. --- .../org/openmetadata/catalog/jdbi3/DashboardRepository.java | 5 +++++ .../java/org/openmetadata/catalog/jdbi3/TopicRepository.java | 5 +++++ .../catalog/resources/dashboards/DashboardResource.java | 2 +- .../openmetadata/catalog/resources/topics/TopicResource.java | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java index 0bf2f6800eb..533aac3e662 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/DashboardRepository.java @@ -207,6 +207,11 @@ public abstract class DashboardRepository { relationshipDAO().deleteAll(id); } + @Transaction + public EntityReference getOwnerReference(Dashboard dashboard) throws IOException { + return EntityUtil.populateOwner(userDAO(), teamDAO(), dashboard.getOwner()); + } + public static List toEntityReference(List charts) { List refList = new ArrayList<>(); for (Chart chart: charts) { diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java index 8fac1658f92..4b3bb292d17 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TopicRepository.java @@ -185,6 +185,11 @@ public abstract class TopicRepository { return updated; } + @Transaction + public EntityReference getOwnerReference(Topic topic) throws IOException { + return EntityUtil.populateOwner(userDAO(), teamDAO(), topic.getOwner()); + } + public Topic createInternal(Topic topic, EntityReference service, EntityReference owner) throws IOException { topic.setFullyQualifiedName(getFQN(service, topic)); EntityUtil.populateOwner(userDAO(), teamDAO(), owner); // Validate owner diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/dashboards/DashboardResource.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/dashboards/DashboardResource.java index 706dbda2e5e..28cd9b86d69 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/dashboards/DashboardResource.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/dashboards/DashboardResource.java @@ -255,7 +255,7 @@ public class DashboardResource { Fields fields = new Fields(FIELD_LIST, FIELDS); Dashboard dashboard = dao.get(id, fields); SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, - EntityUtil.getEntityReference(dashboard)); + dao.getOwnerReference(dashboard)); dashboard = dao.patch(id, patch); return addHref(uriInfo, dashboard); } diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/topics/TopicResource.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/topics/TopicResource.java index d448130b4bc..ed96c2e6315 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/topics/TopicResource.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/resources/topics/TopicResource.java @@ -254,7 +254,7 @@ public class TopicResource { Fields fields = new Fields(FIELD_LIST, FIELDS); Topic topic = dao.get(id, fields); SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, - EntityUtil.getEntityReference(topic)); + dao.getOwnerReference(topic)); topic = dao.patch(id, patch); return addHref(uriInfo, topic); }