You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/06/06 15:53:35 UTC

[airavata] 01/02: AIRAVATA-2797 Add isUserResourceProfileExists to API instead of isNull flag

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

machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit d2811fbd0356688a14509ce640e7a4e981374884
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Jun 6 11:47:50 2018 -0400

    AIRAVATA-2797 Add isUserResourceProfileExists to API instead of isNull flag
---
 .../api/server/handler/AiravataServerHandler.java   | 18 ++++++++++++++++++
 .../api/service/handler/RegistryServerHandler.java  | 21 +++++++++++++++++++++
 .../airavata-apis/airavata_api.thrift               | 18 ++++++++++++++++++
 .../component-cpis/registry-api.thrift              | 15 +++++++++++++++
 .../user_resource_profile_model.thrift              |  4 ----
 5 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 49c32a6..7d0c5d8 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -4320,6 +4320,24 @@ public class AiravataServerHandler implements Airavata.Iface {
         }
     }
 
+    @Override
+    @SecurityCheck
+    public boolean isUserResourceProfileExists(AuthzToken authzToken, String userId, String gatewayID) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+        RegistryService.Client regClient = registryClientPool.getResource();
+        try {
+            boolean result = regClient.isUserResourceProfileExists(userId, gatewayID);
+            registryClientPool.returnResource(regClient);
+            return result;
+        } catch (Exception e) {
+            logger.error("Error while checking existence of user resource profile for " + userId, e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while checking existence of user resource profile. More info : " + e.getMessage());
+            registryClientPool.returnBrokenResource(regClient);
+            throw exception;
+        }
+    }
+
     /**
      * Fetch the given User Resource Profile.
      *
diff --git a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
index 2e491e5..59ac946 100644
--- a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
+++ b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
@@ -4298,6 +4298,27 @@ public class RegistryServerHandler implements RegistryService.Iface {
         }
     }
 
+    @Override
+    public boolean isUserResourceProfileExists(String userId, String gatewayId) throws RegistryServiceException, TException {
+        try {
+            if (!ExpCatResourceUtils.isUserExist(userId, gatewayId)){
+                logger.error("user does not exist.Please provide a valid gateway id...");
+                throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+            }
+            return userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayId);
+        } catch (AppCatalogException e) {
+            logger.error("Error while checking existence of user resource profile...", e);
+            RegistryServiceException exception = new RegistryServiceException();
+            exception.setMessage("Error while checking existence of user resource profile. More info : " + e.getMessage());
+            throw exception;
+        } catch (RegistryException e) {
+            logger.error("Error while checking existence of user resource profile...", e);
+            RegistryServiceException exception = new RegistryServiceException();
+            exception.setMessage("Error while checking existence of user resource profile. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
     /**
      * Fetch the given Gateway Resource Profile.
      *
diff --git a/thrift-interface-descriptions/airavata-apis/airavata_api.thrift b/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
index 0a43ecb..5568b4c 100644
--- a/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
+++ b/thrift-interface-descriptions/airavata-apis/airavata_api.thrift
@@ -3047,6 +3047,24 @@ service Airavata {
                 4: airavata_errors.AuthorizationException ae)
 
     /**
+     * Check if User Resource Profile exists.
+     *
+     * @param userId
+     *   The identifier for the requested user resource profile.
+     *
+     * @param gatewayID
+     *   The identifier to link a gateway for the requested user resource profile.
+     *
+     * @return bool
+     *
+    */
+    bool isUserResourceProfileExists(1: required security_model.AuthzToken authzToken,
+                  2: required string userId, 3: required string gatewayID)
+        	throws (1: airavata_errors.InvalidRequestException ire,
+                  2: airavata_errors.AiravataClientException ace,
+                  3: airavata_errors.AiravataSystemException ase,
+                  4: airavata_errors.AuthorizationException ae)
+    /**
      * Fetch the given User Resource Profile.
      *
      * @param userId
diff --git a/thrift-interface-descriptions/component-cpis/registry-api.thrift b/thrift-interface-descriptions/component-cpis/registry-api.thrift
index 06c5ec2..361ca6a 100644
--- a/thrift-interface-descriptions/component-cpis/registry-api.thrift
+++ b/thrift-interface-descriptions/component-cpis/registry-api.thrift
@@ -2201,6 +2201,21 @@ service RegistryService {
                      throws (1: registry_api_errors.RegistryServiceException rse)
 
                /**
+                * Check if the given User Resource Profile exists.
+                *
+                * @param userId
+                *   The identifier for the requested User Resource Profile.
+                *
+                * @param gatewayID
+                *   The identifier to link gateway for the requested User Resource Profile.
+                *
+                * @return true if User Resource Profile for these identifiers exists.
+                *
+               */
+               bool isUserResourceProfileExists(1: required string userId, 2: required string gatewayID)
+                     throws (1: registry_api_errors.RegistryServiceException rse)
+
+               /**
                 * Fetch the given User Resource Resource Profile.
                 *
                 * @param userId
diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
index 2d48e2c..fc76e7c 100644
--- a/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
+++ b/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
@@ -99,9 +99,6 @@ struct UserStoragePreference {
  *
  *  identityServerPwdCredToken:
  *
- * isNull:
- *  Indicates that this instance is just a container for a null value.
- *
 */
 struct UserResourceProfile {
     1: required string userId,
@@ -111,5 +108,4 @@ struct UserResourceProfile {
     5: optional list<UserStoragePreference> userStoragePreferences,
     6: optional string identityServerTenant,
     7: optional string identityServerPwdCredToken,
-    8: optional bool isNull = false
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.