airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: renaming some classed to Sharing instead of Gov
Date Wed, 05 Oct 2016 07:50:25 GMT
Repository: airavata
Updated Branches:
  refs/heads/airavata-gov-registry a47c6383b -> d24852ae7


renaming some classed to Sharing instead of Gov


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

Branch: refs/heads/airavata-gov-registry
Commit: d24852ae7ce2c9d34aecaaec94f4ed7cba634cf6
Parents: a47c638
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Wed Oct 5 03:50:21 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Wed Oct 5 03:50:21 2016 -0400

----------------------------------------------------------------------
 .../airavata/sharing/registry/DataMigrator.java |   4 +-
 .../repositories/PermissionTypeRepository.java  |   6 +-
 .../sharing/registry/db/utils/JPAUtils.java     |  22 +-
 .../registry/server/GovRegistryServer.java      |  28 -
 .../server/GovRegistryServerHandler.java        | 585 -------------------
 .../registry/server/SharingRegistryServer.java  |  28 +
 .../server/SharingRegistryServerHandler.java    | 585 +++++++++++++++++++
 .../src/main/resources/META-INF/persistence.xml |   2 +-
 .../src/main/resources/gov-registry.sql         | 139 -----
 .../src/main/resources/sharing-registry.sql     | 139 +++++
 .../registry/GovRegistryServerHandlerTest.java  |   4 +-
 11 files changed, 771 insertions(+), 771 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/DataMigrator.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/DataMigrator.java b/modules/airavata-sharing-registry/airavata-sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/DataMigrator.java
index ccc0c41..5e747dc 100644
--- a/modules/airavata-sharing-registry/airavata-sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/DataMigrator.java
+++ b/modules/airavata-sharing-registry/airavata-sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/DataMigrator.java
@@ -21,7 +21,7 @@
 package org.apache.airavata.sharing.registry;
 
 import org.apache.airavata.sharing.registry.models.*;
-import org.apache.airavata.sharing.registry.server.GovRegistryServerHandler;
+import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,7 +39,7 @@ public class DataMigrator {
     public static void main(String[] args) throws SQLException, ClassNotFoundException, TException {
         Connection expCatConnection = ConnectionFactory.getInstance().getExpCatConnection();
 
-        GovRegistryServerHandler govRegistryServerHandler = new GovRegistryServerHandler();
+        SharingRegistryServerHandler govRegistryServerHandler = new SharingRegistryServerHandler();
 
         String query = "SELECT * FROM GATEWAY";
         Statement statement = expCatConnection.createStatement();

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
index 03449e8..e61f1ec 100644
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
@@ -24,7 +24,7 @@ import org.apache.airavata.sharing.registry.db.entities.PermissionTypeEntity;
 import org.apache.airavata.sharing.registry.db.utils.DBConstants;
 import org.apache.airavata.sharing.registry.models.GovRegistryException;
 import org.apache.airavata.sharing.registry.models.PermissionType;
-import org.apache.airavata.sharing.registry.server.GovRegistryServerHandler;
+import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,11 +41,11 @@ public class PermissionTypeRepository extends AbstractRepository<PermissionType,
     public String getGlobalPermissionTypeIdForDomain(String domainId) throws GovRegistryException {
         HashMap<String, String> filters = new HashMap<>();
         filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domainId);
-        filters.put(DBConstants.PermissionTypeTable.NAME, GovRegistryServerHandler.GLOBAL_PERMISSION_NAME);
+        filters.put(DBConstants.PermissionTypeTable.NAME, SharingRegistryServerHandler.GLOBAL_PERMISSION_NAME);
         List<PermissionType> permissionTypeList = select(filters, 0, -1);
         if(permissionTypeList.size() != 1){
             throw new GovRegistryException("GLOBAL Permission inconsistency. Found " + permissionTypeList.size()
-                    + " records with " + GovRegistryServerHandler.GLOBAL_PERMISSION_NAME + " name");
+                    + " records with " + SharingRegistryServerHandler.GLOBAL_PERMISSION_NAME + " name");
         }
         return permissionTypeList.get(0).getPermissionTypeId();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
index 7f31d7f..5d4c910 100644
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
@@ -33,12 +33,12 @@ import java.util.Map;
 public class JPAUtils {
     private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
 
-    private static final String PERSISTENCE_UNIT_NAME = "airavata-gov-registry";
-    private static final String GOV_REG_JDBC_DRIVER = "appcatalog.jdbc.driver";
-    private static final String GOV_REG_JDBC_URL = "appcatalog.jdbc.url";
-    private static final String GOV_REG_JDBC_USER = "appcatalog.jdbc.user";
-    private static final String GOV_REG_JDBC_PWD = "appcatalog.jdbc.password";
-    private static final String GOV_REG_VALIDATION_QUERY = "appcatalog.validationQuery";
+    private static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
+    private static final String SHARING_REG_JDBC_DRIVER = "appcatalog.jdbc.driver";
+    private static final String SHARING_REG_JDBC_URL = "appcatalog.jdbc.url";
+    private static final String SHARING_REG_JDBC_USER = "appcatalog.jdbc.user";
+    private static final String SHARING_REG_JDBC_PWD = "appcatalog.jdbc.password";
+    private static final String SHARING_REG_VALIDATION_QUERY = "appcatalog.validationQuery";
     private static final String JPA_CACHE_SIZE = "jpa.cache.size";
     private static final String JPA_CACHE_ENABLED = "cache.enable";
 
@@ -49,11 +49,11 @@ public class JPAUtils {
 
     public static EntityManager getEntityManager() {
         if (factory == null) {
-//            String connectionProperties = "DriverClassName=" + readServerProperties(GOV_REG_JDBC_DRIVER) + "," +
-//                    "Url=" + readServerProperties(GOV_REG_JDBC_URL) + "?autoReconnect=true," +
-//                    "Username=" + readServerProperties(GOV_REG_JDBC_USER) + "," +
-//                    "Password=" + readServerProperties(GOV_REG_JDBC_PWD) +
-//                    ",validationQuery=" + readServerProperties(GOV_REG_VALIDATION_QUERY);
+//            String connectionProperties = "DriverClassName=" + readServerProperties(SHARING_REG_JDBC_DRIVER) + "," +
+//                    "Url=" + readServerProperties(SHARING_REG_JDBC_URL) + "?autoReconnect=true," +
+//                    "Username=" + readServerProperties(SHARING_REG_JDBC_USER) + "," +
+//                    "Password=" + readServerProperties(SHARING_REG_JDBC_PWD) +
+//                    ",validationQuery=" + readServerProperties(SHARING_REG_VALIDATION_QUERY);
 //
 
             String connectionProperties = "DriverClassName=com.mysql.jdbc.Driver," +

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServer.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServer.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServer.java
deleted file mode 100644
index 764bda0..0000000
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.sharing.registry.server;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GovRegistryServer {
-    private final static Logger logger = LoggerFactory.getLogger(GovRegistryServer.class);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServerHandler.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServerHandler.java
deleted file mode 100644
index 9684c74..0000000
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServerHandler.java
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.sharing.registry.server;
-
-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.*;
-import org.apache.airavata.sharing.registry.db.utils.DBConstants;
-import org.apache.airavata.sharing.registry.models.*;
-import org.apache.airavata.sharing.registry.service.cpi.GovRegistryService;
-import org.apache.thrift.TException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.util.*;
-
-public class GovRegistryServerHandler implements GovRegistryService.Iface{
-    private final static Logger logger = LoggerFactory.getLogger(GovRegistryServerHandler.class);
-
-    public static String GLOBAL_PERMISSION_NAME = "GLOBAL";
-
-    private DomainRepository domainRepository;
-    private UserRepository userRepository;
-    private UserGroupRepository userGroupRepository;
-    private GroupMembershipRepository groupMembershipRepository;
-    private EntityTypeRepository entityTypeRepository;
-    private PermissionTypeRepository permissionTypeRepository;
-    private EntityRepository entityRepository;
-    private SharingRepository sharingRepository;
-
-    public GovRegistryServerHandler(){
-        this.domainRepository = new DomainRepository();
-        this.userRepository = new UserRepository();
-        this.userGroupRepository = new UserGroupRepository();
-        this.groupMembershipRepository = new GroupMembershipRepository();
-        this.entityTypeRepository = new EntityTypeRepository();
-        this.permissionTypeRepository = new PermissionTypeRepository();
-        this.entityRepository = new EntityRepository();
-        this.sharingRepository = new SharingRepository();
-    }
-
-    /**
-     * * Domain Operations
-     * *
-     */
-    @Override
-    public String createDomain(Domain domain) throws GovRegistryException, TException {
-        if(domainRepository.get(domain.domainId) != null)
-            throw new GovRegistryException("There exist domain with given domain id");
-
-        domain.setCreatedTime(System.currentTimeMillis());
-        domain.setUpdatedTime(System.currentTimeMillis());
-        domainRepository.create(domain);
-
-        //create the global permission for the domain
-        PermissionType permissionType = new PermissionType();
-        permissionType.setPermissionTypeId(domain.domainId+":"+GLOBAL_PERMISSION_NAME);
-        permissionType.setDomainId(domain.domainId);
-        permissionType.setName(GLOBAL_PERMISSION_NAME);
-        permissionType.setDescription("GLOBAL permission to " + domain.domainId);
-        permissionType.setCreatedTime(System.currentTimeMillis());
-        permissionType.setUpdatedTime(System.currentTimeMillis());
-        permissionTypeRepository.create(permissionType);
-
-        return domain.domainId;
-    }
-
-    @Override
-    public boolean updateDomain(Domain domain) throws GovRegistryException, TException {
-        Domain oldDomain = domainRepository.get(domain.domainId);
-        domain.setCreatedTime(oldDomain.createdTime);
-        domain.setUpdatedTime(System.currentTimeMillis());
-        domain = getUpdatedObject(oldDomain, domain);
-        domainRepository.update(domain);
-        return true;
-    }
-
-    @Override
-    public boolean deleteDomain(String domainId) throws GovRegistryException, TException {
-        domainRepository.delete(domainId);
-        return true;
-    }
-
-    @Override
-    public Domain getDomain(String domainId) throws GovRegistryException, TException {
-        return domainRepository.get(domainId);
-    }
-
-    @Override
-    public List<Domain> getDomains(int offset, int limit) throws TException {
-        return domainRepository.select(new HashMap<>(), offset, limit);
-    }
-
-    /**
-     * * User Operations
-     * *
-     */
-    @Override
-    public String createUser(User user) throws GovRegistryException, TException {
-        if(userRepository.get(user.userId) != null)
-            throw new GovRegistryException("There exist user with given user id");
-
-        user.setCreatedTime(System.currentTimeMillis());
-        user.setUpdatedTime(System.currentTimeMillis());
-        userRepository.create(user);
-
-        UserGroup userGroup = new UserGroup();
-        userGroup.setGroupId(user.userId);
-        userGroup.setDomainId(user.domainId);
-        userGroup.setName(user.userName);
-        userGroup.setDescription("user " + user.userName + " group");
-        userGroup.setOwnerId(user.userId);
-        userGroup.setGroupType(GroupType.SINGLE_USER);
-        createGroup(userGroup);
-
-        return user.userId;
-    }
-
-    @Override
-    public boolean updatedUser(User user) throws GovRegistryException, TException {
-        User oldUser = userRepository.get(user.userId);
-        user.setCreatedTime(oldUser.createdTime);
-        user.setUpdatedTime(System.currentTimeMillis());
-        user = getUpdatedObject(oldUser, user);
-        userRepository.update(user);
-
-        UserGroup userGroup = userGroupRepository.get(user.userId);
-        userGroup.setName(user.userName);
-        userGroup.setDescription("user " + user.userName + " group");
-        updateGroup(userGroup);
-        return true;
-    }
-
-    @Override
-    public boolean deleteUser(String userId) throws GovRegistryException, TException {
-        userRepository.delete(userId);
-        userGroupRepository.delete(userId);
-        return true;
-    }
-
-    @Override
-    public User getUser(String userId) throws GovRegistryException, TException {
-        return userRepository.get(userId);
-    }
-
-    @Override
-    public List<User> getUsers(String domain, int offset, int limit) throws  GovRegistryException, TException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
-        return userRepository.select(filters, offset, limit);
-    }
-
-    /**
-     * * Group Operations
-     * *
-     */
-    @Override
-    public String createGroup(UserGroup group) throws GovRegistryException, TException {
-        if(userGroupRepository.get(group.groupId) != null)
-            throw new GovRegistryException("There exist group with given group id");
-
-        group.setCreatedTime(System.currentTimeMillis());
-        group.setUpdatedTime(System.currentTimeMillis());
-        userGroupRepository.create(group);
-        return group.groupId;
-    }
-
-    @Override
-    public boolean updateGroup(UserGroup group) throws GovRegistryException, TException {
-        group.setUpdatedTime(System.currentTimeMillis());
-        UserGroup oldGroup = userGroupRepository.get(group.groupId);
-        group.setCreatedTime(oldGroup.createdTime);
-        group = getUpdatedObject(oldGroup, group);
-        userGroupRepository.update(group);
-        return true;
-    }
-
-    @Override
-    public boolean deleteGroup(String groupId) throws GovRegistryException, TException {
-        userGroupRepository.delete(groupId);
-        return true;
-    }
-
-    @Override
-    public UserGroup getGroup(String groupId) throws GovRegistryException, TException {
-        return userGroupRepository.get(groupId);
-    }
-
-    @Override
-    public List<UserGroup> getGroups(String domain, int offset, int limit) throws TException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
-        return userGroupRepository.select(filters, offset, limit);
-    }
-
-    @Override
-    public boolean addUsersToGroup(List<String> userIds, String groupId) throws GovRegistryException, TException {
-        for(int i=0; i < userIds.size(); i++){
-            GroupMembership groupMembership = new GroupMembership();
-            groupMembership.setParentId(groupId);
-            groupMembership.setChildId(userIds.get(i));
-            groupMembership.setChildType(GroupChildType.USER);
-            groupMembership.setCreatedTime(System.currentTimeMillis());
-            groupMembership.setUpdatedTime(System.currentTimeMillis());
-            groupMembershipRepository.create(groupMembership);
-        }
-        return true;
-    }
-
-    @Override
-    public boolean removeUsersFromGroup(List<String> userIds, String groupId) throws GovRegistryException, TException {
-        for(int i=0; i < userIds.size(); i++){
-            GroupMembershipEntityPK groupMembershipEntityPK = new GroupMembershipEntityPK();
-            groupMembershipEntityPK.setParentId(groupId);
-            groupMembershipEntityPK.setChildId(userIds.get(i));
-            groupMembershipRepository.delete(groupMembershipEntityPK);
-        }
-        return true;
-    }
-
-    @Override
-    public Map<String, GroupChildType> getGroupMembers(String groupId, int offset, int limit) throws  GovRegistryException, TException {
-        HashMap<String, GroupChildType> groupMembers = new HashMap<>();
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
-        List<GroupMembership> groupMembershipList = groupMembershipRepository.select(filters, 0, -1);
-        groupMembershipList.stream().forEach(gm->{groupMembers.put(gm.getChildId(), gm.getChildType());});
-        return groupMembers;
-    }
-
-    @Override
-    public boolean addChildGroupToParentGroup(String childId, String groupId) throws GovRegistryException, TException {
-        //Todo check for cyclic dependencies
-        GroupMembership groupMembership = new GroupMembership();
-        groupMembership.setParentId(groupId);
-        groupMembership.setChildId(childId);
-        groupMembership.setChildType(GroupChildType.GROUP);
-        groupMembership.setCreatedTime(System.currentTimeMillis());
-        groupMembership.setUpdatedTime(System.currentTimeMillis());
-        groupMembershipRepository.create(groupMembership);
-        return true;
-    }
-
-    @Override
-    public boolean removeChildGroupFromParentGroup(String childId, String groupId) throws GovRegistryException, TException {
-        GroupMembershipEntityPK groupMembershipEntityPK = new GroupMembershipEntityPK();
-        groupMembershipEntityPK.setParentId(groupId);
-        groupMembershipEntityPK.setChildId(childId);
-        groupMembershipRepository.delete(groupMembershipEntityPK);
-        return true;
-    }
-
-    /**
-     * * EntityType Operations
-     * *
-     */
-    @Override
-    public String createEntityType(EntityType entityType) throws GovRegistryException, TException {
-        if(entityTypeRepository.get(entityType.entityTypeId) != null)
-            throw new GovRegistryException("There exist EntityType with given EntityType id");
-
-        entityType.setCreatedTime(System.currentTimeMillis());
-        entityType.setUpdatedTime(System.currentTimeMillis());
-        entityTypeRepository.create(entityType);
-        return entityType.entityTypeId;
-    }
-
-    @Override
-    public boolean updateEntityType(EntityType entityType) throws GovRegistryException, TException {
-        entityType.setUpdatedTime(System.currentTimeMillis());
-        EntityType oldEntityType = entityTypeRepository.get(entityType.entityTypeId);
-        entityType.setCreatedTime(oldEntityType.createdTime);
-        entityType = getUpdatedObject(oldEntityType, entityType);
-        entityTypeRepository.update(entityType);
-        return true;
-    }
-
-    @Override
-    public boolean deleteEntityType(String entityTypeId) throws GovRegistryException, TException {
-        entityTypeRepository.delete(entityTypeId);
-        return true;
-    }
-
-    @Override
-    public EntityType getEntityType(String entityTypeId) throws GovRegistryException, TException {
-        return entityTypeRepository.get(entityTypeId);
-    }
-
-    @Override
-    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws TException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.EntityTypeTable.DOMAIN_ID, domain);
-        return entityTypeRepository.select(domain, offset, limit);
-    }
-
-    /**
-     * * Permission Operations
-     * *
-     */
-    @Override
-    public String createPermissionType(PermissionType permissionType) throws GovRegistryException, TException {
-        if(permissionTypeRepository.get(permissionType.permissionTypeId) != null)
-            throw new GovRegistryException("There exist PermissionType with given PermissionType id");
-        permissionType.setCreatedTime(System.currentTimeMillis());
-        permissionType.setUpdatedTime(System.currentTimeMillis());
-        permissionTypeRepository.create(permissionType);
-        return permissionType.permissionTypeId;
-    }
-
-    @Override
-    public boolean updatePermissionType(PermissionType permissionType) throws GovRegistryException, TException {
-        permissionType.setUpdatedTime(System.currentTimeMillis());
-        PermissionType oldPermissionType = permissionTypeRepository.get(permissionType.permissionTypeId);
-        permissionType = getUpdatedObject(oldPermissionType, permissionType);
-        permissionTypeRepository.update(permissionType);
-        return true;
-    }
-
-    @Override
-    public boolean deletePermissionType(String entityTypeId) throws GovRegistryException, TException {
-        permissionTypeRepository.delete(entityTypeId);
-        return true;
-    }
-
-    @Override
-    public PermissionType getPermissionType(String permissionTypeId) throws GovRegistryException, TException {
-        return permissionTypeRepository.get(permissionTypeId);
-    }
-
-    @Override
-    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws GovRegistryException, TException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domain);
-        return permissionTypeRepository.select(filters, offset, limit);
-    }
-
-    /**
-     * * Entity Operations
-     * *
-     */
-    @Override
-    public String createEntity(Entity entity) throws GovRegistryException, TException {
-        if(entityRepository.get(entity.entityId) != null)
-            throw new GovRegistryException("There exist Entity with given Entity id");
-
-        entity.setCreatedTime(System.currentTimeMillis());
-        entity.setUpdatedTime(System.currentTimeMillis());
-        entityRepository.create(entity);
-
-        //Assigning global permission for the owner
-        Sharing newSharing = new Sharing();
-        newSharing.setPermissionTypeId(permissionTypeRepository.getGlobalPermissionTypeIdForDomain(entity.domainId));
-        newSharing.setEntityId(entity.entityId);
-        newSharing.setGroupId(entity.ownerId);
-        newSharing.setGroupType(GroupType.SINGLE_USER);
-        newSharing.setSharingType(SharingType.DIRECT);
-        newSharing.setCreatedTime(System.currentTimeMillis());
-        newSharing.setUpdatedTime(System.currentTimeMillis());
-
-        sharingRepository.create(newSharing);
-
-        //creating records for inherited permissions
-        if(entity.getParentEntityId() != null && entity.getParentEntityId() != ""){
-            List<Sharing> sharings = sharingRepository.getPermissionsForEntity(entity.parentEntityId);
-            for(Sharing sharing : sharings){
-                newSharing = new Sharing();
-                newSharing.setPermissionTypeId(sharing.permissionTypeId);
-                newSharing.setEntityId(entity.entityId);
-                newSharing.setGroupId(sharing.groupId);
-                newSharing.setGroupType(sharing.groupType);
-                newSharing.setSharingType(SharingType.INHERITED);
-                newSharing.setCreatedTime(System.currentTimeMillis());
-                newSharing.setUpdatedTime(System.currentTimeMillis());
-
-                sharingRepository.create(newSharing);
-            }
-        }
-
-        return entity.entityId;
-    }
-
-    @Override
-    public boolean updateEntity(Entity entity) throws GovRegistryException, TException {
-        //TODO Check for permission changes
-        entity.setUpdatedTime(System.currentTimeMillis());
-        Entity oldEntity = entityRepository.get(entity.getEntityId());
-        entity.setCreatedTime(oldEntity.createdTime);
-        entity = getUpdatedObject(oldEntity, entity);
-        entityRepository.update(entity);
-        return true;
-    }
-
-    @Override
-    public boolean deleteEntity(String entityId) throws GovRegistryException, TException {
-        //TODO Check for permission changes
-        entityRepository.delete(entityId);
-        return true;
-    }
-
-    @Override
-    public Entity getEntity(String entityId) throws GovRegistryException, TException {
-        return entityRepository.get(entityId);
-    }
-
-    @Override
-    public List<Entity> searchEntities(String userId, String entityTypeId, Map<EntitySearchFields, String> filters,
-                                       int offset, int limit) throws GovRegistryException, TException {
-        List<String> groupIds = new ArrayList<>();
-        groupIds.add(userId);
-        groupMembershipRepository.getAllParentMembershipsForChild(userId).stream().forEach(gm->groupIds.add(gm.parentId));
-        return entityRepository.searchEntities(groupIds, entityTypeId, filters, offset, limit);
-    }
-
-    /**
-     * * Sharing Entity with Users and Groups
-     * *
-     *
-     * @param entityId
-     * @param userList
-     * @param permissionType
-     */
-    @Override
-    public boolean shareEntityWithUsers(String entityId, List<String> userList, String permissionTypeId) throws GovRegistryException, TException {
-        return shareEntity(entityId, userList, permissionTypeId, GroupType.SINGLE_USER);
-    }
-
-    @Override
-    public boolean shareEntityWithGroups(String entityId, List<String> groupList, String permissionTypeId) throws GovRegistryException, TException {
-        return shareEntity(entityId, groupList, permissionTypeId, GroupType.MULTI_USER);
-    }
-
-    private boolean shareEntity(String entityId, List<String> groupOrUserList, String permissionTypeId, GroupType groupType)  throws GovRegistryException, TException {
-        //Adding permission for the specified users/groups for the specified entity
-        LinkedList<Entity> temp = new LinkedList<>();
-        for(String userId : groupOrUserList){
-            Sharing sharing = new Sharing();
-            sharing.setPermissionTypeId(permissionTypeId);
-            sharing.setEntityId(entityId);
-            sharing.setGroupId(userId);
-            sharing.setGroupType(groupType);
-            sharing.setSharingType(SharingType.DIRECT);
-            sharing.setCreatedTime(System.currentTimeMillis());
-            sharing.setUpdatedTime(System.currentTimeMillis());
-
-            sharingRepository.create(sharing);
-        }
-
-        //Adding permission for the specified users/groups for all child entities
-        entityRepository.getChildEntities(entityId).stream().forEach(e-> temp.addLast(e));
-        while(temp.size() > 0){
-            Entity entity = temp.pop();
-            String childEntityId = entity.entityId;
-            String parentEntityId = entity.parentEntityId;
-            for(String userId : groupOrUserList){
-                Sharing sharing = new Sharing();
-                sharing.setPermissionTypeId(permissionTypeId);
-                sharing.setEntityId(childEntityId);
-                sharing.setGroupId(userId);
-                sharing.setGroupType(groupType);
-                sharing.setSharingType(SharingType.INHERITED);
-                sharing.setInheritedParentId(parentEntityId);
-                sharing.setCreatedTime(System.currentTimeMillis());
-                sharing.setUpdatedTime(System.currentTimeMillis());
-                sharingRepository.create(sharing);
-                entityRepository.getChildEntities(childEntityId).stream().forEach(e-> temp.addLast(e));
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public boolean revokeEntitySharingFromUsers(String entityId, List<String> userList, String permissionTypeId) throws GovRegistryException, TException {
-        return revokeEntitySharing(entityId, userList, permissionTypeId);
-    }
-
-
-    @Override
-    public boolean revokeEntitySharingFromGroups(String entityId, List<String> groupList, String permissionTypeId) throws GovRegistryException, TException {
-        return revokeEntitySharing(entityId, groupList, permissionTypeId);
-    }
-
-    @Override
-    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws GovRegistryException, TException {
-        //check whether the user has permission directly or indirectly
-        List<GroupMembership> parentMemberships = groupMembershipRepository.getAllParentMembershipsForChild(userId);
-        List<String> groupIds = new ArrayList<>();
-        parentMemberships.stream().forEach(pm->groupIds.add(pm.parentId));
-        groupIds.add(userId);
-        return sharingRepository.hasAccess(entityId, groupIds, Arrays.asList(permissionTypeId,
-                permissionTypeRepository.getGlobalPermissionTypeIdForDomain(domainId)));
-    }
-
-    public boolean revokeEntitySharing(String entityId, List<String> groupOrUserList, String permissionTypeId) throws GovRegistryException {
-        //revoking permission for the entity
-        LinkedList<Sharing> temp = new LinkedList<>();
-        sharingRepository.getIndirectSharedChildren(entityId, permissionTypeId).stream().forEach(s->temp.addLast(s));
-        for(String groupId : groupOrUserList){
-            SharingEntityPK sharingEntityPK = new SharingEntityPK();
-            sharingEntityPK.setEntityId(entityId);
-            sharingEntityPK.setGroupId(groupId);
-            sharingEntityPK.setPermissionTypeId(permissionTypeId);
-
-            sharingRepository.delete(sharingEntityPK);
-        }
-
-        //revoking permission from inheritance
-        while(temp.size() > 0){
-            Sharing sharing = temp.pop();
-            String childEntityId = sharing.entityId;
-            sharingRepository.getIndirectSharedChildren(sharing.entityId, permissionTypeId).stream().forEach(s->temp.addLast(s));
-            for(String groupId : groupOrUserList){
-                SharingEntityPK sharingEntityPK = new SharingEntityPK();
-                sharingEntityPK.setEntityId(childEntityId);
-                sharingEntityPK.setGroupId(groupId);
-                sharingEntityPK.setPermissionTypeId(permissionTypeId);
-
-                sharingRepository.delete(sharingEntityPK);
-            }
-        }
-        return true;
-    }
-
-
-
-    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws GovRegistryException {
-        Field[] newEntityFields = newEntity.getClass().getDeclaredFields();
-        Hashtable newHT = fieldsToHT(newEntityFields, newEntity);
-
-        Class oldEntityClass = oldEntity.getClass();
-        Field[] oldEntityFields = oldEntityClass.getDeclaredFields();
-
-        for (Field field : oldEntityFields){
-            field.setAccessible(true);
-            Object o = newHT.get(field.getName());
-            if (o != null){
-                Field f = null;
-                try {
-                    f = oldEntityClass.getDeclaredField(field.getName());
-                    f.setAccessible(true);
-                    logger.debug("setting " + f.getName());
-                    f.set(oldEntity, o);
-                } catch (Exception e) {
-                    throw new GovRegistryException(e.getMessage());
-                }
-            }
-        }
-        return oldEntity;
-    }
-
-    private static Hashtable<String, Object> fieldsToHT(Field[] fields, Object obj){
-        Hashtable<String,Object> hashtable = new Hashtable<>();
-        for (Field field: fields){
-            field.setAccessible(true);
-            try {
-                Object retrievedObject = field.get(obj);
-                if (retrievedObject != null){
-                    logger.debug("scanning " + field.getName());
-                    hashtable.put(field.getName(), field.get(obj));
-                }
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            }
-        }
-        return hashtable;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
new file mode 100644
index 0000000..96fdb90
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.sharing.registry.server;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SharingRegistryServer {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServer.class);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
new file mode 100644
index 0000000..7ae1c64
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -0,0 +1,585 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.sharing.registry.server;
+
+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.*;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.*;
+import org.apache.airavata.sharing.registry.service.cpi.GovRegistryService;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.util.*;
+
+public class SharingRegistryServerHandler implements GovRegistryService.Iface{
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandler.class);
+
+    public static String GLOBAL_PERMISSION_NAME = "GLOBAL";
+
+    private DomainRepository domainRepository;
+    private UserRepository userRepository;
+    private UserGroupRepository userGroupRepository;
+    private GroupMembershipRepository groupMembershipRepository;
+    private EntityTypeRepository entityTypeRepository;
+    private PermissionTypeRepository permissionTypeRepository;
+    private EntityRepository entityRepository;
+    private SharingRepository sharingRepository;
+
+    public SharingRegistryServerHandler(){
+        this.domainRepository = new DomainRepository();
+        this.userRepository = new UserRepository();
+        this.userGroupRepository = new UserGroupRepository();
+        this.groupMembershipRepository = new GroupMembershipRepository();
+        this.entityTypeRepository = new EntityTypeRepository();
+        this.permissionTypeRepository = new PermissionTypeRepository();
+        this.entityRepository = new EntityRepository();
+        this.sharingRepository = new SharingRepository();
+    }
+
+    /**
+     * * Domain Operations
+     * *
+     */
+    @Override
+    public String createDomain(Domain domain) throws GovRegistryException, TException {
+        if(domainRepository.get(domain.domainId) != null)
+            throw new GovRegistryException("There exist domain with given domain id");
+
+        domain.setCreatedTime(System.currentTimeMillis());
+        domain.setUpdatedTime(System.currentTimeMillis());
+        domainRepository.create(domain);
+
+        //create the global permission for the domain
+        PermissionType permissionType = new PermissionType();
+        permissionType.setPermissionTypeId(domain.domainId+":"+GLOBAL_PERMISSION_NAME);
+        permissionType.setDomainId(domain.domainId);
+        permissionType.setName(GLOBAL_PERMISSION_NAME);
+        permissionType.setDescription("GLOBAL permission to " + domain.domainId);
+        permissionType.setCreatedTime(System.currentTimeMillis());
+        permissionType.setUpdatedTime(System.currentTimeMillis());
+        permissionTypeRepository.create(permissionType);
+
+        return domain.domainId;
+    }
+
+    @Override
+    public boolean updateDomain(Domain domain) throws GovRegistryException, TException {
+        Domain oldDomain = domainRepository.get(domain.domainId);
+        domain.setCreatedTime(oldDomain.createdTime);
+        domain.setUpdatedTime(System.currentTimeMillis());
+        domain = getUpdatedObject(oldDomain, domain);
+        domainRepository.update(domain);
+        return true;
+    }
+
+    @Override
+    public boolean deleteDomain(String domainId) throws GovRegistryException, TException {
+        domainRepository.delete(domainId);
+        return true;
+    }
+
+    @Override
+    public Domain getDomain(String domainId) throws GovRegistryException, TException {
+        return domainRepository.get(domainId);
+    }
+
+    @Override
+    public List<Domain> getDomains(int offset, int limit) throws TException {
+        return domainRepository.select(new HashMap<>(), offset, limit);
+    }
+
+    /**
+     * * User Operations
+     * *
+     */
+    @Override
+    public String createUser(User user) throws GovRegistryException, TException {
+        if(userRepository.get(user.userId) != null)
+            throw new GovRegistryException("There exist user with given user id");
+
+        user.setCreatedTime(System.currentTimeMillis());
+        user.setUpdatedTime(System.currentTimeMillis());
+        userRepository.create(user);
+
+        UserGroup userGroup = new UserGroup();
+        userGroup.setGroupId(user.userId);
+        userGroup.setDomainId(user.domainId);
+        userGroup.setName(user.userName);
+        userGroup.setDescription("user " + user.userName + " group");
+        userGroup.setOwnerId(user.userId);
+        userGroup.setGroupType(GroupType.SINGLE_USER);
+        createGroup(userGroup);
+
+        return user.userId;
+    }
+
+    @Override
+    public boolean updatedUser(User user) throws GovRegistryException, TException {
+        User oldUser = userRepository.get(user.userId);
+        user.setCreatedTime(oldUser.createdTime);
+        user.setUpdatedTime(System.currentTimeMillis());
+        user = getUpdatedObject(oldUser, user);
+        userRepository.update(user);
+
+        UserGroup userGroup = userGroupRepository.get(user.userId);
+        userGroup.setName(user.userName);
+        userGroup.setDescription("user " + user.userName + " group");
+        updateGroup(userGroup);
+        return true;
+    }
+
+    @Override
+    public boolean deleteUser(String userId) throws GovRegistryException, TException {
+        userRepository.delete(userId);
+        userGroupRepository.delete(userId);
+        return true;
+    }
+
+    @Override
+    public User getUser(String userId) throws GovRegistryException, TException {
+        return userRepository.get(userId);
+    }
+
+    @Override
+    public List<User> getUsers(String domain, int offset, int limit) throws  GovRegistryException, TException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
+        return userRepository.select(filters, offset, limit);
+    }
+
+    /**
+     * * Group Operations
+     * *
+     */
+    @Override
+    public String createGroup(UserGroup group) throws GovRegistryException, TException {
+        if(userGroupRepository.get(group.groupId) != null)
+            throw new GovRegistryException("There exist group with given group id");
+
+        group.setCreatedTime(System.currentTimeMillis());
+        group.setUpdatedTime(System.currentTimeMillis());
+        userGroupRepository.create(group);
+        return group.groupId;
+    }
+
+    @Override
+    public boolean updateGroup(UserGroup group) throws GovRegistryException, TException {
+        group.setUpdatedTime(System.currentTimeMillis());
+        UserGroup oldGroup = userGroupRepository.get(group.groupId);
+        group.setCreatedTime(oldGroup.createdTime);
+        group = getUpdatedObject(oldGroup, group);
+        userGroupRepository.update(group);
+        return true;
+    }
+
+    @Override
+    public boolean deleteGroup(String groupId) throws GovRegistryException, TException {
+        userGroupRepository.delete(groupId);
+        return true;
+    }
+
+    @Override
+    public UserGroup getGroup(String groupId) throws GovRegistryException, TException {
+        return userGroupRepository.get(groupId);
+    }
+
+    @Override
+    public List<UserGroup> getGroups(String domain, int offset, int limit) throws TException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
+        return userGroupRepository.select(filters, offset, limit);
+    }
+
+    @Override
+    public boolean addUsersToGroup(List<String> userIds, String groupId) throws GovRegistryException, TException {
+        for(int i=0; i < userIds.size(); i++){
+            GroupMembership groupMembership = new GroupMembership();
+            groupMembership.setParentId(groupId);
+            groupMembership.setChildId(userIds.get(i));
+            groupMembership.setChildType(GroupChildType.USER);
+            groupMembership.setCreatedTime(System.currentTimeMillis());
+            groupMembership.setUpdatedTime(System.currentTimeMillis());
+            groupMembershipRepository.create(groupMembership);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeUsersFromGroup(List<String> userIds, String groupId) throws GovRegistryException, TException {
+        for(int i=0; i < userIds.size(); i++){
+            GroupMembershipEntityPK groupMembershipEntityPK = new GroupMembershipEntityPK();
+            groupMembershipEntityPK.setParentId(groupId);
+            groupMembershipEntityPK.setChildId(userIds.get(i));
+            groupMembershipRepository.delete(groupMembershipEntityPK);
+        }
+        return true;
+    }
+
+    @Override
+    public Map<String, GroupChildType> getGroupMembers(String groupId, int offset, int limit) throws  GovRegistryException, TException {
+        HashMap<String, GroupChildType> groupMembers = new HashMap<>();
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
+        List<GroupMembership> groupMembershipList = groupMembershipRepository.select(filters, 0, -1);
+        groupMembershipList.stream().forEach(gm->{groupMembers.put(gm.getChildId(), gm.getChildType());});
+        return groupMembers;
+    }
+
+    @Override
+    public boolean addChildGroupToParentGroup(String childId, String groupId) throws GovRegistryException, TException {
+        //Todo check for cyclic dependencies
+        GroupMembership groupMembership = new GroupMembership();
+        groupMembership.setParentId(groupId);
+        groupMembership.setChildId(childId);
+        groupMembership.setChildType(GroupChildType.GROUP);
+        groupMembership.setCreatedTime(System.currentTimeMillis());
+        groupMembership.setUpdatedTime(System.currentTimeMillis());
+        groupMembershipRepository.create(groupMembership);
+        return true;
+    }
+
+    @Override
+    public boolean removeChildGroupFromParentGroup(String childId, String groupId) throws GovRegistryException, TException {
+        GroupMembershipEntityPK groupMembershipEntityPK = new GroupMembershipEntityPK();
+        groupMembershipEntityPK.setParentId(groupId);
+        groupMembershipEntityPK.setChildId(childId);
+        groupMembershipRepository.delete(groupMembershipEntityPK);
+        return true;
+    }
+
+    /**
+     * * EntityType Operations
+     * *
+     */
+    @Override
+    public String createEntityType(EntityType entityType) throws GovRegistryException, TException {
+        if(entityTypeRepository.get(entityType.entityTypeId) != null)
+            throw new GovRegistryException("There exist EntityType with given EntityType id");
+
+        entityType.setCreatedTime(System.currentTimeMillis());
+        entityType.setUpdatedTime(System.currentTimeMillis());
+        entityTypeRepository.create(entityType);
+        return entityType.entityTypeId;
+    }
+
+    @Override
+    public boolean updateEntityType(EntityType entityType) throws GovRegistryException, TException {
+        entityType.setUpdatedTime(System.currentTimeMillis());
+        EntityType oldEntityType = entityTypeRepository.get(entityType.entityTypeId);
+        entityType.setCreatedTime(oldEntityType.createdTime);
+        entityType = getUpdatedObject(oldEntityType, entityType);
+        entityTypeRepository.update(entityType);
+        return true;
+    }
+
+    @Override
+    public boolean deleteEntityType(String entityTypeId) throws GovRegistryException, TException {
+        entityTypeRepository.delete(entityTypeId);
+        return true;
+    }
+
+    @Override
+    public EntityType getEntityType(String entityTypeId) throws GovRegistryException, TException {
+        return entityTypeRepository.get(entityTypeId);
+    }
+
+    @Override
+    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws TException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.EntityTypeTable.DOMAIN_ID, domain);
+        return entityTypeRepository.select(domain, offset, limit);
+    }
+
+    /**
+     * * Permission Operations
+     * *
+     */
+    @Override
+    public String createPermissionType(PermissionType permissionType) throws GovRegistryException, TException {
+        if(permissionTypeRepository.get(permissionType.permissionTypeId) != null)
+            throw new GovRegistryException("There exist PermissionType with given PermissionType id");
+        permissionType.setCreatedTime(System.currentTimeMillis());
+        permissionType.setUpdatedTime(System.currentTimeMillis());
+        permissionTypeRepository.create(permissionType);
+        return permissionType.permissionTypeId;
+    }
+
+    @Override
+    public boolean updatePermissionType(PermissionType permissionType) throws GovRegistryException, TException {
+        permissionType.setUpdatedTime(System.currentTimeMillis());
+        PermissionType oldPermissionType = permissionTypeRepository.get(permissionType.permissionTypeId);
+        permissionType = getUpdatedObject(oldPermissionType, permissionType);
+        permissionTypeRepository.update(permissionType);
+        return true;
+    }
+
+    @Override
+    public boolean deletePermissionType(String entityTypeId) throws GovRegistryException, TException {
+        permissionTypeRepository.delete(entityTypeId);
+        return true;
+    }
+
+    @Override
+    public PermissionType getPermissionType(String permissionTypeId) throws GovRegistryException, TException {
+        return permissionTypeRepository.get(permissionTypeId);
+    }
+
+    @Override
+    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws GovRegistryException, TException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domain);
+        return permissionTypeRepository.select(filters, offset, limit);
+    }
+
+    /**
+     * * Entity Operations
+     * *
+     */
+    @Override
+    public String createEntity(Entity entity) throws GovRegistryException, TException {
+        if(entityRepository.get(entity.entityId) != null)
+            throw new GovRegistryException("There exist Entity with given Entity id");
+
+        entity.setCreatedTime(System.currentTimeMillis());
+        entity.setUpdatedTime(System.currentTimeMillis());
+        entityRepository.create(entity);
+
+        //Assigning global permission for the owner
+        Sharing newSharing = new Sharing();
+        newSharing.setPermissionTypeId(permissionTypeRepository.getGlobalPermissionTypeIdForDomain(entity.domainId));
+        newSharing.setEntityId(entity.entityId);
+        newSharing.setGroupId(entity.ownerId);
+        newSharing.setGroupType(GroupType.SINGLE_USER);
+        newSharing.setSharingType(SharingType.DIRECT);
+        newSharing.setCreatedTime(System.currentTimeMillis());
+        newSharing.setUpdatedTime(System.currentTimeMillis());
+
+        sharingRepository.create(newSharing);
+
+        //creating records for inherited permissions
+        if(entity.getParentEntityId() != null && entity.getParentEntityId() != ""){
+            List<Sharing> sharings = sharingRepository.getPermissionsForEntity(entity.parentEntityId);
+            for(Sharing sharing : sharings){
+                newSharing = new Sharing();
+                newSharing.setPermissionTypeId(sharing.permissionTypeId);
+                newSharing.setEntityId(entity.entityId);
+                newSharing.setGroupId(sharing.groupId);
+                newSharing.setGroupType(sharing.groupType);
+                newSharing.setSharingType(SharingType.INHERITED);
+                newSharing.setCreatedTime(System.currentTimeMillis());
+                newSharing.setUpdatedTime(System.currentTimeMillis());
+
+                sharingRepository.create(newSharing);
+            }
+        }
+
+        return entity.entityId;
+    }
+
+    @Override
+    public boolean updateEntity(Entity entity) throws GovRegistryException, TException {
+        //TODO Check for permission changes
+        entity.setUpdatedTime(System.currentTimeMillis());
+        Entity oldEntity = entityRepository.get(entity.getEntityId());
+        entity.setCreatedTime(oldEntity.createdTime);
+        entity = getUpdatedObject(oldEntity, entity);
+        entityRepository.update(entity);
+        return true;
+    }
+
+    @Override
+    public boolean deleteEntity(String entityId) throws GovRegistryException, TException {
+        //TODO Check for permission changes
+        entityRepository.delete(entityId);
+        return true;
+    }
+
+    @Override
+    public Entity getEntity(String entityId) throws GovRegistryException, TException {
+        return entityRepository.get(entityId);
+    }
+
+    @Override
+    public List<Entity> searchEntities(String userId, String entityTypeId, Map<EntitySearchFields, String> filters,
+                                       int offset, int limit) throws GovRegistryException, TException {
+        List<String> groupIds = new ArrayList<>();
+        groupIds.add(userId);
+        groupMembershipRepository.getAllParentMembershipsForChild(userId).stream().forEach(gm->groupIds.add(gm.parentId));
+        return entityRepository.searchEntities(groupIds, entityTypeId, filters, offset, limit);
+    }
+
+    /**
+     * * Sharing Entity with Users and Groups
+     * *
+     *
+     * @param entityId
+     * @param userList
+     * @param permissionType
+     */
+    @Override
+    public boolean shareEntityWithUsers(String entityId, List<String> userList, String permissionTypeId) throws GovRegistryException, TException {
+        return shareEntity(entityId, userList, permissionTypeId, GroupType.SINGLE_USER);
+    }
+
+    @Override
+    public boolean shareEntityWithGroups(String entityId, List<String> groupList, String permissionTypeId) throws GovRegistryException, TException {
+        return shareEntity(entityId, groupList, permissionTypeId, GroupType.MULTI_USER);
+    }
+
+    private boolean shareEntity(String entityId, List<String> groupOrUserList, String permissionTypeId, GroupType groupType)  throws GovRegistryException, TException {
+        //Adding permission for the specified users/groups for the specified entity
+        LinkedList<Entity> temp = new LinkedList<>();
+        for(String userId : groupOrUserList){
+            Sharing sharing = new Sharing();
+            sharing.setPermissionTypeId(permissionTypeId);
+            sharing.setEntityId(entityId);
+            sharing.setGroupId(userId);
+            sharing.setGroupType(groupType);
+            sharing.setSharingType(SharingType.DIRECT);
+            sharing.setCreatedTime(System.currentTimeMillis());
+            sharing.setUpdatedTime(System.currentTimeMillis());
+
+            sharingRepository.create(sharing);
+        }
+
+        //Adding permission for the specified users/groups for all child entities
+        entityRepository.getChildEntities(entityId).stream().forEach(e-> temp.addLast(e));
+        while(temp.size() > 0){
+            Entity entity = temp.pop();
+            String childEntityId = entity.entityId;
+            String parentEntityId = entity.parentEntityId;
+            for(String userId : groupOrUserList){
+                Sharing sharing = new Sharing();
+                sharing.setPermissionTypeId(permissionTypeId);
+                sharing.setEntityId(childEntityId);
+                sharing.setGroupId(userId);
+                sharing.setGroupType(groupType);
+                sharing.setSharingType(SharingType.INHERITED);
+                sharing.setInheritedParentId(parentEntityId);
+                sharing.setCreatedTime(System.currentTimeMillis());
+                sharing.setUpdatedTime(System.currentTimeMillis());
+                sharingRepository.create(sharing);
+                entityRepository.getChildEntities(childEntityId).stream().forEach(e-> temp.addLast(e));
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean revokeEntitySharingFromUsers(String entityId, List<String> userList, String permissionTypeId) throws GovRegistryException, TException {
+        return revokeEntitySharing(entityId, userList, permissionTypeId);
+    }
+
+
+    @Override
+    public boolean revokeEntitySharingFromGroups(String entityId, List<String> groupList, String permissionTypeId) throws GovRegistryException, TException {
+        return revokeEntitySharing(entityId, groupList, permissionTypeId);
+    }
+
+    @Override
+    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws GovRegistryException, TException {
+        //check whether the user has permission directly or indirectly
+        List<GroupMembership> parentMemberships = groupMembershipRepository.getAllParentMembershipsForChild(userId);
+        List<String> groupIds = new ArrayList<>();
+        parentMemberships.stream().forEach(pm->groupIds.add(pm.parentId));
+        groupIds.add(userId);
+        return sharingRepository.hasAccess(entityId, groupIds, Arrays.asList(permissionTypeId,
+                permissionTypeRepository.getGlobalPermissionTypeIdForDomain(domainId)));
+    }
+
+    public boolean revokeEntitySharing(String entityId, List<String> groupOrUserList, String permissionTypeId) throws GovRegistryException {
+        //revoking permission for the entity
+        LinkedList<Sharing> temp = new LinkedList<>();
+        sharingRepository.getIndirectSharedChildren(entityId, permissionTypeId).stream().forEach(s->temp.addLast(s));
+        for(String groupId : groupOrUserList){
+            SharingEntityPK sharingEntityPK = new SharingEntityPK();
+            sharingEntityPK.setEntityId(entityId);
+            sharingEntityPK.setGroupId(groupId);
+            sharingEntityPK.setPermissionTypeId(permissionTypeId);
+
+            sharingRepository.delete(sharingEntityPK);
+        }
+
+        //revoking permission from inheritance
+        while(temp.size() > 0){
+            Sharing sharing = temp.pop();
+            String childEntityId = sharing.entityId;
+            sharingRepository.getIndirectSharedChildren(sharing.entityId, permissionTypeId).stream().forEach(s->temp.addLast(s));
+            for(String groupId : groupOrUserList){
+                SharingEntityPK sharingEntityPK = new SharingEntityPK();
+                sharingEntityPK.setEntityId(childEntityId);
+                sharingEntityPK.setGroupId(groupId);
+                sharingEntityPK.setPermissionTypeId(permissionTypeId);
+
+                sharingRepository.delete(sharingEntityPK);
+            }
+        }
+        return true;
+    }
+
+
+
+    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws GovRegistryException {
+        Field[] newEntityFields = newEntity.getClass().getDeclaredFields();
+        Hashtable newHT = fieldsToHT(newEntityFields, newEntity);
+
+        Class oldEntityClass = oldEntity.getClass();
+        Field[] oldEntityFields = oldEntityClass.getDeclaredFields();
+
+        for (Field field : oldEntityFields){
+            field.setAccessible(true);
+            Object o = newHT.get(field.getName());
+            if (o != null){
+                Field f = null;
+                try {
+                    f = oldEntityClass.getDeclaredField(field.getName());
+                    f.setAccessible(true);
+                    logger.debug("setting " + f.getName());
+                    f.set(oldEntity, o);
+                } catch (Exception e) {
+                    throw new GovRegistryException(e.getMessage());
+                }
+            }
+        }
+        return oldEntity;
+    }
+
+    private static Hashtable<String, Object> fieldsToHT(Field[] fields, Object obj){
+        Hashtable<String,Object> hashtable = new Hashtable<>();
+        for (Field field: fields){
+            field.setAccessible(true);
+            try {
+                Object retrievedObject = field.get(obj);
+                if (retrievedObject != null){
+                    logger.debug("scanning " + field.getName());
+                    hashtable.put(field.getName(), field.get(obj));
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return hashtable;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/META-INF/persistence.xml b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/META-INF/persistence.xml
index ceba398..a9f808c 100644
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/META-INF/persistence.xml
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
 
-    <persistence-unit name="airavata-gov-registry">
+    <persistence-unit name="airavata-sharing-registry">
         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
         <class>org.apache.airavata.sharing.registry.db.entities.DomainEntity</class>
         <class>org.apache.airavata.sharing.registry.db.entities.EntityEntity</class>

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/gov-registry.sql
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/gov-registry.sql b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/gov-registry.sql
deleted file mode 100644
index 4b046ce..0000000
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/gov-registry.sql
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-CREATE TABLE DOMAIN (
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (DOMAIN_ID)
-);
-
-CREATE TABLE USER (
-  USER_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  USER_NAME VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (USER_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-CREATE TABLE USER_GROUP (
-  GROUP_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  OWNER_ID VARCHAR(255) NOT NULL,
-  GROUP_TYPE VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (GROUP_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (OWNER_ID) REFERENCES USER(USER_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-
-CREATE TABLE GROUP_MEMBERSHIP (
-  PARENT_ID VARCHAR(255) NOT NULL,
-  CHILD_ID VARCHAR(255) NOT NULL,
-  CHILD_TYPE VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PARENT_ID, CHILD_ID),
-  FOREIGN KEY (PARENT_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (CHILD_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-CREATE TABLE ENTITY_TYPE (
-  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (ENTITY_TYPE_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-CREATE TABLE PERMISSION_TYPE (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PERMISSION_TYPE_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-CREATE TABLE ENTITY (
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
-  OWNER_ID VARCHAR(255) NOT NULL,
-  PARENT_ENTITY_ID VARCHAR(255),
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  FULL_TEXT TEXT,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (ENTITY_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (ENTITY_TYPE_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (OWNER_ID) REFERENCES USER(USER_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (PARENT_ENTITY_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
-
-CREATE TABLE ENTITY_METADATA (
-  ENTITY_ID VARCHAR (255) NOT NULL,
-  META_KEY VARCHAR (255) NOT NULL,
-  META_VALUE VARCHAR (255) NOT NULL,
-  PRIMARY KEY (ENTITY_ID, META_KEY),
-  FOREIGN KEY (ENTITY_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-CREATE TABLE SHARING (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  GROUP_ID VARCHAR(255) NOT NULL,
-  GROUP_TYPE VARCHAR(255) NOT NULL,
-  SHARING_TYPE VARCHAR(255) NOT NULL,
-  INHERITED_PARENT_ID VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID),
-  FOREIGN KEY (PERMISSION_TYPE_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (INHERITED_PARENT_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE CASCADE,
-  FOREIGN KEY (GROUP_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE
-);
-
-CREATE TABLE CONFIGURATION
-(
-  CONFIG_KEY VARCHAR(255) NOT NULL,
-  CONFIG_VALUE VARCHAR(255) NOT NULL,
-  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/sharing-registry.sql
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/sharing-registry.sql b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/sharing-registry.sql
new file mode 100644
index 0000000..4b046ce
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/sharing-registry.sql
@@ -0,0 +1,139 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+CREATE TABLE DOMAIN (
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (DOMAIN_ID)
+);
+
+CREATE TABLE USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (USER_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE USER_GROUP (
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (GROUP_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (OWNER_ID) REFERENCES USER(USER_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+
+CREATE TABLE GROUP_MEMBERSHIP (
+  PARENT_ID VARCHAR(255) NOT NULL,
+  CHILD_ID VARCHAR(255) NOT NULL,
+  CHILD_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PARENT_ID, CHILD_ID),
+  FOREIGN KEY (PARENT_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (CHILD_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE ENTITY_TYPE (
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_TYPE_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE PERMISSION_TYPE (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE ENTITY (
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  OWNER_ID VARCHAR(255) NOT NULL,
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  FULL_TEXT TEXT,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (ENTITY_TYPE_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (OWNER_ID) REFERENCES USER(USER_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (PARENT_ENTITY_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
+
+CREATE TABLE ENTITY_METADATA (
+  ENTITY_ID VARCHAR (255) NOT NULL,
+  META_KEY VARCHAR (255) NOT NULL,
+  META_VALUE VARCHAR (255) NOT NULL,
+  PRIMARY KEY (ENTITY_ID, META_KEY),
+  FOREIGN KEY (ENTITY_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  SHARING_TYPE VARCHAR(255) NOT NULL,
+  INHERITED_PARENT_ID VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID),
+  FOREIGN KEY (PERMISSION_TYPE_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (INHERITED_PARENT_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE CASCADE,
+  FOREIGN KEY (GROUP_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE CONFIGURATION
+(
+  CONFIG_KEY VARCHAR(255) NOT NULL,
+  CONFIG_VALUE VARCHAR(255) NOT NULL,
+  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
+);
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/d24852ae/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
index 32c6a17..688117c 100644
--- a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
@@ -22,7 +22,7 @@ package org.apache.airavata.sharing.registry;
 
 import junit.framework.Assert;
 import org.apache.airavata.sharing.registry.models.*;
-import org.apache.airavata.sharing.registry.server.GovRegistryServerHandler;
+import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
 import org.apache.thrift.TException;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -37,7 +37,7 @@ public class GovRegistryServerHandlerTest {
 
     @Test
     public void test() throws TException {
-        GovRegistryServerHandler govRegistryServerHandler = new GovRegistryServerHandler();
+        SharingRegistryServerHandler govRegistryServerHandler = new SharingRegistryServerHandler();
 
         //Creating domain
         Domain domain = new Domain();


Mime
View raw message