airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [8/9] airavata git commit: adding isExists methods to sharing service
Date Tue, 07 Mar 2017 22:16:41 GMT
adding isExists methods to sharing service


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/536cca16
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/536cca16
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/536cca16

Branch: refs/heads/develop
Commit: 536cca166851be8d15a2edd1e909fb4f546b9940
Parents: 1306097
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Tue Mar 7 15:53:22 2017 -0500
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Tue Mar 7 17:16:04 2017 -0500

----------------------------------------------------------------------
 .../server/SharingRegistryServerHandler.java    |   105 +
 .../registry/SharingRegistryServiceTest.java    |     6 +
 .../service/cpi/SharingRegistryService.java     | 19547 +++++++++++------
 .../sharing-service-docs/api-docs/index.html    |     6 +
 .../api-docs/sharing_cpi.html                   |    35 +
 .../api-docs/sharing_models.html                |     2 -
 .../thrift_models/sharing_cpi.thrift            |    24 +
 7 files changed, 13136 insertions(+), 6589 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/536cca16/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
index 5a222ce..6fb2a12 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -90,6 +90,21 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         }
     }
 
+    /**
+     * <p>API method to check Domain Exists</p>
+     *
+     * @param domainId
+     */
+    @Override
+    public boolean isDomainExists(String domainId) throws SharingRegistryException, TException
{
+        try{
+            return (new DomainRepository()).isExists(domainId);
+        }catch (SharingRegistryException ex) {
+            logger.error(ex.getMessage(), ex);
+            throw ex;
+        }
+    }
+
     @Override
     public boolean deleteDomain(String domainId) throws SharingRegistryException, TException
{
         try{
@@ -181,6 +196,24 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         }
     }
 
+    /**
+     * <p>API method to check User Exists</p>
+     *
+     * @param userId
+     */
+    @Override
+    public boolean isUserExists(String domainId, String userId) throws SharingRegistryException,
TException {
+        try{
+            UserPK userPK = new UserPK();
+            userPK.setDomainId(domainId);
+            userPK.setUserId(userId);
+            return (new UserRepository()).isExists(userPK);
+        }catch (SharingRegistryException ex) {
+            logger.error(ex.getMessage(), ex);
+            throw ex;
+        }
+    }
+
     @Override
     public boolean deleteUser(String domainId, String userId) throws SharingRegistryException,
TException {
         try{
@@ -275,6 +308,24 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         }
     }
 
+    /**
+     * <p>API method to check Group Exists</p>
+     *
+     * @param group
+     */
+    @Override
+    public boolean isGroupExists(String domainId, String groupId) throws SharingRegistryException,
TException {
+        try{
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setDomainId(domainId);
+            userGroupPK.setGroupId(groupId);
+            return (new UserGroupRepository()).isExists(userGroupPK);
+        }catch (SharingRegistryException ex) {
+            logger.error(ex.getMessage(), ex);
+            throw ex;
+        }
+    }
+
     @Override
     public boolean deleteGroup(String domainId, String groupId) throws SharingRegistryException,
TException {
         try{
@@ -452,6 +503,24 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         }
     }
 
+    /**
+     * <p>API method to check EntityType Exists</p>
+     *
+     * @param entityTypeId
+     */
+    @Override
+    public boolean isEntityTypeExists(String domainId, String entityTypeId) throws SharingRegistryException,
TException {
+        try{
+            EntityTypePK entityTypePK = new EntityTypePK();
+            entityTypePK.setDomainId(domainId);
+            entityTypePK.setEntityTypeId(entityTypeId);
+            return (new EntityTypeRepository()).isExists(entityTypePK);
+        }catch (SharingRegistryException ex) {
+            logger.error(ex.getMessage(), ex);
+            throw ex;
+        }
+    }
+
     @Override
     public boolean deleteEntityType(String domainId, String entityTypeId) throws SharingRegistryException,
TException {
         try{
@@ -530,6 +599,24 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         }
     }
 
+    /**
+     * <p>API method to check Permission Exists</p>
+     *
+     * @param permissionId
+     */
+    @Override
+    public boolean isPermissionExists(String domainId, String permissionId) throws SharingRegistryException,
TException {
+        try{
+            PermissionTypePK permissionTypePK = new PermissionTypePK();
+            permissionTypePK.setDomainId(domainId);
+            permissionTypePK.setPermissionTypeId(permissionId);
+            return (new PermissionTypeRepository()).isExists(permissionTypePK);
+        }catch (SharingRegistryException ex) {
+            logger.error(ex.getMessage(), ex);
+            throw ex;
+        }
+    }
+
     @Override
     public boolean deletePermissionType(String domainId, String permissionTypeId) throws
SharingRegistryException, TException {
         try{
@@ -659,6 +746,24 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         }
     }
 
+    /**
+     * <p>API method to check Entity Exists</p>
+     *
+     * @param entityId
+     */
+    @Override
+    public boolean isEntityExists(String domainId, String entityId) throws SharingRegistryException,
TException {
+        try{
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(domainId);
+            entityPK.setEntityId(entityId);
+            return (new EntityRepository()).isExists(entityPK);
+        }catch (SharingRegistryException ex) {
+            logger.error(ex.getMessage(), ex);
+            throw ex;
+        }
+    }
+
     @Override
     public boolean deleteEntity(String domainId, String entityId) throws SharingRegistryException,
TException {
         try{

http://git-wip-us.apache.org/repos/asf/airavata/blob/536cca16/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
index f678282..ad5e9f3 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
@@ -72,6 +72,7 @@ public class SharingRegistryServiceTest {
         domain.setDescription("test domain description");
 
         String domainId = sharingServiceClient.createDomain(domain);
+        Assert.assertTrue(sharingServiceClient.isDomainExists(domainId));
 
         User user1 = new User();
         //required
@@ -91,6 +92,7 @@ public class SharingRegistryServiceTest {
         //user1.setIcon(icon1);
 
         sharingServiceClient.createUser(user1);
+        Assert.assertTrue(sharingServiceClient.isUserExists(domainId, "test-user-1"));
 
         User user2 = new User();
         //required
@@ -145,6 +147,7 @@ public class SharingRegistryServiceTest {
         userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
 
         sharingServiceClient.createGroup(userGroup1);
+        Assert.assertTrue(sharingServiceClient.isGroupExists(domainId, "test-group-1"));
 
         UserGroup userGroup2 = new UserGroup();
         //required
@@ -176,6 +179,7 @@ public class SharingRegistryServiceTest {
         //optional
         permissionType1.setDescription("READ description");
         sharingServiceClient.createPermissionType(permissionType1);
+        Assert.assertTrue(sharingServiceClient.isPermissionExists(domainId, "READ"));
 
         PermissionType permissionType2 = new PermissionType();
         permissionType2.setPermissionTypeId("WRITE");
@@ -201,6 +205,7 @@ public class SharingRegistryServiceTest {
         //optional
         entityType1.setDescription("PROJECT entity type description");
         sharingServiceClient.createEntityType(entityType1);
+        Assert.assertTrue(sharingServiceClient.isEntityTypeExists(domainId, "PROJECT"));
 
         EntityType entityType2 = new EntityType();
         entityType2.setEntityTypeId("EXPERIMENT");
@@ -236,6 +241,7 @@ public class SharingRegistryServiceTest {
         //optional - If not set this will be default to current system time
         entity1.setOriginalEntityCreationTime(System.currentTimeMillis());
         sharingServiceClient.createEntity(entity1);
+        Assert.assertTrue(sharingServiceClient.isEntityExists(domainId, "test-project-1"));
 
         Entity entity2 = new Entity();
         entity2.setEntityId("test-experiment-1");


Mime
View raw message