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 2016/09/23 22:51:39 UTC

[07/19] airavata git commit: WIP

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
new file mode 100644
index 0000000..259e22c
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * 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.db.repositories;
+
+import org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntity;
+import org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntityPK;
+import org.apache.airavata.sharing.registry.db.entities.UserEntity;
+import org.apache.airavata.sharing.registry.db.entities.UserGroupEntity;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.*;
+
+import java.util.*;
+
+public class GroupMembershipRepository extends AbstractRepository<GroupMembership, GroupMembershipEntity, GroupMembershipEntityPK> {
+
+    public GroupMembershipRepository() {
+        super(GroupMembership.class, GroupMembershipEntity.class);
+    }
+
+    public List<GroupMembership> getChildMembershipsOfGroup(String parentId) throws GovRegistryException {
+        Map<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.GroupMembershipTable.PARENT_ID, parentId);
+        return select(filters, 0, -1);
+    }
+
+    public List<User> getAllChildUsers(String groupId) throws GovRegistryException {
+        String queryString = "SELECT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName()
+                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = U." + DBConstants.UserTable.USER_ID + " AND " +
+                "gm." + DBConstants.GroupMembershipTable.PARENT_ID+"='"+groupId + "' AND gm." + DBConstants.GroupMembershipTable.CHILD_TYPE
+                + "='" + GroupChildType.USER.toString() + "'";
+        UserRepository userRepository = new UserRepository();
+        List<User> users = userRepository.select(queryString, 0, -1);
+        return users;
+    }
+
+    public List<UserGroup> getAllChildGroups(String groupId) throws GovRegistryException {
+        String queryString = "SELECT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
+                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.PARENT_ID+"='"+groupId + "' AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
+                + "='" + GroupChildType.GROUP.toString() + "'";
+        UserGroupRepository userGroupRepository = new UserGroupRepository();
+        List<UserGroup> groups = userGroupRepository.select(queryString, 0, -1);
+        return groups;
+    }
+
+    public List<GroupMembership> getAllParentMembershipsForChild(String childId) throws GovRegistryException {
+        List<GroupMembership> finalParentGroups = new ArrayList<>();
+        Map<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId);
+        LinkedList<GroupMembership> temp = new LinkedList<>();
+        select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
+        while (temp.size() > 0){
+            GroupMembership gm = temp.pop();
+            filters = new HashMap<>();
+            filters.put(DBConstants.GroupMembershipTable.CHILD_ID, gm.parentId);
+            select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
+            finalParentGroups.add(gm);
+        }
+        return finalParentGroups;
+    }
+
+    public List<UserGroup> getAllParentGroupsForChild(String childId) throws GovRegistryException {
+        List<UserGroup> finalParentGroups = new ArrayList<>();
+        Map<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId);
+        LinkedList<GroupMembership> temp = new LinkedList<>();
+        select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
+        UserGroupRepository userGroupRepository = new UserGroupRepository();
+        while (temp.size() > 0){
+            GroupMembership gm = temp.pop();
+            filters = new HashMap<>();
+            filters.put(DBConstants.GroupMembershipTable.CHILD_ID, gm.parentId);
+            select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
+            finalParentGroups.add(userGroupRepository.get(gm.parentId));
+        }
+        return finalParentGroups;
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/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
new file mode 100644
index 0000000..abc290a
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.db.repositories;
+
+import org.apache.airavata.sharing.registry.db.entities.PermissionTypeEntity;
+import org.apache.airavata.sharing.registry.models.PermissionType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class);
+
+    public PermissionTypeRepository() {
+        super(PermissionType.class, PermissionTypeEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
new file mode 100644
index 0000000..1c45c31
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.db.repositories;
+
+import org.apache.airavata.sharing.registry.db.entities.SharingEntity;
+import org.apache.airavata.sharing.registry.models.Sharing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class);
+
+    public SharingRepository() {
+        super(Sharing.class, SharingEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
new file mode 100644
index 0000000..170b1fd
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.db.repositories;
+
+import org.apache.airavata.sharing.registry.db.entities.UserGroupEntity;
+import org.apache.airavata.sharing.registry.models.UserGroup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class);
+
+    public UserGroupRepository() {
+        super(UserGroup.class, UserGroupEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
new file mode 100644
index 0000000..f4ec03f
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.db.repositories;
+
+
+import org.apache.airavata.sharing.registry.db.entities.UserEntity;
+import org.apache.airavata.sharing.registry.models.User;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserRepository extends AbstractRepository<User, UserEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(UserRepository.class);
+
+    public UserRepository() {
+        super(User.class, UserEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
new file mode 100644
index 0000000..ed8c9b3
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * 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.db.utils;
+
+@FunctionalInterface
+public interface Committer<T, R>  {
+
+    R commit(T t);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
new file mode 100644
index 0000000..f242b83
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.db.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DBConstants {
+    private final static Logger logger = LoggerFactory.getLogger(DBConstants.class);
+
+    public static int SELECT_MAX_ROWS = 10000;
+
+    public static class DomainTable {
+        public static String DOMAIN_ID = "domainId";
+        public static String NAME = "name";
+        public static String DESCRIPTION = "description";
+    }
+
+    public static class UserTable {
+        public static String USER_ID = "userId";
+        public static String DOMAIN_ID = "domainId";
+        public static String USER_NAME = "userName";
+    }
+
+    public static class UserGroupTable {
+        public static String GROUP_ID = "groupId";
+        public static String DOMAIN_ID = "domainId";
+        public static String NAME = "name";
+        public static String DESCRIPTION = "description";
+        public static String OWNER_ID = "ownerId";
+        public static String GROUP_TYPE = "groupType";
+    }
+
+    public static class GroupMembershipTable {
+        public static String PARENT_ID = "parentId";
+        public static String CHILD_ID = "childId";
+        public static String CHILD_TYPE = "childType";
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/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
new file mode 100644
index 0000000..e1eba62
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
@@ -0,0 +1,111 @@
+/*
+ *
+ * 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.db.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.sharing.registry.models.GovRegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.util.HashMap;
+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 JPA_CACHE_SIZE = "jpa.cache.size";
+    private static final String JPA_CACHE_ENABLED = "cache.enable";
+
+    @PersistenceUnit(unitName = PERSISTENCE_UNIT_NAME)
+    protected static EntityManagerFactory factory;
+    @PersistenceContext(unitName = PERSISTENCE_UNIT_NAME)
+    private static EntityManager entityManager;
+
+    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=com.mysql.jdbc.Driver," +
+                    "Url=jdbc:mysql://localhost:3306/airavata_gov_registry?autoReconnect=true," +
+                    "Username=root," +
+                    "Password=," +
+                    ",validationQuery=SELECT 1 FROM CONFIGURATION";
+
+            Map<String, String> properties = new HashMap<String, String>();
+            properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
+            properties.put("openjpa.ConnectionProperties", connectionProperties);
+            properties.put("openjpa.DynamicEnhancementAgent", "true");
+            properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
+            // For app catalog, we don't need caching
+//            properties.put("openjpa.DataCache","" + readServerProperties(JPA_CACHE_ENABLED) + "(CacheSize=" + Integer.valueOf(readServerProperties(JPA_CACHE_SIZE)) + ", SoftReferenceSize=0)");
+//            properties.put("openjpa.QueryCache","" + readServerProperties(JPA_CACHE_ENABLED) + "(CacheSize=" + Integer.valueOf(readServerProperties(JPA_CACHE_SIZE)) + ", SoftReferenceSize=0)");
+            properties.put("openjpa.RemoteCommitProvider", "sjvm");
+            properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
+            properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+            properties.put("openjpa.jdbc.QuerySQLCache", "false");
+            properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72," +
+                    " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000,  autoReconnect=true");
+            properties.put("openjpa.RuntimeUnenhancedClasses", "warn");
+            factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
+        }
+        entityManager = factory.createEntityManager();
+        return entityManager;
+    }
+
+    private static String readServerProperties(String propertyName) throws GovRegistryException {
+        try {
+            return ServerSettings.getSetting(propertyName);
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server.properties...", e);
+            throw new GovRegistryException("Unable to read airavata-server.properties...");
+        }
+    }
+
+    public static <R> R execute(Committer<EntityManager, R> committer) throws GovRegistryException {
+        EntityManager entityManager = JPAUtils.getEntityManager();
+        try {
+            entityManager.getTransaction().begin();
+            R r = committer.commit(entityManager);
+            entityManager.getTransaction().commit();
+            return  r;
+        }finally {
+            if (entityManager != null && entityManager.isOpen()) {
+                if (entityManager.getTransaction().isActive()) {
+                    entityManager.getTransaction().rollback();
+                }
+                entityManager.close();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
new file mode 100644
index 0000000..de6bea9
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.db.utils;
+
+import org.dozer.DozerBeanMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ObjectMapperSingleton extends DozerBeanMapper{
+    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
+
+    private static ObjectMapperSingleton instance;
+
+    private ObjectMapperSingleton(){}
+
+    public static ObjectMapperSingleton getInstance(){
+        if(instance == null)
+            instance = new ObjectMapperSingleton();
+        return instance;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/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
new file mode 100644
index 0000000..276c99e
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServer.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.gov.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/ac819e51/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
new file mode 100644
index 0000000..5af94a0
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/GovRegistryServerHandler.java
@@ -0,0 +1,223 @@
+/*
+ *
+ * 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.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.util.List;
+import java.util.Map;
+
+public class GovRegistryServerHandler implements GovRegistryService.Iface{
+    private final static Logger logger = LoggerFactory.getLogger(GovRegistryServerHandler.class);
+
+    /**
+     * * Domain Operations
+     * *
+     */
+    @Override
+    public boolean createDomain(Domain domain) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean updateDomain(Domain domain) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean deleteDomain(String domainId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public Domain getDomain(String domainId) throws GovRegistryException, TException {
+        return null;
+    }
+
+    @Override
+    public List<Domain> getDomains(int offset, int limit) throws TException {
+        return null;
+    }
+
+    /**
+     * * User Operations
+     * *
+     */
+    @Override
+    public boolean registerUser(User user) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean updatedUser(User user) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean deleteUser(String userId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public User getUser(String userId) throws GovRegistryException, TException {
+        return null;
+    }
+
+    @Override
+    public List<User> getUsers(String domain, int offset, int limit) throws TException {
+        return null;
+    }
+
+    /**
+     * * Group Operations
+     * *
+     */
+    @Override
+    public boolean createGroup(UserGroup group) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean updateGroup(UserGroup group) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean deleteGroup(String groupId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public UserGroup getGroup(String groupId) throws GovRegistryException, TException {
+        return null;
+    }
+
+    @Override
+    public List<UserGroup> getGroups(String domain, int offset, int limit) throws TException {
+        return null;
+    }
+
+    @Override
+    public boolean addUsersToGroup(List<String> userIds, String groupId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean removeUsersFromGroup(List<String> userIds, String groupId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public Map<String, GroupType> getGroupMembers(String groupId) throws TException {
+        return null;
+    }
+
+    /**
+     * * EntityType Operations
+     * *
+     */
+    @Override
+    public boolean createEntityType(EntityType entityType) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean updateEntityType(EntityType entityType) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean deleteEntityType(String entityTypeId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public EntityType getEntityType(String entityTypeId) throws GovRegistryException, TException {
+        return null;
+    }
+
+    @Override
+    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws TException {
+        return null;
+    }
+
+    /**
+     * * Entity Operations
+     * *
+     */
+    @Override
+    public boolean registerEntity(Entity entity) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean updateEntity(Entity entity) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean deleteEntity(String entityId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public Entity getEntity(String entityId) throws GovRegistryException, TException {
+        return null;
+    }
+
+    @Override
+    public List<Entity> searchEntities(String domain, String entityType, Map<String, String> filters, int offset, int limit) throws GovRegistryException, TException {
+        return null;
+    }
+
+    /**
+     * * EntityType Operations
+     * *
+     */
+    @Override
+    public boolean createPermissionType(PermissionType permisionType) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean updatePermissionType(PermissionType permisionType) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public boolean deletePermissionType(String entityTypeId) throws GovRegistryException, TException {
+        return false;
+    }
+
+    @Override
+    public PermissionType getPermissionType(String permisionTypeId) throws GovRegistryException, TException {
+        return null;
+    }
+
+    @Override
+    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws GovRegistryException, TException {
+        return null;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/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
new file mode 100644
index 0000000..ceba398
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?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">
+        <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>
+        <class>org.apache.airavata.sharing.registry.db.entities.EntityTypeEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.PermissionTypeEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.SharingEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.UserEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.UserGroupEntity</class>
+    </persistence-unit>
+</persistence>

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/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
new file mode 100644
index 0000000..7c03e0c
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/main/resources/gov-registry.sql
@@ -0,0 +1,135 @@
+/*
+ *
+ * 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),
+  NAME VARCHAR(255),
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  PRIMARY KEY (DOMAIN_ID)
+);
+
+CREATE TABLE USER (
+  USER_ID VARCHAR(255),
+  DOMAIN_ID VARCHAR(255),
+  USER_NAME VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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),
+  DOMAIN_ID VARCHAR(255),
+  NAME VARCHAR(255),
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255),
+  TYPE VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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),
+  CHILD_ID VARCHAR(255),
+  CHILD_TYPE VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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),
+  DOMAIN_ID VARCHAR(255),
+  NAME VARCHAR(255),
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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),
+  DOMAIN_ID VARCHAR(255),
+  NAME VARCHAR(255),
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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),
+  DOMAIN_ID VARCHAR(255),
+  ENTITY_TYPE_ID VARCHAR(255),
+  OWNER_ID VARCHAR(255),
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255),
+  DESCRIPTION VARCHAR(255),
+  FULL_TEXT TEXT,
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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
+);
+
+CREATE TABLE ENTITY_METADATA (
+  ENTITY_ID VARCHAR (255),
+  META_KEY VARCHAR (255),
+  META_VALUE VARCHAR (255),
+  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),
+  ENTITY_TYPE_ID VARCHAR(255),
+  ENTITY_ID VARCHAR(255),
+  GROUP_ID VARCHAR(255),
+  CREATED_TIME BIGINT,
+  UPDATED_TIME BIGINT,
+  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 (ENTITY_TYPE_ID) REFERENCES  ENTITY_TYPE(ENTITY_TYPE_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),
+  CONFIG_VALUE VARCHAR(255),
+  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/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/db/RepositoriesTest.java
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/db/RepositoriesTest.java b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/db/RepositoriesTest.java
new file mode 100644
index 0000000..aeeaafb
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/db/RepositoriesTest.java
@@ -0,0 +1,353 @@
+/*
+ *
+ * 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.db;
+
+import junit.framework.Assert;
+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.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class RepositoriesTest {
+    private final static Logger logger = LoggerFactory.getLogger(RepositoriesTest.class);
+
+    @Test
+    public void test() throws GovRegistryException {
+
+        //Creating domain
+        Domain domain = new Domain();
+        String domainId = "test-domain."+System.currentTimeMillis();
+        domain.setDomainId(domainId);
+        domain.setName(domainId);
+        domain.setDescription("test domain description");
+        domain.setCreatedTime(System.currentTimeMillis());
+        domain.setUpdatedTime(System.currentTimeMillis());
+
+        DomainRepository domainRepository = new DomainRepository();
+        domain = domainRepository.create(domain);
+        Assert.assertNotNull(domain);
+
+        Map<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.DomainTable.DESCRIPTION, "test");
+        Assert.assertTrue(domainRepository.select(filters, 0, 10).size() > 0);
+
+
+        //Creating users
+        User user1 = new User();
+        String userName1 = "test-user." + System.currentTimeMillis();
+        String userId1 = domainId + ":" + userName1;
+        user1.setUserId(userId1);
+        user1.setUserName(userName1);
+        user1.setDomainId(domainId);
+        user1.setCreatedTime(System.currentTimeMillis());
+        user1.setUpdatedTime(System.currentTimeMillis());
+
+        UserRepository userRepository = new UserRepository();
+        user1 = userRepository.create(user1);
+        Assert.assertNotNull(user1);
+
+        User user2 = new User();
+        String userName2 = "test-user." + System.currentTimeMillis();
+        String userId2 = domainId + ":" + userName2;
+        user2.setUserId(userId2);
+        user2.setUserName(userName2);
+        user2.setDomainId(domainId);
+        user2.setCreatedTime(System.currentTimeMillis());
+        user2.setUpdatedTime(System.currentTimeMillis());
+
+        userRepository.create(user2);
+
+        User user3 = new User();
+        String userName3 = "test-user." + System.currentTimeMillis();
+        String userId3 = domainId + ":" + userName3;
+        user3.setUserId(userId3);
+        user3.setUserName(userName3);
+        user3.setDomainId(domainId);
+        user3.setCreatedTime(System.currentTimeMillis());
+        user3.setUpdatedTime(System.currentTimeMillis());
+
+        userRepository.create(user3);
+
+        filters = new HashMap<>();
+        filters.put(DBConstants.UserTable.USER_NAME, "test");
+        Assert.assertTrue(userRepository.select(filters, 0, 10).size() > 0);
+
+        // Creating user groups
+        UserGroup userGroup1 = new UserGroup();
+        String groupName1 = "test-group";
+        String groupId1 = domainId + ":" + groupName1 + "." + System.currentTimeMillis();
+        userGroup1.setGroupId(groupId1);
+        userGroup1.setDomainId(domainId);
+        userGroup1.setName(groupName1);
+        userGroup1.setDescription("test group description");
+        userGroup1.setOwnerId(userId1);
+        userGroup1.setGroupType(GroupType.MULTI_USER);
+        userGroup1.setCreatedTime(System.currentTimeMillis());
+        userGroup1.setUpdatedTime(System.currentTimeMillis());
+
+        UserGroupRepository userGroupRepository = new UserGroupRepository();
+        userGroup1 = userGroupRepository.create(userGroup1);
+        Assert.assertNotNull(userGroup1);
+
+        UserGroup userGroup2 = new UserGroup();
+        String groupName2 = "test-group";
+        String groupId2 = domainId + ":" + groupName2 + "." + System.currentTimeMillis();
+        userGroup2.setGroupId(groupId2);
+        userGroup2.setDomainId(domainId);
+        userGroup2.setName(groupName2);
+        userGroup2.setDescription("test group description");
+        userGroup2.setOwnerId(userId2);
+        userGroup2.setGroupType(GroupType.MULTI_USER);
+        userGroup2.setCreatedTime(System.currentTimeMillis());
+        userGroup2.setUpdatedTime(System.currentTimeMillis());
+
+        userGroupRepository.create(userGroup2);
+
+        UserGroup userGroup3 = new UserGroup();
+        String groupName3 = "test-group";
+        String groupId3 = domainId + ":" + groupName3 + "." + System.currentTimeMillis();
+        userGroup3.setGroupId(groupId3);
+        userGroup3.setDomainId(domainId);
+        userGroup3.setName(groupName3);
+        userGroup3.setDescription("test group description");
+        userGroup3.setOwnerId(userId3);
+        userGroup3.setGroupType(GroupType.MULTI_USER);
+        userGroup3.setCreatedTime(System.currentTimeMillis());
+        userGroup3.setUpdatedTime(System.currentTimeMillis());
+
+        userGroupRepository.create(userGroup3);
+
+        //Creating Groups for users (This is an implementation level abstract)
+        UserGroup ug1 = new UserGroup();
+        String ug1Name = "user1-group-name";
+        String ug1GroupId = userId1;
+        ug1.setGroupId(ug1GroupId);
+        ug1.setDomainId(domainId);
+        ug1.setName(ug1Name);
+        ug1.setDescription("test group description");
+        ug1.setOwnerId(userId1);
+        ug1.setGroupType(GroupType.SINGLE_USER);
+        ug1.setCreatedTime(System.currentTimeMillis());
+        ug1.setUpdatedTime(System.currentTimeMillis());
+
+        userGroupRepository.create(ug1);
+
+        UserGroup ug2 = new UserGroup();
+        String ug2Name = "user2-group-name";
+        String ug2GroupId = userId2;
+        ug2.setGroupId(ug2GroupId);
+        ug2.setDomainId(domainId);
+        ug2.setName(ug2Name);
+        ug2.setDescription("test group description");
+        ug2.setOwnerId(userId1);
+        ug2.setGroupType(GroupType.SINGLE_USER);
+        ug2.setCreatedTime(System.currentTimeMillis());
+        ug2.setUpdatedTime(System.currentTimeMillis());
+
+        userGroupRepository.create(ug2);
+
+        UserGroup ug3 = new UserGroup();
+        String ug3Name = "user1-group-name";
+        String ug3GroupId = userId3;
+        ug3.setGroupId(ug3GroupId);
+        ug3.setDomainId(domainId);
+        ug3.setName(ug3Name);
+        ug3.setDescription("test group description");
+        ug3.setOwnerId(userId1);
+        ug3.setGroupType(GroupType.SINGLE_USER);
+        ug3.setCreatedTime(System.currentTimeMillis());
+        ug3.setUpdatedTime(System.currentTimeMillis());
+
+        userGroupRepository.create(ug3);
+
+        GroupMembership grpU2ToGrp2 = new GroupMembership();
+        grpU2ToGrp2.setParentId(groupId2);
+        grpU2ToGrp2.setChildId(userId2);
+        grpU2ToGrp2.setChildType(GroupChildType.USER);
+
+        GroupMembershipRepository groupMembershipRepository = new GroupMembershipRepository();
+        grpU2ToGrp2 = groupMembershipRepository.create(grpU2ToGrp2);
+        Assert.assertNotNull(grpU2ToGrp2);
+
+        GroupMembership grpU3ToGrp2 = new GroupMembership();
+        grpU3ToGrp2.setParentId(groupId2);
+        grpU3ToGrp2.setChildId(userId3);
+        grpU3ToGrp2.setChildType(GroupChildType.USER);
+
+        groupMembershipRepository.create(grpU3ToGrp2);
+
+        GroupMembership grpU1ToGrp1 = new GroupMembership();
+        grpU1ToGrp1.setParentId(groupId1);
+        grpU1ToGrp1.setChildId(userId1);
+        grpU1ToGrp1.setChildType(GroupChildType.USER);
+
+        groupMembershipRepository.create(grpU1ToGrp1);
+
+        GroupMembership grpG2ToGrp1 = new GroupMembership();
+        grpG2ToGrp1.setParentId(groupId1);
+        grpG2ToGrp1.setChildId(groupId2);
+        grpG2ToGrp1.setChildType(GroupChildType.GROUP);
+
+        groupMembershipRepository.create(grpG2ToGrp1);
+
+        filters = new HashMap<>();
+        filters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId2);
+        Assert.assertTrue(groupMembershipRepository.select(filters, 0, 10).size() == 2);
+
+        Assert.assertTrue(groupMembershipRepository.getChildMembershipsOfGroup(groupId2).size() == 2);
+        Assert.assertTrue(groupMembershipRepository.getAllChildUsers(groupId2).size() == 2);
+        Assert.assertTrue(groupMembershipRepository.getAllChildGroups(groupId1).size() == 1);
+
+        Assert.assertTrue(groupMembershipRepository.getAllParentMembershipsForChild(userId3).size() == 2);
+        Assert.assertTrue(groupMembershipRepository.getAllParentGroupsForChild(userId3).size() == 2);
+
+        //Creating permission types
+        PermissionType permissionType1 = new PermissionType();
+        String permissionName1 = "READ";
+        String permissionType1Id = domainId + ":" + permissionName1;
+        permissionType1.setPermissionTypeId(permissionType1Id);
+        permissionType1.setDomainId(domainId);
+        permissionType1.setName(permissionName1);
+        permissionType1.setDescription("READ description");
+        permissionType1.setCreatedTime(System.currentTimeMillis());
+        permissionType1.setUpdatedTime(System.currentTimeMillis());
+
+        PermissionTypeRepository permissionTypeRepository = new PermissionTypeRepository();
+        permissionType1 = permissionTypeRepository.create(permissionType1);
+        Assert.assertNotNull(permissionType1);
+
+        PermissionType permissionType2 = new PermissionType();
+        String permissionName2 = "WRITE";
+        String permissionType2Id = domainId + ":" + permissionName2;
+        permissionType2.setPermissionTypeId(permissionType2Id);
+        permissionType2.setDomainId(domainId);
+        permissionType2.setName(permissionName2);
+        permissionType2.setDescription("WRITE description");
+        permissionType2.setCreatedTime(System.currentTimeMillis());
+        permissionType2.setUpdatedTime(System.currentTimeMillis());
+        permissionTypeRepository.create(permissionType2);
+
+        //Creating entity types
+        EntityType entityType1 = new EntityType();
+        String entityType1Name = "Project";
+        String entityTypeId1 = domainId + ":" + entityType1Name;
+        entityType1.setEntityTypeId(entityTypeId1);
+        entityType1.setDomainId(domainId);
+        entityType1.setName(entityType1Name);
+        entityType1.setDescription("test entity type");
+        entityType1.setCreatedTime(System.currentTimeMillis());
+        entityType1.setUpdatedTime(System.currentTimeMillis());
+
+        EntityTypeRepository entityTypeRepository = new EntityTypeRepository();
+        entityType1 = entityTypeRepository.create(entityType1);
+        Assert.assertNotNull(entityType1);
+
+        EntityType entityType2 = new EntityType();
+        String entityType2Name = "Experiment";
+        String entityTypeId2 = domainId + ":" + entityType2Name;
+        entityType2.setEntityTypeId(entityTypeId2);
+        entityType2.setDomainId(domainId);
+        entityType2.setName(entityType2Name);
+        entityType2.setDescription("test entity type");
+        entityType2.setCreatedTime(System.currentTimeMillis());
+        entityType2.setUpdatedTime(System.currentTimeMillis());
+        entityTypeRepository.create(entityType2);
+
+        //Creating Entities
+        String entityId1 = UUID.randomUUID().toString();
+        Entity entity1 = new Entity();
+        entity1.setEntityId(entityId1);
+        entity1.setDomainId(domainId);
+        entity1.setEntityTypeId(entityTypeId1);
+        entity1.setOwnerId(userId1);
+        entity1.setName("Project name");
+        entity1.setDescription("Project description");
+        Map<String, String> metadataMap = new HashMap<>();
+        metadataMap.put("key", "val");
+        entity1.setMetadata(metadataMap);
+        entity1.setFullText("Project name project description");
+        entity1.setCreatedTime(System.currentTimeMillis());
+        entity1.setUpdatedTime(System.currentTimeMillis());
+
+        EntityRepository entityRepository = new EntityRepository();
+        entity1 = entityRepository.create(entity1);
+        Assert.assertNotNull(entity1);
+
+        String entityId2 = UUID.randomUUID().toString();
+        Entity entity2 = new Entity();
+        entity2.setEntityId(entityId2);
+        entity2.setDomainId(domainId);
+        entity2.setEntityTypeId(entityTypeId2);
+        entity2.setOwnerId(userId1);
+        entity2.setName("Experiment name");
+        entity2.setDescription("Experiment description");
+        entity2.setParentEntityId(entityId1);
+        metadataMap = new HashMap<>();
+        metadataMap.put("key", "val");
+        entity2.setMetadata(metadataMap);
+        entity2.setFullText("Project name project description");
+        entity2.setCreatedTime(System.currentTimeMillis());
+        entity2.setUpdatedTime(System.currentTimeMillis());
+
+        entityRepository.create(entity2);
+
+        String entityId3 = UUID.randomUUID().toString();
+        Entity entity3 = new Entity();
+        entity3.setEntityId(entityId3);
+        entity3.setDomainId(domainId);
+        entity3.setEntityTypeId(entityTypeId2);
+        entity3.setOwnerId(userId1);
+        entity3.setName("Experiment name");
+        entity3.setDescription("Experiment description");
+        entity3.setParentEntityId(entityId1);
+        metadataMap = new HashMap<>();
+        metadataMap.put("key", "val");
+        entity3.setMetadata(metadataMap);
+        entity3.setFullText("Project name project description");
+        entity3.setCreatedTime(System.currentTimeMillis());
+        entity3.setUpdatedTime(System.currentTimeMillis());
+
+        entityRepository.create(entity3);
+
+        // Creating sharing entries
+        Sharing sharing1 = new Sharing();
+        sharing1.setPermissionTypeId(permissionType1Id);
+        sharing1.setEntityId(entityId1);
+        sharing1.setGroupId(userId2);
+
+        SharingRepository sharingRepository = new SharingRepository();
+        sharing1 = sharingRepository.create(sharing1);
+        Assert.assertNotNull(sharing1);
+
+        Sharing sharing2 = new Sharing();
+        sharing2.setPermissionTypeId(permissionType1Id);
+        sharing2.setEntityId(entityId3);
+        sharing2.setGroupId(groupId2);
+
+        sharingRepository.create(sharing2);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/ac819e51/modules/airavata-sharing-registry/airavata-sharing-registry-stubs/pom.xml
----------------------------------------------------------------------
diff --git a/modules/airavata-sharing-registry/airavata-sharing-registry-stubs/pom.xml b/modules/airavata-sharing-registry/airavata-sharing-registry-stubs/pom.xml
new file mode 100644
index 0000000..ff0334c
--- /dev/null
+++ b/modules/airavata-sharing-registry/airavata-sharing-registry-stubs/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>airavata-sharing-registry</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <relativePath>../pom.xml</relativePath>
+        <version>${global.version}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>airavata-sharing-registry-stubs</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>0.9.3</version>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file