You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2017/04/05 19:10:50 UTC

[26/50] [abbrv] airavata git commit: Replacing sharing exception with Duplicate entry exception if entity already exists

Replacing sharing exception with Duplicate entry exception if entity already exists


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

Branch: refs/heads/develop
Commit: de241d6cc524901554c500eefcd143909629d51b
Parents: eff24f1
Author: Ajinkya Dhamnaskar <ad...@umail.iu.edu>
Authored: Tue Apr 4 15:44:54 2017 -0400
Committer: Ajinkya Dhamnaskar <ad...@umail.iu.edu>
Committed: Tue Apr 4 15:44:54 2017 -0400

----------------------------------------------------------------------
 .../server/SharingRegistryServerHandler.java      | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/de241d6c/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 1af4cd6..4f4fe9c 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
@@ -21,6 +21,7 @@
 package org.apache.airavata.sharing.registry.server;
 
 import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.model.error.DuplicateEntryException;
 import org.apache.airavata.sharing.registry.db.entities.*;
 import org.apache.airavata.sharing.registry.db.repositories.*;
 import org.apache.airavata.sharing.registry.db.utils.DBConstants;
@@ -53,7 +54,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         try{
             domain.setDomainId(domain.getDomainId());
             if((new DomainRepository()).get(domain.getDomainId()) != null)
-                throw new SharingRegistryException("There exist domain with given domain id");
+                throw new DuplicateEntryException("There exist domain with given domain id : " + domain.getDomainId());
 
             domain.setCreatedTime(System.currentTimeMillis());
             domain.setUpdatedTime(System.currentTimeMillis());
@@ -133,7 +134,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
             userPK.setUserId(user.getUserId());
             userPK.setDomainId(user.domainId);
             if((new UserRepository()).get(userPK) != null)
-                throw new SharingRegistryException("There exist user with given user id");
+                throw new DuplicateEntryException("There exist user with given user id : " + user.getUserId());
 
             user.setCreatedTime(System.currentTimeMillis());
             user.setUpdatedTime(System.currentTimeMillis());
@@ -423,7 +424,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
             entityTypePK.setDomainId(entityType.domainId);
             entityTypePK.setEntityTypeId(entityType.entityTypeId);
             if((new EntityTypeRepository()).get(entityTypePK) != null)
-                throw new SharingRegistryException("There exist EntityType with given EntityType id");
+                throw new DuplicateEntryException("There exist EntityType with given EntityType id : " + entityType.domainId);
 
             entityType.setCreatedTime(System.currentTimeMillis());
             entityType.setUpdatedTime(System.currentTimeMillis());
@@ -503,7 +504,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
             permissionTypePK.setDomainId(permissionType.domainId);
             permissionTypePK.setPermissionTypeId(permissionType.permissionTypeId);
             if((new PermissionTypeRepository()).get(permissionTypePK) != null)
-                throw new SharingRegistryException("There exist PermissionType with given PermissionType id");
+                throw new DuplicateEntryException("There exist PermissionType with given PermissionType id : " + permissionType.domainId);
             permissionType.setCreatedTime(System.currentTimeMillis());
             permissionType.setUpdatedTime(System.currentTimeMillis());
             (new PermissionTypeRepository()).create(permissionType);
@@ -725,12 +726,15 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
     }
 
     /**
-     * * Sharing Entity with Users and Groups
-     * *
      *
+     * @param domainId
      * @param entityId
      * @param userList
-     * @param permissionType
+     * @param permissionTypeId
+     * @param cascadePermission
+     * @return
+     * @throws SharingRegistryException
+     * @throws TException
      */
     @Override
     public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {