Repository: airavata
Updated Branches:
  refs/heads/develop 81d8dee38 -> 7c6c56253


moving sharing registry initialization to AiravataServerHandler


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

Branch: refs/heads/develop
Commit: 7c6c562533efbb5a42ab136b9a7a61a5d8d9b9e5
Parents: 81d8dee
Author: scnakandala <supun.nakand...@gmail.com>
Authored: Wed Oct 12 11:46:50 2016 -0400
Committer: scnakandala <supun.nakand...@gmail.com>
Committed: Wed Oct 12 11:46:50 2016 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 59 ++++++++++++++++++--
 .../server/SharingRegistryServerHandler.java    | 53 ------------------
 2 files changed, 55 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/7c6c5625/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
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 1a64ef8..a0a563c 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
@@ -77,10 +77,7 @@ import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.registry.api.RegistryService;
 import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
 import org.apache.airavata.registry.api.exception.RegistryServiceException;
-import org.apache.airavata.sharing.registry.models.Domain;
-import org.apache.airavata.sharing.registry.models.Entity;
-import org.apache.airavata.sharing.registry.models.EntityType;
-import org.apache.airavata.sharing.registry.models.PermissionType;
+import org.apache.airavata.sharing.registry.models.*;
 import 
org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
@@ -102,6 +99,7 @@ public class AiravataServerHandler implements Airavata.Iface 
{
             experimentPublisher = 
MessagingFactory.getPublisher(Type.EXPERIMENT_LAUNCH);
 
             sharingRegistryServerHandler = new SharingRegistryServerHandler();
+            initSharingRegistry();
         } catch (ApplicationSettingsException e) {
             logger.error("Error occured while reading airavata-server 
properties..", e);
         } catch (AiravataException e) {
@@ -111,6 +109,59 @@ public class AiravataServerHandler implements 
Airavata.Iface {
         }
     }
 
+    private void initSharingRegistry() throws ApplicationSettingsException, 
TException {
+        
if(sharingRegistryServerHandler.getDomain(ServerSettings.getDefaultUserGateway())
 == null){
+            Domain domain = new Domain();
+            domain.setDomainId(ServerSettings.getDefaultUserGateway());
+            domain.setName(ServerSettings.getDefaultUserGateway());
+            domain.setDescription("Domain entry for " + domain.name);
+            sharingRegistryServerHandler.createDomain(domain);
+
+            User user = new User();
+            user.setDomainId(domain.domainId);
+            
user.setUserId(ServerSettings.getDefaultUser()+"@"+ServerSettings.getDefaultUserGateway());
+            user.setUserName(ServerSettings.getDefaultUser());
+            sharingRegistryServerHandler.createUser(user);
+
+            //Creating Entity Types for each domain
+            EntityType entityType = new EntityType();
+            entityType.setEntityTypeId(domain.domainId+":PROJECT");
+            entityType.setDomainId(domain.domainId);
+            entityType.setName("PROJECT");
+            entityType.setDescription("Project entity type");
+            sharingRegistryServerHandler.createEntityType(entityType);
+
+            entityType = new EntityType();
+            entityType.setEntityTypeId(domain.domainId+":EXPERIMENT");
+            entityType.setDomainId(domain.domainId);
+            entityType.setName("EXPERIMENT");
+            entityType.setDescription("Experiment entity type");
+            sharingRegistryServerHandler.createEntityType(entityType);
+
+            entityType = new EntityType();
+            entityType.setEntityTypeId(domain.domainId+":FILE");
+            entityType.setDomainId(domain.domainId);
+            entityType.setName("FILE");
+            entityType.setDescription("File entity type");
+            sharingRegistryServerHandler.createEntityType(entityType);
+
+            //Creating Permission Types for each domain
+            PermissionType permissionType = new PermissionType();
+            permissionType.setPermissionTypeId(domain.domainId+":READ");
+            permissionType.setDomainId(domain.domainId);
+            permissionType.setName("READ");
+            permissionType.setDescription("Read permission type");
+            sharingRegistryServerHandler.createPermissionType(permissionType);
+
+            permissionType = new PermissionType();
+            permissionType.setPermissionTypeId(domain.domainId+":WRITE");
+            permissionType.setDomainId(domain.domainId);
+            permissionType.setName("WRITE");
+            permissionType.setDescription("Write permission type");
+            sharingRegistryServerHandler.createPermissionType(permissionType);
+        }
+    }
+
     /**
      * Query Airavata to fetch the API version
      */

http://git-wip-us.apache.org/repos/asf/airavata/blob/7c6c5625/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
 
b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
index 8716252..1c7714f 100644
--- 
a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ 
b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -21,7 +21,6 @@
 package org.apache.airavata.sharing.registry.server;
 
 import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
 import 
org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntityPK;
 import org.apache.airavata.sharing.registry.db.entities.SharingEntityPK;
 import org.apache.airavata.sharing.registry.db.repositories.*;
@@ -61,58 +60,6 @@ public class SharingRegistryServerHandler implements 
GovRegistryService.Iface{
         this.permissionTypeRepository = new PermissionTypeRepository();
         this.entityRepository = new EntityRepository();
         this.sharingRepository = new SharingRepository();
-
-        if(!domainRepository.isExists(ServerSettings.getDefaultUserGateway())){
-            Domain domain = new Domain();
-            domain.setDomainId(ServerSettings.getDefaultUserGateway());
-            domain.setName(ServerSettings.getDefaultUserGateway());
-            domain.setDescription("Domain entry for " + domain.name);
-            createDomain(domain);
-
-            User user = new User();
-            user.setDomainId(domain.domainId);
-            
user.setUserId(ServerSettings.getDefaultUser()+"@"+ServerSettings.getDefaultUserGateway());
-            user.setUserName(ServerSettings.getDefaultUser());
-            createUser(user);
-
-            //Creating Entity Types for each domain
-            EntityType entityType = new EntityType();
-            entityType.setEntityTypeId(domain.domainId+":PROJECT");
-            entityType.setDomainId(domain.domainId);
-            entityType.setName("PROJECT");
-            entityType.setDescription("Project entity type");
-            createEntityType(entityType);
-
-            entityType = new EntityType();
-            entityType.setEntityTypeId(domain.domainId+":EXPERIMENT");
-            entityType.setDomainId(domain.domainId);
-            entityType.setName("EXPERIMENT");
-            entityType.setDescription("Experiment entity type");
-            createEntityType(entityType);
-
-            entityType = new EntityType();
-            entityType.setEntityTypeId(domain.domainId+":FILE");
-            entityType.setDomainId(domain.domainId);
-            entityType.setName("FILE");
-            entityType.setDescription("File entity type");
-            createEntityType(entityType);
-
-            //Creating Permission Types for each domain
-            PermissionType permissionType = new PermissionType();
-            permissionType.setPermissionTypeId(domain.domainId+":READ");
-            permissionType.setDomainId(domain.domainId);
-            permissionType.setName("READ");
-            permissionType.setDescription("Read permission type");
-            createPermissionType(permissionType);
-
-            permissionType = new PermissionType();
-            permissionType.setPermissionTypeId(domain.domainId+":WRITE");
-            permissionType.setDomainId(domain.domainId);
-            permissionType.setName("WRITE");
-            permissionType.setDescription("Write permission type");
-            createPermissionType(permissionType);
-
-        }
     }
 
     /**

Reply via email to