This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch custos-integration
in repository https://gitbox.apache.org/repos/asf/airavata-data-catalog.git


The following commit(s) were added to refs/heads/custos-integration by this 
push:
     new 9cad7f4  Fixes to Custos integration, primarily with the data product 
sharing view
9cad7f4 is described below

commit 9cad7f4f775a0e845f3c3cb7d862664dd66f82b7
Author: Marcus Christie <[email protected]>
AuthorDate: Mon May 15 16:46:24 2023 -0400

    Fixes to Custos integration, primarily with the data product sharing view
---
 .../api/client/DataCatalogAPIClient.java           |  3 +--
 .../api/sharing/SharingManagerImpl.java            |  4 ++--
 .../resources/custos_data_product_sharing_view.sql | 24 ----------------------
 .../custos-sharing/src/main/resources/schema.sql   | 24 ++++++++++++++++++++++
 4 files changed, 27 insertions(+), 28 deletions(-)

diff --git 
a/data-catalog-api/client/src/main/java/org/apache/airavata/datacatalog/api/client/DataCatalogAPIClient.java
 
b/data-catalog-api/client/src/main/java/org/apache/airavata/datacatalog/api/client/DataCatalogAPIClient.java
index 026cc82..f953835 100644
--- 
a/data-catalog-api/client/src/main/java/org/apache/airavata/datacatalog/api/client/DataCatalogAPIClient.java
+++ 
b/data-catalog-api/client/src/main/java/org/apache/airavata/datacatalog/api/client/DataCatalogAPIClient.java
@@ -44,8 +44,7 @@ import io.grpc.StatusRuntimeException;;
 public class DataCatalogAPIClient {
 
     private final DataCatalogAPIServiceBlockingStub blockingStub;
-    // String tenantId = "custos-e6vgzgskcr0pewrejma3-10000002";
-    String tenantId = "demotenant";
+    String tenantId = System.getenv("CUSTOS_CLIENT_ID") != null ? 
System.getenv("CUSTOS_CLIENT_ID") : "demotenant";
     String userId = "demouser";
     private final UserInfo userInfo = UserInfo.newBuilder()
             .setUserId(userId)
diff --git 
a/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/SharingManagerImpl.java
 
b/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/SharingManagerImpl.java
index fe96700..ea011d8 100644
--- 
a/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/SharingManagerImpl.java
+++ 
b/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/SharingManagerImpl.java
@@ -143,7 +143,7 @@ public class SharingManagerImpl implements SharingManager {
                     TenantEntity tenantEntity = resolveTenant(userInfo);
 
                     UserEntity userEntity = new UserEntity();
-                    userEntity.setExternalId(userProfile.getId());
+                    userEntity.setExternalId(userProfile.getUsername());
                     userEntity.setName(userProfile.getUsername());
                     userEntity.setTenant(tenantEntity);
                     return userRepository.save(userEntity);
@@ -173,7 +173,7 @@ public class SharingManagerImpl implements SharingManager {
 
     @Override
     public String getDataProductSharingView() {
-        return "data_catalog.custos_data_product_sharing_view";
+        return "custos_data_product_sharing_view";
     }
 
     @Override
diff --git 
a/data-catalog-api/server/custos-sharing/src/main/resources/custos_data_product_sharing_view.sql
 
b/data-catalog-api/server/custos-sharing/src/main/resources/custos_data_product_sharing_view.sql
deleted file mode 100644
index 527ce3c..0000000
--- 
a/data-catalog-api/server/custos-sharing/src/main/resources/custos_data_product_sharing_view.sql
+++ /dev/null
@@ -1,24 +0,0 @@
--- TODO: get this into a database migration script
-CREATE
-OR REPLACE VIEW custos_data_product_sharing_view AS
-SELECT
-    dp.data_product_id AS data_product_id,
-    s.associating_id AS user_id,
-    CASE
-        WHEN s.permission_type_id = concat('OWNER', s.tenant_id) THEN 0
-        WHEN s.permission_type_id = concat('READ', s.tenant_id) THEN 1
-        WHEN s.permission_type_id = concat('READ_METADATA', s.tenant_id) THEN 2
-        WHEN s.permission_type_id = concat('WRITE', s.tenant_id) THEN 3
-        WHEN s.permission_type_id = concat('WRITE_METADATA', s.tenant_id) THEN 
4
-        WHEN s.permission_type_id = concat('MANAGE_SHARING', s.tenant_id) THEN 
5
-        ELSE NULL
-    END AS permission_id
-FROM
-    sharing s
-    INNER JOIN tenant t ON t.external_id = s.tenant_id
-    INNER JOIN user_table u ON u.external_id = s.associating_id
-    AND u.tenant_id = t.tenant_id
-    INNER JOIN data_product dp ON concat(dp.external_id, t.external_id) = 
s.entity_id
-WHERE
-    -- TODO: add group support
-    s.associating_id_type = 'user';
diff --git 
a/data-catalog-api/server/custos-sharing/src/main/resources/schema.sql 
b/data-catalog-api/server/custos-sharing/src/main/resources/schema.sql
new file mode 100644
index 0000000..cfb1aa3
--- /dev/null
+++ b/data-catalog-api/server/custos-sharing/src/main/resources/schema.sql
@@ -0,0 +1,24 @@
+-- TODO: get this into a database migration script
+CREATE
+OR REPLACE VIEW custos_data_product_sharing_view AS
+SELECT
+    dp.data_product_id AS data_product_id,
+    u.user_id AS user_id,
+    CASE
+        WHEN s.permission_type_id = concat('OWNER', '@', s.tenant_id) THEN 0
+        WHEN s.permission_type_id = concat('READ', '@', s.tenant_id) THEN 1
+        WHEN s.permission_type_id = concat('READ_METADATA', '@', s.tenant_id) 
THEN 2
+        WHEN s.permission_type_id = concat('WRITE', '@', s.tenant_id) THEN 3
+        WHEN s.permission_type_id = concat('WRITE_METADATA', '@', s.tenant_id) 
THEN 4
+        WHEN s.permission_type_id = concat('MANAGE_SHARING', '@', s.tenant_id) 
THEN 5
+        ELSE NULL
+    END AS permission_id
+FROM
+    sharing s
+    INNER JOIN tenant t ON t.external_id = s.tenant_id
+    INNER JOIN user_table u ON u.external_id = s.associating_id
+    AND u.tenant_id = t.tenant_id
+    INNER JOIN data_product dp ON concat(dp.external_id, '@', t.external_id) = 
s.entity_id
+WHERE
+    -- TODO: add group support
+    s.associating_id_type = 'user';

Reply via email to