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/10/13 20:30:44 UTC

[1/6] airavata git commit: adding separate distribution

Repository: airavata
Updated Branches:
  refs/heads/develop a8e033358 -> e36c145d0


http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
new file mode 100644
index 0000000..0e58356
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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 SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  ICON BLOB,
+  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 NO ACTION
+);
+
+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 NO ACTION,
+  FOREIGN KEY (OWNER_ID) REFERENCES SHARING_USER(USER_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+
+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 NO ACTION,
+  FOREIGN KEY (CHILD_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+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 NO ACTION
+);
+
+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 NO ACTION
+);
+
+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 CLOB,
+  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 NO ACTION,
+  FOREIGN KEY (ENTITY_TYPE_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (OWNER_ID) REFERENCES SHARING_USER(USER_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (PARENT_ENTITY_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+-- 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 NO ACTION
+);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  GROUP_ID 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, INHERITED_PARENT_ID),
+  FOREIGN KEY (PERMISSION_TYPE_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (INHERITED_PARENT_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (GROUP_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+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/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
new file mode 100644
index 0000000..78d5d78
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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 SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  ICON BLOB,
+  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 SHARING_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 SHARING_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,
+  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, INHERITED_PARENT_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/e36c145d/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
new file mode 100644
index 0000000..cf92856
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
@@ -0,0 +1,290 @@
+/*
+ *
+ * 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;
+
+import junit.framework.Assert;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.sharing.registry.models.*;
+import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
+import org.apache.airavata.sharing.registry.util.Initialize;
+import org.apache.thrift.TException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SharingRegistryServerHandlerTest {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandlerTest.class);
+
+    @BeforeClass
+    public static void setup() throws SharingRegistryException, SQLException {
+        Initialize initialize = new Initialize("sharing-registry-derby.sql");
+        initialize.initializeDB();
+    }
+
+    @Test
+    public void test() throws TException, ApplicationSettingsException {
+        SharingRegistryServerHandler sharingRegistryServerHandler = new SharingRegistryServerHandler();
+
+        //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());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createDomain(domain));
+        Assert.assertTrue(sharingRegistryServerHandler.getDomains(0, 10).size() > 0);
+
+
+        //Creating users
+        User user1 = new User();
+        String userName1 = "test-user-1." + System.currentTimeMillis();
+        String userId1 = domainId + ":" + userName1;
+        user1.setUserId(userId1);
+        user1.setUserName(userName1);
+        user1.setDomainId(domainId);
+        user1.setCreatedTime(System.currentTimeMillis());
+        user1.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user1));
+
+        User user2 = new User();
+        String userName2 = "test-user-2." + System.currentTimeMillis();
+        String userId2 = domainId + ":" + userName2;
+        user2.setUserId(userId2);
+        user2.setUserName(userName2);
+        user2.setDomainId(domainId);
+        user2.setCreatedTime(System.currentTimeMillis());
+        user2.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user2));
+
+        User user3 = new User();
+        String userName3 = "test-user-3." + System.currentTimeMillis();
+        String userId3 = domainId + ":" + userName3;
+        user3.setUserId(userId3);
+        user3.setUserName(userName3);
+        user3.setDomainId(domainId);
+        user3.setCreatedTime(System.currentTimeMillis());
+        user3.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user3));
+
+        Assert.assertTrue(sharingRegistryServerHandler.getUsers(domainId, 0, 10).size() > 0);
+
+        // Creating user groups
+        UserGroup userGroup1 = new UserGroup();
+        String groupName1 = "test-group-1." + System.currentTimeMillis();
+        String groupId1 = domainId + ":" + groupName1;
+        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());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup1));
+
+        UserGroup userGroup2 = new UserGroup();
+        String groupName2 = "test-group-2." + System.currentTimeMillis();
+        String groupId2 = domainId + ":" + groupName2;
+        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());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup2));
+
+        sharingRegistryServerHandler.addUsersToGroup(Arrays.asList(userId1), groupId1);
+        sharingRegistryServerHandler.addUsersToGroup(Arrays.asList(userId2, userId3), groupId2);
+        sharingRegistryServerHandler.addChildGroupToParentGroup(groupId2, groupId1);
+
+        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembers(groupId1, 0, 10).size() == 2);
+        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembers(groupId2, 0, 10).size() == 2);
+
+
+        //Creating permission types
+        PermissionType permissionType1 = new PermissionType();
+        String permissionName1 = "READ";
+        permissionType1.setPermissionTypeId(domainId+":"+permissionName1);
+        permissionType1.setDomainId(domainId);
+        permissionType1.setName(permissionName1);
+        permissionType1.setDescription("READ description");
+        permissionType1.setCreatedTime(System.currentTimeMillis());
+        permissionType1.setUpdatedTime(System.currentTimeMillis());
+        String permissionTypeId1 = sharingRegistryServerHandler.createPermissionType(permissionType1);
+        Assert.assertNotNull(permissionTypeId1);
+
+        PermissionType permissionType2 = new PermissionType();
+        String permissionName2 = "WRITE";
+        permissionType2.setPermissionTypeId(domainId+":"+permissionName2);
+        permissionType2.setDomainId(domainId);
+        permissionType2.setName(permissionName2);
+        permissionType2.setDescription("WRITE description");
+        permissionType2.setCreatedTime(System.currentTimeMillis());
+        permissionType2.setUpdatedTime(System.currentTimeMillis());
+        String permissionTypeId2 = sharingRegistryServerHandler.createPermissionType(permissionType2);
+        Assert.assertNotNull(permissionTypeId2);
+
+        //Creating entity types
+        EntityType entityType1 = new EntityType();
+        String entityType1Name = "Project";
+        entityType1.setEntityTypeId(domainId+":"+entityType1Name);
+        entityType1.setDomainId(domainId);
+        entityType1.setName(entityType1Name);
+        entityType1.setDescription("test entity type");
+        entityType1.setCreatedTime(System.currentTimeMillis());
+        entityType1.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId1 = sharingRegistryServerHandler.createEntityType(entityType1);
+        Assert.assertNotNull(entityTypeId1);
+
+        EntityType entityType2 = new EntityType();
+        String entityType2Name = "Experiment";
+        entityType2.setEntityTypeId(domainId+":"+entityType2Name);
+        entityType2.setDomainId(domainId);
+        entityType2.setName(entityType2Name);
+        entityType2.setDescription("test entity type");
+        entityType2.setCreatedTime(System.currentTimeMillis());
+        entityType2.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId2 = sharingRegistryServerHandler.createEntityType(entityType2);
+        Assert.assertNotNull(entityTypeId2);
+
+        EntityType entityType3 = new EntityType();
+        String entityType3Name = "FileInput";
+        entityType3.setEntityTypeId(domainId+":"+entityType3Name);
+        entityType3.setDomainId(domainId);
+        entityType3.setName(entityType3Name);
+        entityType3.setDescription("file input type");
+        entityType3.setCreatedTime(System.currentTimeMillis());
+        entityType3.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId3 = sharingRegistryServerHandler.createEntityType(entityType3);
+        Assert.assertNotNull(entityTypeId3);
+
+        //Creating Entities
+        Entity entity1 = new Entity();
+        entity1.setEntityId(domainId+":Entity1");
+        entity1.setDomainId(domainId);
+        entity1.setEntityTypeId(entityTypeId1);
+        entity1.setOwnerId(userId1);
+        entity1.setName("Project name 1");
+        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());
+
+        String entityId1 = sharingRegistryServerHandler.createEntity(entity1);
+        Assert.assertNotNull(entityId1);
+
+        Entity entity2 = new Entity();
+        entity2.setEntityId(domainId+":Entity2");
+        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());
+
+        String entityId2 = sharingRegistryServerHandler.createEntity(entity2);
+        Assert.assertNotNull(entityId2);
+
+        Entity entity3 = new Entity();
+        entity3.setEntityId(domainId+":Entity3");
+        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());
+
+        String entityId3 = sharingRegistryServerHandler.createEntity(entity3);
+        Assert.assertNotNull(entityId3);
+
+        sharingRegistryServerHandler.shareEntityWithUsers(entityId1, Arrays.asList(userId2), permissionTypeId1, true);
+        sharingRegistryServerHandler.shareEntityWithGroups(entityId3, Arrays.asList(groupId2), permissionTypeId1, true);
+
+        Entity entity4 = new Entity();
+        entity4.setEntityId(domainId+":Entity4");
+        entity4.setDomainId(domainId);
+        entity4.setEntityTypeId(entityTypeId3);
+        entity4.setOwnerId(userId3);
+        entity4.setName("Input name");
+        entity4.setDescription("Input file description");
+        entity4.setParentEntityId(entityId3);
+        metadataMap = new HashMap<>();
+        metadataMap.put("key", "val");
+        entity4.setMetadata(metadataMap);
+        entity4.setFullText("Input File");
+        entity4.setCreatedTime(System.currentTimeMillis());
+        entity4.setUpdatedTime(System.currentTimeMillis());
+
+        String entityId4 = sharingRegistryServerHandler.createEntity(entity4);
+        Assert.assertNotNull(entityId4);
+
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId4, permissionTypeId1));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId1, entityId4, permissionTypeId1));
+        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId1, permissionTypeId1));
+
+        ArrayList<SearchCriteria> filters = new ArrayList<>();
+        SearchCriteria searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.LIKE);
+        searchCriteria.setValue("Input");
+        searchCriteria.setSearchField(EntitySearchField.NAME);
+        filters.add(searchCriteria);
+        Assert.assertTrue(sharingRegistryServerHandler.searchEntities(userId1, entityTypeId3, filters, 0, -1).size() > 0);
+
+        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedUsers(entityId1, permissionTypeId1));
+        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedGroups(entityId1, permissionTypeId1));
+
+//        sharingRegistryServerHandler.revokeEntitySharingFromUsers(entityId1, Arrays.asList(userId2), permissionTypeId1);
+//        sharingRegistryServerHandler.revokeEntitySharingFromGroups(entityId3, Arrays.asList(groupId2), permissionTypeId1);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java
new file mode 100644
index 0000000..4a89094
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java
@@ -0,0 +1,298 @@
+/*
+ *
+ * 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.util;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.sharing.registry.db.utils.JPAUtils;
+import org.apache.derby.drda.NetworkServerControl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.URI;
+import java.sql.*;
+import java.util.StringTokenizer;
+
+public class Initialize {
+    private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
+    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
+    public  String scriptName ;
+    private NetworkServerControl server;
+    private static final String delimiter = ";";
+    public static final String PERSISTANT_DATA = "Configuration";
+
+    public Initialize(String scriptName) {
+        this.scriptName = scriptName;
+    }
+
+    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
+        if (suffix.length() > buffer.length()) {
+            return false;
+        }
+        // this loop is done on purpose to avoid memory allocation performance
+        // problems on various JDKs
+        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
+        // implementation is ok though does allocation/copying
+        // StringBuffer.toString().endsWith() does massive memory
+        // allocation/copying on JDK 1.5
+        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
+        int endIndex = suffix.length() - 1;
+        int bufferIndex = buffer.length() - 1;
+        while (endIndex >= 0) {
+            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
+                return false;
+            }
+            bufferIndex--;
+            endIndex--;
+        }
+        return true;
+    }
+
+    private static boolean isServerStarted(NetworkServerControl server, int ntries)
+    {
+        for (int i = 1; i <= ntries; i ++)
+        {
+            try {
+                Thread.sleep(500);
+                server.ping();
+                return true;
+            }
+            catch (Exception e) {
+                if (i == ntries)
+                    return false;
+            }
+        }
+        return false;
+    }
+
+    public void initializeDB() throws SQLException{
+        String jdbcUrl = null;
+        String jdbcUser = null;
+        String jdbcPassword = null;
+        try{
+            jdbcUrl = ServerSettings.getSetting("sharingcatalog.jdbc.url");
+            jdbcUser = ServerSettings.getSetting("sharingcatalog.jdbc.user");
+            jdbcPassword = ServerSettings.getSetting("sharingcatalog.jdbc.password");
+            jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read properties", e);
+        }
+        startDerbyInServerMode();
+        if(!isServerStarted(server, 20)){
+           throw new RuntimeException("Derby server cound not started within five seconds...");
+        }
+
+        Connection conn = null;
+        try {
+            Class.forName(JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_DRIVER)).newInstance();
+            conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
+            if (!isDatabaseStructureCreated(PERSISTANT_DATA, conn)) {
+                executeSQLScript(conn);
+                logger.info("New Database created for Registry");
+            } else {
+                logger.debug("Database already created for Registry!");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RuntimeException("Database failure", e);
+        } finally {
+            try {
+                if (conn != null){
+                    if (!conn.getAutoCommit()) {
+                        conn.commit();
+                    }
+                    conn.close();
+                }
+            } catch (SQLException e) {
+                logger.error(e.getMessage(), e);
+            }
+        }
+    }
+
+    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
+        try {
+            System.out.println("Running a query to test the database tables existence.");
+            // check whether the tables are already created with a query
+            Statement statement = null;
+            try {
+                statement = conn.createStatement();
+                ResultSet rs = statement.executeQuery("select * from " + tableName);
+                if (rs != null) {
+                    rs.close();
+                }
+            } finally {
+                try {
+                    if (statement != null) {
+                        statement.close();
+                    }
+                } catch (SQLException e) {
+                    return false;
+                }
+            }
+        } catch (SQLException e) {
+            return false;
+        }
+
+        return true;
+    }
+
+    private void executeSQLScript(Connection conn) throws Exception {
+        StringBuffer sql = new StringBuffer();
+        BufferedReader reader = null;
+        try{
+
+        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName);
+        reader = new BufferedReader(new InputStreamReader(inputStream));
+        String line;
+        while ((line = reader.readLine()) != null) {
+            line = line.trim();
+            if (line.startsWith("//")) {
+                continue;
+            }
+            if (line.startsWith("--")) {
+                continue;
+            }
+            StringTokenizer st = new StringTokenizer(line);
+            if (st.hasMoreTokens()) {
+                String token = st.nextToken();
+                if ("REM".equalsIgnoreCase(token)) {
+                    continue;
+                }
+            }
+            sql.append(" ").append(line);
+
+            // SQL defines "--" as a comment to EOL
+            // and in Oracle it may contain a hint
+            // so we cannot just remove it, instead we must end it
+            if (line.indexOf("--") >= 0) {
+                sql.append("\n");
+            }
+            if ((checkStringBufferEndsWith(sql, delimiter))) {
+                executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
+                sql.replace(0, sql.length(), "");
+            }
+        }
+        // Catch any statements not followed by ;
+        if (sql.length() > 0) {
+            executeSQL(sql.toString(), conn);
+        }
+        }catch (IOException e){
+            logger.error("Error occurred while executing SQL script for creating Airavata database", e);
+            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
+        }finally {
+            if (reader != null) {
+                reader.close();
+            }
+
+        }
+
+    }
+
+    private static void executeSQL(String sql, Connection conn) throws Exception {
+        // Check and ignore empty statements
+        if ("".equals(sql.trim())) {
+            return;
+        }
+
+        Statement statement = null;
+        try {
+            logger.debug("SQL : " + sql);
+
+            boolean ret;
+            int updateCount = 0, updateCountTotal = 0;
+            statement = conn.createStatement();
+            ret = statement.execute(sql);
+            updateCount = statement.getUpdateCount();
+            do {
+                if (!ret) {
+                    if (updateCount != -1) {
+                        updateCountTotal += updateCount;
+                    }
+                }
+                ret = statement.getMoreResults();
+                if (ret) {
+                    updateCount = statement.getUpdateCount();
+                }
+            } while (ret);
+
+            logger.debug(sql + " : " + updateCountTotal + " rows affected");
+
+            SQLWarning warning = conn.getWarnings();
+            while (warning != null) {
+                logger.warn(warning + " sql warning");
+                warning = warning.getNextWarning();
+            }
+            conn.clearWarnings();
+        } catch (SQLException e) {
+            if (e.getSQLState().equals("X0Y32")) {
+                // eliminating the table already exception for the derby
+                // database
+                logger.info("Table Already Exists", e);
+            } else {
+                throw new Exception("Error occurred while executing : " + sql, e);
+            }
+        } finally {
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (SQLException e) {
+                    logger.error("Error occurred while closing result set.", e);
+                }
+            }
+        }
+    }
+
+    private void startDerbyInServerMode() {
+        try {
+            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
+            String jdbcURL = JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_URL);
+            String cleanURI = jdbcURL.substring(5);
+            URI uri = URI.create(cleanURI);
+            server = new NetworkServerControl(InetAddress.getByName(uri.getHost()),
+                    20000,
+                    JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_USER), JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_USER));
+            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
+            server.start(consoleWriter);
+        } catch (IOException e) {
+            logger.error("Unable to start Apache derby in the server mode! Check whether " +
+                    "specified port is available");
+        } catch (Exception e) {
+            logger.error("Unable to start Apache derby in the server mode! Check whether " +
+                    "specified port is available");
+        }
+
+    }
+
+    public void stopDerbyServer() throws SQLException{
+        try {
+            server.shutdown();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new SQLException("Error while stopping derby server", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-stubs/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-stubs/pom.xml b/modules/sharing-registry/sharing-registry-stubs/pom.xml
index eb47dc9..56e8eb4 100644
--- a/modules/sharing-registry/sharing-registry-stubs/pom.xml
+++ b/modules/sharing-registry/sharing-registry-stubs/pom.xml
@@ -16,7 +16,7 @@
         <dependency>
             <groupId>org.apache.thrift</groupId>
             <artifactId>libthrift</artifactId>
-            <version>0.9.3</version>
+            <version>${thrift.version}</version>
         </dependency>
     </dependencies>
 


[6/6] airavata git commit: adding separate distribution

Posted by sc...@apache.org.
adding separate distribution


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

Branch: refs/heads/develop
Commit: e36c145d0fa794d0a56be117f321c30fbce1189a
Parents: a8e0333
Author: scnakandala <su...@gmail.com>
Authored: Thu Oct 13 16:30:27 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Thu Oct 13 16:30:40 2016 -0400

----------------------------------------------------------------------
 airavata-api/airavata-api-server/pom.xml        |   2 +-
 modules/sharing-registry/pom.xml                |  11 +-
 .../sharing-data-migrator/pom.xml               |   2 +-
 .../sharing-registry-core/pom.xml               | 104 ----
 .../registry/db/entities/DomainEntity.java      | 113 ----
 .../registry/db/entities/EntityEntity.java      | 192 ------
 .../registry/db/entities/EntityTypeEntity.java  | 125 ----
 .../db/entities/GroupMembershipEntity.java      | 112 ----
 .../db/entities/GroupMembershipEntityPK.java    |  74 ---
 .../db/entities/PermissionTypeEntity.java       | 125 ----
 .../registry/db/entities/SharingEntity.java     | 136 ----
 .../registry/db/entities/SharingEntityPK.java   |  99 ---
 .../registry/db/entities/SharingUserEntity.java | 146 -----
 .../registry/db/entities/UserGroupEntity.java   | 150 -----
 .../db/repositories/AbstractRepository.java     | 138 -----
 .../db/repositories/DomainRepository.java       |  34 -
 .../db/repositories/EntityRepository.java       |  86 ---
 .../db/repositories/EntityTypeRepository.java   |  34 -
 .../repositories/GroupMembershipRepository.java |  98 ---
 .../repositories/PermissionTypeRepository.java  |  52 --
 .../db/repositories/SharingRepository.java      |  80 ---
 .../db/repositories/UserGroupRepository.java    |  51 --
 .../db/repositories/UserRepository.java         |  51 --
 .../sharing/registry/db/utils/Committer.java    |  27 -
 .../registry/db/utils/ConnectionPool.java       | 382 ------------
 .../sharing/registry/db/utils/DBConstants.java  | 101 ---
 .../registry/db/utils/DatabaseCreator.java      | 353 -----------
 .../sharing/registry/db/utils/JPAUtils.java     | 230 -------
 .../sharing/registry/db/utils/JdbcStorage.java  | 175 ------
 .../db/utils/ObjectMapperSingleton.java         |  39 --
 .../registry/server/SharingRegistryServer.java  |  28 -
 .../server/SharingRegistryServerHandler.java    | 613 -------------------
 .../src/main/resources/META-INF/persistence.xml |  15 -
 .../main/resources/sharing-registry-derby.sql   | 141 -----
 .../main/resources/sharing-registry-mysql.sql   | 141 -----
 .../SharingRegistryServerHandlerTest.java       | 290 ---------
 .../sharing/registry/util/Initialize.java       | 298 ---------
 .../sharing-registry-distribution/pom.xml       |  91 +++
 .../src/main/assembly/bin-assembly.xml          |  69 +++
 .../src/main/resources/bin/setenv.sh            |  65 ++
 .../src/main/resources/bin/sharing-registry.sh  |  87 +++
 .../sharing-registry-server/pom.xml             |  99 +++
 .../registry/db/entities/DomainEntity.java      | 113 ++++
 .../registry/db/entities/EntityEntity.java      | 192 ++++++
 .../registry/db/entities/EntityTypeEntity.java  | 125 ++++
 .../db/entities/GroupMembershipEntity.java      | 112 ++++
 .../db/entities/GroupMembershipEntityPK.java    |  74 +++
 .../db/entities/PermissionTypeEntity.java       | 125 ++++
 .../registry/db/entities/SharingEntity.java     | 136 ++++
 .../registry/db/entities/SharingEntityPK.java   |  99 +++
 .../registry/db/entities/SharingUserEntity.java | 146 +++++
 .../registry/db/entities/UserGroupEntity.java   | 150 +++++
 .../db/repositories/AbstractRepository.java     | 138 +++++
 .../db/repositories/DomainRepository.java       |  34 +
 .../db/repositories/EntityRepository.java       |  86 +++
 .../db/repositories/EntityTypeRepository.java   |  34 +
 .../repositories/GroupMembershipRepository.java |  98 +++
 .../repositories/PermissionTypeRepository.java  |  52 ++
 .../db/repositories/SharingRepository.java      |  80 +++
 .../db/repositories/UserGroupRepository.java    |  51 ++
 .../db/repositories/UserRepository.java         |  51 ++
 .../sharing/registry/db/utils/Committer.java    |  27 +
 .../registry/db/utils/ConnectionPool.java       | 382 ++++++++++++
 .../sharing/registry/db/utils/DBConstants.java  | 101 +++
 .../registry/db/utils/DatabaseCreator.java      | 353 +++++++++++
 .../sharing/registry/db/utils/JPAUtils.java     | 230 +++++++
 .../sharing/registry/db/utils/JdbcStorage.java  | 175 ++++++
 .../db/utils/ObjectMapperSingleton.java         |  39 ++
 .../registry/server/SharingRegistryServer.java  |  28 +
 .../server/SharingRegistryServerHandler.java    | 613 +++++++++++++++++++
 .../src/main/resources/META-INF/persistence.xml |  15 +
 .../main/resources/sharing-registry-derby.sql   | 141 +++++
 .../main/resources/sharing-registry-mysql.sql   | 141 +++++
 .../SharingRegistryServerHandlerTest.java       | 290 +++++++++
 .../sharing/registry/util/Initialize.java       | 298 +++++++++
 .../sharing-registry-stubs/pom.xml              |   2 +-
 76 files changed, 5150 insertions(+), 4840 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/airavata-api/airavata-api-server/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/pom.xml b/airavata-api/airavata-api-server/pom.xml
index 3ceb494..7116c1d 100644
--- a/airavata-api/airavata-api-server/pom.xml
+++ b/airavata-api/airavata-api-server/pom.xml
@@ -73,7 +73,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-sharing-registry-core</artifactId>
+            <artifactId>airavata-sharing-registry-server</artifactId>
             <version>${project.version}</version>
         </dependency>
         <!--<dependency>-->

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/pom.xml b/modules/sharing-registry/pom.xml
index a931543..781a11d 100644
--- a/modules/sharing-registry/pom.xml
+++ b/modules/sharing-registry/pom.xml
@@ -11,18 +11,21 @@
         <version>0.17-SNAPSHOT</version>
     </parent>
 
+    <properties>
+        <global.version>0.17-SNAPSHOT</global.version>
+    </properties>
+
     <groupId>org.apache.airavata</groupId>
     <artifactId>airavata-sharing-registry</artifactId>
     <packaging>pom</packaging>
     <version>${global.version}</version>
 
-    <properties>
-        <global.version>0.17-SNAPSHOT</global.version>
-    </properties>
+
 
     <modules>
         <module>sharing-registry-stubs</module>
-        <module>sharing-registry-core</module>
+        <module>sharing-registry-server</module>
         <module>sharing-data-migrator</module>
+        <module>sharing-registry-distribution</module>
     </modules>
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-data-migrator/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-data-migrator/pom.xml b/modules/sharing-registry/sharing-data-migrator/pom.xml
index 7a6de21..3fb2035 100644
--- a/modules/sharing-registry/sharing-data-migrator/pom.xml
+++ b/modules/sharing-registry/sharing-data-migrator/pom.xml
@@ -15,7 +15,7 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-sharing-registry-core</artifactId>
+            <artifactId>airavata-sharing-registry-server</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/pom.xml b/modules/sharing-registry/sharing-registry-core/pom.xml
deleted file mode 100644
index d529744..0000000
--- a/modules/sharing-registry/sharing-registry-core/pom.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-<?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-core</artifactId>
-    <packaging>jar</packaging>
-    <dependencies>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.7.10</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>0.9.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-sharing-registry-stubs</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-server-configuration</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.airavata</groupId>
-            <artifactId>airavata-commons</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>net.sf.dozer</groupId>
-            <artifactId>dozer</artifactId>
-            <version>5.4.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa-all</artifactId>
-            <version>2.2.0</version>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>5.1.34</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>0.9.3</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.5.1</version>
-                <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.openjpa</groupId>
-                <artifactId>openjpa-maven-plugin</artifactId>
-                <version>2.2.0</version>
-                <configuration>
-                    <includes>**/entities/*.class</includes>
-                    <excludes>**/entities/XML*.class</excludes>
-                    <addDefaultConstructor>true</addDefaultConstructor>
-                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>enhancer</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>enhance</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.apache.openjpa</groupId>
-                        <artifactId>openjpa</artifactId>
-                        <version>2.2.0</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java
deleted file mode 100644
index 48b5314..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java
+++ /dev/null
@@ -1,113 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "DOMAIN", schema = "" )
-public class DomainEntity {
-    private final static Logger logger = LoggerFactory.getLogger(DomainEntity.class);
-    private String domainId;
-    private String name;
-    private String description;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        DomainEntity that = (DomainEntity) o;
-
-        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
-        if (name != null ? !name.equals(that.name) : that.name != null) return false;
-        if (description != null ? !description.equals(that.description) : that.description != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = domainId != null ? domainId.hashCode() : 0;
-        result = 31 * result + (name != null ? name.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 0);
-        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
-        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
deleted file mode 100644
index de8abf4..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
+++ /dev/null
@@ -1,192 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.util.Map;
-
-@Entity
-@Table(name = "ENTITY", schema = "")
-public class EntityEntity {
-    private final static Logger logger = LoggerFactory.getLogger(EntityEntity.class);
-    private String entityId;
-    private String domainId;
-    private String entityTypeId;
-    private String ownerId;
-    private String parentEntityId;
-    private String name;
-    private String description;
-    private Map<String, String> metadata;
-    private String fullText;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "ENTITY_ID")
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Basic
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "ENTITY_TYPE_ID")
-    public String getEntityTypeId() {
-        return entityTypeId;
-    }
-
-    public void setEntityTypeId(String entityTypeId) {
-        this.entityTypeId = entityTypeId;
-    }
-
-    @Basic
-    @Column(name = "OWNER_ID")
-    public String getOwnerId() {
-        return ownerId;
-    }
-
-    public void setOwnerId(String ownerId) {
-        this.ownerId = ownerId;
-    }
-
-    @Basic
-    @Column(name = "PARENT_ENTITY_ID")
-    public String getParentEntityId() {
-        return parentEntityId;
-    }
-
-    public void setParentEntityId(String parentEntityId) {
-        this.parentEntityId = parentEntityId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @ElementCollection
-    @CollectionTable(
-            name="ENTITY_METADATA",
-            joinColumns=@JoinColumn(name="ENTITY_ID")
-    )
-    @MapKeyColumn(name="META_KEY")
-    @Column(name="META_VALUE")
-    public Map<String, String> getMetadata() {
-        return metadata;
-    }
-
-    public void setMetadata(Map<String, String> metadata) {
-        this.metadata = metadata;
-    }
-
-    @Lob
-    @Column(name = "FULL_TEXT")
-    public String getFullText() {
-        return fullText;
-    }
-
-    public void setFullText(String fullText) {
-        this.fullText = fullText;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        EntityEntity that = (EntityEntity) o;
-
-        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
-        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
-        if (parentEntityId != null ? !parentEntityId.equals(that.parentEntityId) : that.parentEntityId != null) return false;
-        if (name != null ? !name.equals(that.name) : that.name != null) return false;
-        if (description != null ? !description.equals(that.description) : that.description != null) return false;
-        if (metadata.equals(that.metadata)) return false;
-        if (fullText != null ? !fullText.equals(that.fullText) : that.fullText != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-        if (ownerId != null ? !ownerId.equals(that.ownerId) : that.ownerId != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = entityId != null ? entityId.hashCode() : 0;
-        result = 31 * result + (name != null ? name.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 0);
-        result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
-        result = 31 * result + (fullText != null ? fullText.hashCode() : 0);
-        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
-        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java
deleted file mode 100644
index 0b789ed..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java
+++ /dev/null
@@ -1,125 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "ENTITY_TYPE", schema = "")
-public class EntityTypeEntity {
-    private final static Logger logger = LoggerFactory.getLogger(EntityTypeEntity.class);
-    private String entityTypeId;
-    private String domainId;
-    private String name;
-    private String description;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "ENTITY_TYPE_ID")
-    public String getEntityTypeId() {
-        return entityTypeId;
-    }
-
-    public void setEntityTypeId(String entityTypeId) {
-        this.entityTypeId = entityTypeId;
-    }
-
-    @Basic
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        EntityTypeEntity that = (EntityTypeEntity) o;
-
-        if (entityTypeId != null ? !entityTypeId.equals(that.entityTypeId) : that.entityTypeId != null) return false;
-        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
-        if (name != null ? !name.equals(that.name) : that.name != null) return false;
-        if (description != null ? !description.equals(that.description) : that.description != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = entityTypeId != null ? entityTypeId.hashCode() : 0;
-        result = 31 * result + (name != null ? name.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 0);
-        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
-        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java
deleted file mode 100644
index c62a52d..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java
+++ /dev/null
@@ -1,112 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "GROUP_MEMBERSHIP", schema = "")
-@IdClass(GroupMembershipEntityPK.class)
-public class GroupMembershipEntity {
-    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntity.class);
-    private String parentId;
-    private String childId;
-    private String childType;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "PARENT_ID")
-    public String getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(String parentId) {
-        this.parentId = parentId;
-    }
-
-    @Id
-    @Column(name = "CHILD_ID")
-    public String getChildId() {
-        return childId;
-    }
-
-    public void setChildId(String childId) {
-        this.childId = childId;
-    }
-
-    @Basic
-    @Column(name = "CHILD_TYPE")
-    public String getChildType() {
-        return childType;
-    }
-
-    public void setChildType(String childType) {
-        this.childType = childType;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        GroupMembershipEntity that = (GroupMembershipEntity) o;
-
-        if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false;
-        if (childId != null ? !childId.equals(that.childId) : that.childId != null) return false;
-        if (childType != null ? !childType.equals(that.childType) : that.childType != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = parentId != null ? parentId.hashCode() : 0;
-        result = 31 * result + (childId != null ? childId.hashCode() : 0);
-        result = 31 * result + (childType != null ? childType.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java
deleted file mode 100644
index be3b1f9..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java
+++ /dev/null
@@ -1,74 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class GroupMembershipEntityPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntityPK.class);
-    private String parentId;
-    private String childId;
-
-    @Column(name = "PARENT_ID")
-    @Id
-    public String getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(String parentId) {
-        this.parentId = parentId;
-    }
-
-    @Column(name = "CHILD_ID")
-    @Id
-    public String getChildId() {
-        return childId;
-    }
-
-    public void setChildId(String childId) {
-        this.childId = childId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        GroupMembershipEntityPK that = (GroupMembershipEntityPK) o;
-
-        if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false;
-        if (childId != null ? !childId.equals(that.childId) : that.childId != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = parentId != null ? parentId.hashCode() : 0;
-        result = 31 * result + (childId != null ? childId.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java
deleted file mode 100644
index c145cbe..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java
+++ /dev/null
@@ -1,125 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "PERMISSION_TYPE", schema = "")
-public class PermissionTypeEntity {
-    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeEntity.class);
-    private String permissionTypeId;
-    private String domainId;
-    private String name;
-    private String description;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "PERMISSION_TYPE_ID")
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Basic
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        PermissionTypeEntity that = (PermissionTypeEntity) o;
-
-        if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null)
-            return false;
-        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
-        if (name != null ? !name.equals(that.name) : that.name != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0;
-        result = 31 * result + (name != null ? name.hashCode() : 0);
-        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
-        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java
deleted file mode 100644
index b4b74b0..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java
+++ /dev/null
@@ -1,136 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "SHARING", schema = "")
-@IdClass(SharingEntityPK.class)
-public class SharingEntity {
-    private final static Logger logger = LoggerFactory.getLogger(SharingEntity.class);
-    private String permissionTypeId;
-    private String entityId;
-    private String groupId;
-    private String sharingType;
-    private String inheritedParentId;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "PERMISSION_TYPE_ID")
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Id
-    @Column(name = "ENTITY_ID")
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Id
-    @Column(name = "GROUP_ID")
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-
-    @Id
-    @Column(name = "INHERITED_PARENT_ID")
-    public String getInheritedParentId() {
-        return inheritedParentId;
-    }
-
-    public void setInheritedParentId(String inheritedParentId) {
-        this.inheritedParentId = inheritedParentId;
-    }
-
-    @Basic
-    @Column(name = "SHARING_TYPE")
-    public String getSharingType() {
-        return sharingType;
-    }
-
-    public void setSharingType(String sharingType) {
-        this.sharingType = sharingType;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        SharingEntity that = (SharingEntity) o;
-
-        if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null)
-            return false;
-        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
-        if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0;
-        result = 31 * result + (entityId != null ? entityId.hashCode() : 0);
-        result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java
deleted file mode 100644
index da77a87..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java
+++ /dev/null
@@ -1,99 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class SharingEntityPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(SharingEntityPK.class);
-    private String permissionTypeId;
-    private String entityId;
-    private String groupId;
-    private String inheritedParentId;
-
-    @Column(name = "PERMISSION_TYPE_ID")
-    @Id
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Column(name = "ENTITY_ID")
-    @Id
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Column(name = "GROUP_ID")
-    @Id
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Column(name = "INHERITED_PARENT_ID")
-    @Id
-    public String getInheritedParentId() {
-        return inheritedParentId;
-    }
-
-    public void setInheritedParentId(String inheritedParentId) {
-        this.inheritedParentId = inheritedParentId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        SharingEntityPK that = (SharingEntityPK) o;
-
-        if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null)
-            return false;
-        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
-        if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0;
-        result = 31 * result + (entityId != null ? entityId.hashCode() : 0);
-        result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java
deleted file mode 100644
index 0d17279..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java
+++ /dev/null
@@ -1,146 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.nio.ByteBuffer;
-
-@Entity
-@Table(name = "SHARING_USER", schema = "")
-public class SharingUserEntity {
-    private final static Logger logger = LoggerFactory.getLogger(SharingUserEntity.class);
-    private String userId;
-    private String domainId;
-    private String userName;
-    private String firstName;
-    private String lastName;
-    private ByteBuffer icon;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "USER_ID")
-    public String getUserId() {
-        return userId;
-    }
-
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    @Basic
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "USER_NAME")
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
-    @Basic
-    @Column(name = "FIRST_NAME")
-    public String getFirstName() {
-        return firstName;
-    }
-
-    public void setFirstName(String firstName) {
-        this.firstName = firstName;
-    }
-
-    @Basic
-    @Column(name = "LAST_NAME")
-    public String getLastName() {
-        return lastName;
-    }
-
-    public void setLastName(String lastName) {
-        this.lastName = lastName;
-    }
-
-    @Lob
-    @Column(name = "ICON")
-    public ByteBuffer getIcon() {
-        return icon;
-    }
-
-    public void setIcon(ByteBuffer icon) {
-        this.icon = icon;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        SharingUserEntity that = (SharingUserEntity) o;
-
-        if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false;
-        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
-        if (userName != null ? !userName.equals(that.userName) : that.userName != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = userId != null ? userId.hashCode() : 0;
-        result = 31 * result + (userName != null ? userName.hashCode() : 0);
-        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
-        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java
deleted file mode 100644
index 10d901a..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java
+++ /dev/null
@@ -1,150 +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.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "USER_GROUP", schema = "")
-public class UserGroupEntity {
-    private final static Logger logger = LoggerFactory.getLogger(UserGroupEntity.class);
-    private String groupId;
-    private String domainId;
-    private String name;
-    private String description;
-    private String ownerId;
-    private String groupType;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "GROUP_ID")
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Basic
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "OWNER_ID")
-    public String getOwnerId() {
-        return ownerId;
-    }
-
-    public void setOwnerId(String ownerId) {
-        this.ownerId = ownerId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "GROUP_TYPE")
-    public String getGroupType() {
-        return groupType;
-    }
-
-    public void setGroupType(String type) {
-        this.groupType = type;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        UserGroupEntity that = (UserGroupEntity) o;
-
-        if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false;
-        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
-        if (ownerId != null ? !ownerId.equals(that.ownerId) : that.ownerId != null) return false;
-        if (name != null ? !name.equals(that.name) : that.name != null) return false;
-        if (description != null ? !description.equals(that.description) : that.description != null) return false;
-        if (groupType != null ? !groupType.equals(that.groupType) : that.groupType != null) return false;
-        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
-        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = groupId != null ? groupId.hashCode() : 0;
-        result = 31 * result + (name != null ? name.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 0);
-        result = 31 * result + (groupType != null ? groupType.hashCode() : 0);
-        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
-        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
deleted file mode 100644
index a53a6a2..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
+++ /dev/null
@@ -1,138 +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.db.repositories;
-
-import org.apache.airavata.sharing.registry.db.utils.DBConstants;
-import org.apache.airavata.sharing.registry.db.utils.JPAUtils;
-import org.apache.airavata.sharing.registry.db.utils.ObjectMapperSingleton;
-import org.apache.airavata.sharing.registry.models.SharingRegistryException;
-import org.dozer.Mapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public abstract class AbstractRepository<T, E, Id> {
-    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
-
-    private Class<T> thriftGenericClass;
-    private Class<E> dbEntityGenericClass;
-
-    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass){
-        this.thriftGenericClass = thriftGenericClass;
-        this.dbEntityGenericClass = dbEntityGenericClass;
-    }
-
-    public T create(T t) throws SharingRegistryException {
-        return update(t);
-    }
-
-    public List<T> create(List<T> tList) throws SharingRegistryException {
-        return update(tList);
-    }
-
-    public  T update(T t) throws SharingRegistryException {
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        E entity = mapper.map(t, dbEntityGenericClass);
-        E persistedCopy = JPAUtils.execute(entityManager -> entityManager.merge(entity));
-        return mapper.map(persistedCopy, thriftGenericClass);
-    }
-
-    public  List<T> update(List<T> tList) throws SharingRegistryException {
-        List<T> returnList = new ArrayList<>();
-        for(T temp : tList)
-            returnList.add(update(temp));
-        return returnList;
-    }
-
-    public boolean delete(Id id) throws SharingRegistryException {
-        JPAUtils.execute(entityManager -> {
-            E entity = entityManager.find(dbEntityGenericClass, id);
-            entityManager.remove(entity);
-            return entity;
-        });
-        return true;
-    }
-
-    public boolean delete(List<Id> idList) throws SharingRegistryException {
-        for(Id id : idList)
-            delete(id);
-        return true;
-    }
-
-    public T get(Id id) throws SharingRegistryException {
-        E entity = JPAUtils.execute(entityManager -> entityManager
-                .find(dbEntityGenericClass, id));
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        if(entity == null)
-            return null;
-        return mapper.map(entity, thriftGenericClass);
-    }
-
-    public boolean isExists(Id id) throws SharingRegistryException {
-        return get(id) != null;
-    }
-
-    public List<T> get(List<Id> idList) throws SharingRegistryException {
-        List<T> returnList = new ArrayList<>();
-        for(Id id : idList)
-            returnList.add(get(id));
-        return returnList;
-    }
-
-    public List<T> select(Map<String, String> filters, int offset, int limit) throws SharingRegistryException {
-        String queryString = getSelectQuery(filters);
-        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
-        List resultSet = JPAUtils.execute(entityManager -> entityManager.createQuery(queryString).setFirstResult(offset)
-                .setMaxResults(newLimit).getResultList());
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> gatewayList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
-        return gatewayList;
-    }
-
-    public List<T> select(String queryString, int offset, int limit) throws SharingRegistryException {
-        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
-        List resultSet = JPAUtils.execute(entityManager -> entityManager.createQuery(queryString).setFirstResult(offset)
-                .setMaxResults(newLimit).getResultList());
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> gatewayList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
-        return gatewayList;
-    }
-
-    private String getSelectQuery(Map<String, String> filters){
-        String query = "SELECT p from " + dbEntityGenericClass.getSimpleName() + " as p";
-        if(filters != null && filters.size() != 0){
-            query += " WHERE ";
-            for(String k : filters.keySet()){
-                query += "p." + k + " = '" + filters.get(k) + "' AND ";
-            }
-            query = query.substring(0, query.length()-5);
-        }
-
-        query += " ORDER BY p.createdTime DESC";
-
-        return query;
-    }
-}
\ No newline at end of file

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

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
deleted file mode 100644
index b7137d2..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
+++ /dev/null
@@ -1,86 +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.db.repositories;
-
-import org.apache.airavata.sharing.registry.db.entities.EntityEntity;
-import org.apache.airavata.sharing.registry.db.entities.SharingEntity;
-import org.apache.airavata.sharing.registry.db.utils.DBConstants;
-import org.apache.airavata.sharing.registry.models.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-
-public class EntityRepository extends AbstractRepository<Entity, EntityEntity, String> {
-    private final static Logger logger = LoggerFactory.getLogger(EntityRepository.class);
-
-    public EntityRepository() {
-        super(Entity.class, EntityEntity.class);
-    }
-
-    public List<Entity> getChildEntities(String parentId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.EntityTable.PARENT_ENTITY_ID, parentId);
-        return select(filters, 0, -1);
-    }
-
-    public List<Entity> searchEntities(List<String> groupIds, String entityTypeId, List<SearchCriteria> filters,
-                                       int offset, int limit) throws SharingRegistryException {
-        String groupIdString = "'";
-        for(String groupId : groupIds)
-            groupIdString += groupId + "','";
-        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
-
-        String query = "SELECT E FROM " + EntityEntity.class.getSimpleName() + " E, " + SharingEntity.class.getSimpleName() + " S WHERE " +
-                "E." + DBConstants.EntityTable.ENTITY_ID + " = S." + DBConstants.SharingTable.ENTITY_ID + " AND " +
-                "S." + DBConstants.SharingTable.GROUP_ID + " IN(" + groupIdString + ") AND E." + DBConstants.EntityTable.ENTITY_TYPE_ID + "='" +
-                entityTypeId + "' AND ";
-
-        for(SearchCriteria searchCriteria : filters){
-            if(searchCriteria.getSearchField().equals(EntitySearchField.NAME)){
-                query += "E." + DBConstants.EntityTable.NAME + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
-                query += "E." + DBConstants.EntityTable.DESCRIPTION + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
-                query += "E." + DBConstants.EntityTable.FULL_TEXT + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PRRENT_ENTITY_ID)){
-                query += "E." + DBConstants.EntityTable.PARENT_ENTITY_ID + " = '" + searchCriteria.getValue() + "' AND ";
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
-                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
-                    query += "E." + DBConstants.EntityTable.CREATED_TIME + " >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
-                }else{
-                    query += "E." + DBConstants.EntityTable.CREATED_TIME + " <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.UPDATED_TIME)){
-                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
-                    query += "E." + DBConstants.EntityTable.UPDATED_TIME + " >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
-                }else{
-                    query += "E." + DBConstants.EntityTable.UPDATED_TIME + " <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
-                }
-            }
-        }
-
-        query = query.substring(0, query.length() - 5);
-        return select(query, offset, limit);
-
-    }
-}
\ No newline at end of file

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

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
deleted file mode 100644
index 87d5d4c..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
+++ /dev/null
@@ -1,98 +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.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.SharingUserEntity;
-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 SharingRegistryException {
-        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 SharingRegistryException {
-        String queryString = "SELECT U FROM " + SharingUserEntity.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 SharingRegistryException {
-        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 SharingRegistryException {
-        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 SharingRegistryException {
-        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/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
deleted file mode 100644
index c5d683c..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
+++ /dev/null
@@ -1,52 +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.db.repositories;
-
-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.SharingRegistryException;
-import org.apache.airavata.sharing.registry.models.PermissionType;
-import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-
-public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, String> {
-    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class);
-
-    public PermissionTypeRepository() {
-        super(PermissionType.class, PermissionTypeEntity.class);
-    }
-
-    public String getGlobalPermissionTypeIdForDomain(String domainId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domainId);
-        filters.put(DBConstants.PermissionTypeTable.NAME, SharingRegistryServerHandler.GLOBAL_PERMISSION_NAME);
-        List<PermissionType> permissionTypeList = select(filters, 0, -1);
-        if(permissionTypeList.size() != 1){
-            throw new SharingRegistryException("GLOBAL Permission inconsistency. Found " + permissionTypeList.size()
-                    + " records with " + SharingRegistryServerHandler.GLOBAL_PERMISSION_NAME + " name");
-        }
-        return permissionTypeList.get(0).getPermissionTypeId();
-    }
-}
\ No newline at end of file


[3/6] airavata git commit: adding separate distribution

Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
new file mode 100644
index 0000000..de8abf4
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
@@ -0,0 +1,192 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.util.Map;
+
+@Entity
+@Table(name = "ENTITY", schema = "")
+public class EntityEntity {
+    private final static Logger logger = LoggerFactory.getLogger(EntityEntity.class);
+    private String entityId;
+    private String domainId;
+    private String entityTypeId;
+    private String ownerId;
+    private String parentEntityId;
+    private String name;
+    private String description;
+    private Map<String, String> metadata;
+    private String fullText;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "ENTITY_ID")
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Basic
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "ENTITY_TYPE_ID")
+    public String getEntityTypeId() {
+        return entityTypeId;
+    }
+
+    public void setEntityTypeId(String entityTypeId) {
+        this.entityTypeId = entityTypeId;
+    }
+
+    @Basic
+    @Column(name = "OWNER_ID")
+    public String getOwnerId() {
+        return ownerId;
+    }
+
+    public void setOwnerId(String ownerId) {
+        this.ownerId = ownerId;
+    }
+
+    @Basic
+    @Column(name = "PARENT_ENTITY_ID")
+    public String getParentEntityId() {
+        return parentEntityId;
+    }
+
+    public void setParentEntityId(String parentEntityId) {
+        this.parentEntityId = parentEntityId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @ElementCollection
+    @CollectionTable(
+            name="ENTITY_METADATA",
+            joinColumns=@JoinColumn(name="ENTITY_ID")
+    )
+    @MapKeyColumn(name="META_KEY")
+    @Column(name="META_VALUE")
+    public Map<String, String> getMetadata() {
+        return metadata;
+    }
+
+    public void setMetadata(Map<String, String> metadata) {
+        this.metadata = metadata;
+    }
+
+    @Lob
+    @Column(name = "FULL_TEXT")
+    public String getFullText() {
+        return fullText;
+    }
+
+    public void setFullText(String fullText) {
+        this.fullText = fullText;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EntityEntity that = (EntityEntity) o;
+
+        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
+        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
+        if (parentEntityId != null ? !parentEntityId.equals(that.parentEntityId) : that.parentEntityId != null) return false;
+        if (name != null ? !name.equals(that.name) : that.name != null) return false;
+        if (description != null ? !description.equals(that.description) : that.description != null) return false;
+        if (metadata.equals(that.metadata)) return false;
+        if (fullText != null ? !fullText.equals(that.fullText) : that.fullText != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+        if (ownerId != null ? !ownerId.equals(that.ownerId) : that.ownerId != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = entityId != null ? entityId.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        result = 31 * result + (description != null ? description.hashCode() : 0);
+        result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
+        result = 31 * result + (fullText != null ? fullText.hashCode() : 0);
+        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
+        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java
new file mode 100644
index 0000000..0b789ed
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "ENTITY_TYPE", schema = "")
+public class EntityTypeEntity {
+    private final static Logger logger = LoggerFactory.getLogger(EntityTypeEntity.class);
+    private String entityTypeId;
+    private String domainId;
+    private String name;
+    private String description;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "ENTITY_TYPE_ID")
+    public String getEntityTypeId() {
+        return entityTypeId;
+    }
+
+    public void setEntityTypeId(String entityTypeId) {
+        this.entityTypeId = entityTypeId;
+    }
+
+    @Basic
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EntityTypeEntity that = (EntityTypeEntity) o;
+
+        if (entityTypeId != null ? !entityTypeId.equals(that.entityTypeId) : that.entityTypeId != null) return false;
+        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
+        if (name != null ? !name.equals(that.name) : that.name != null) return false;
+        if (description != null ? !description.equals(that.description) : that.description != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = entityTypeId != null ? entityTypeId.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        result = 31 * result + (description != null ? description.hashCode() : 0);
+        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
+        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java
new file mode 100644
index 0000000..c62a52d
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "GROUP_MEMBERSHIP", schema = "")
+@IdClass(GroupMembershipEntityPK.class)
+public class GroupMembershipEntity {
+    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntity.class);
+    private String parentId;
+    private String childId;
+    private String childType;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "PARENT_ID")
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    @Id
+    @Column(name = "CHILD_ID")
+    public String getChildId() {
+        return childId;
+    }
+
+    public void setChildId(String childId) {
+        this.childId = childId;
+    }
+
+    @Basic
+    @Column(name = "CHILD_TYPE")
+    public String getChildType() {
+        return childType;
+    }
+
+    public void setChildType(String childType) {
+        this.childType = childType;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GroupMembershipEntity that = (GroupMembershipEntity) o;
+
+        if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false;
+        if (childId != null ? !childId.equals(that.childId) : that.childId != null) return false;
+        if (childType != null ? !childType.equals(that.childType) : that.childType != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = parentId != null ? parentId.hashCode() : 0;
+        result = 31 * result + (childId != null ? childId.hashCode() : 0);
+        result = 31 * result + (childType != null ? childType.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java
new file mode 100644
index 0000000..be3b1f9
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class GroupMembershipEntityPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntityPK.class);
+    private String parentId;
+    private String childId;
+
+    @Column(name = "PARENT_ID")
+    @Id
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    @Column(name = "CHILD_ID")
+    @Id
+    public String getChildId() {
+        return childId;
+    }
+
+    public void setChildId(String childId) {
+        this.childId = childId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GroupMembershipEntityPK that = (GroupMembershipEntityPK) o;
+
+        if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false;
+        if (childId != null ? !childId.equals(that.childId) : that.childId != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = parentId != null ? parentId.hashCode() : 0;
+        result = 31 * result + (childId != null ? childId.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java
new file mode 100644
index 0000000..c145cbe
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "PERMISSION_TYPE", schema = "")
+public class PermissionTypeEntity {
+    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeEntity.class);
+    private String permissionTypeId;
+    private String domainId;
+    private String name;
+    private String description;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "PERMISSION_TYPE_ID")
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Basic
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        PermissionTypeEntity that = (PermissionTypeEntity) o;
+
+        if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null)
+            return false;
+        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
+        if (name != null ? !name.equals(that.name) : that.name != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
+        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java
new file mode 100644
index 0000000..b4b74b0
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java
@@ -0,0 +1,136 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "SHARING", schema = "")
+@IdClass(SharingEntityPK.class)
+public class SharingEntity {
+    private final static Logger logger = LoggerFactory.getLogger(SharingEntity.class);
+    private String permissionTypeId;
+    private String entityId;
+    private String groupId;
+    private String sharingType;
+    private String inheritedParentId;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "PERMISSION_TYPE_ID")
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Id
+    @Column(name = "ENTITY_ID")
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Id
+    @Column(name = "GROUP_ID")
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+
+    @Id
+    @Column(name = "INHERITED_PARENT_ID")
+    public String getInheritedParentId() {
+        return inheritedParentId;
+    }
+
+    public void setInheritedParentId(String inheritedParentId) {
+        this.inheritedParentId = inheritedParentId;
+    }
+
+    @Basic
+    @Column(name = "SHARING_TYPE")
+    public String getSharingType() {
+        return sharingType;
+    }
+
+    public void setSharingType(String sharingType) {
+        this.sharingType = sharingType;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SharingEntity that = (SharingEntity) o;
+
+        if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null)
+            return false;
+        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
+        if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0;
+        result = 31 * result + (entityId != null ? entityId.hashCode() : 0);
+        result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java
new file mode 100644
index 0000000..da77a87
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class SharingEntityPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(SharingEntityPK.class);
+    private String permissionTypeId;
+    private String entityId;
+    private String groupId;
+    private String inheritedParentId;
+
+    @Column(name = "PERMISSION_TYPE_ID")
+    @Id
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Column(name = "ENTITY_ID")
+    @Id
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Column(name = "GROUP_ID")
+    @Id
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Column(name = "INHERITED_PARENT_ID")
+    @Id
+    public String getInheritedParentId() {
+        return inheritedParentId;
+    }
+
+    public void setInheritedParentId(String inheritedParentId) {
+        this.inheritedParentId = inheritedParentId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SharingEntityPK that = (SharingEntityPK) o;
+
+        if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null)
+            return false;
+        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
+        if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0;
+        result = 31 * result + (entityId != null ? entityId.hashCode() : 0);
+        result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java
new file mode 100644
index 0000000..0d17279
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.nio.ByteBuffer;
+
+@Entity
+@Table(name = "SHARING_USER", schema = "")
+public class SharingUserEntity {
+    private final static Logger logger = LoggerFactory.getLogger(SharingUserEntity.class);
+    private String userId;
+    private String domainId;
+    private String userName;
+    private String firstName;
+    private String lastName;
+    private ByteBuffer icon;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "USER_ID")
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    @Basic
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "USER_NAME")
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    @Basic
+    @Column(name = "FIRST_NAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Basic
+    @Column(name = "LAST_NAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    @Lob
+    @Column(name = "ICON")
+    public ByteBuffer getIcon() {
+        return icon;
+    }
+
+    public void setIcon(ByteBuffer icon) {
+        this.icon = icon;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SharingUserEntity that = (SharingUserEntity) o;
+
+        if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false;
+        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
+        if (userName != null ? !userName.equals(that.userName) : that.userName != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = userId != null ? userId.hashCode() : 0;
+        result = 31 * result + (userName != null ? userName.hashCode() : 0);
+        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
+        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java
new file mode 100644
index 0000000..10d901a
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java
@@ -0,0 +1,150 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "USER_GROUP", schema = "")
+public class UserGroupEntity {
+    private final static Logger logger = LoggerFactory.getLogger(UserGroupEntity.class);
+    private String groupId;
+    private String domainId;
+    private String name;
+    private String description;
+    private String ownerId;
+    private String groupType;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "GROUP_ID")
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Basic
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "OWNER_ID")
+    public String getOwnerId() {
+        return ownerId;
+    }
+
+    public void setOwnerId(String ownerId) {
+        this.ownerId = ownerId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "GROUP_TYPE")
+    public String getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(String type) {
+        this.groupType = type;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        UserGroupEntity that = (UserGroupEntity) o;
+
+        if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false;
+        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
+        if (ownerId != null ? !ownerId.equals(that.ownerId) : that.ownerId != null) return false;
+        if (name != null ? !name.equals(that.name) : that.name != null) return false;
+        if (description != null ? !description.equals(that.description) : that.description != null) return false;
+        if (groupType != null ? !groupType.equals(that.groupType) : that.groupType != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = groupId != null ? groupId.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        result = 31 * result + (description != null ? description.hashCode() : 0);
+        result = 31 * result + (groupType != null ? groupType.hashCode() : 0);
+        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
+        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
new file mode 100644
index 0000000..a53a6a2
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
@@ -0,0 +1,138 @@
+/*
+ *
+ * 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.utils.DBConstants;
+import org.apache.airavata.sharing.registry.db.utils.JPAUtils;
+import org.apache.airavata.sharing.registry.db.utils.ObjectMapperSingleton;
+import org.apache.airavata.sharing.registry.models.SharingRegistryException;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractRepository<T, E, Id> {
+    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
+
+    private Class<T> thriftGenericClass;
+    private Class<E> dbEntityGenericClass;
+
+    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass){
+        this.thriftGenericClass = thriftGenericClass;
+        this.dbEntityGenericClass = dbEntityGenericClass;
+    }
+
+    public T create(T t) throws SharingRegistryException {
+        return update(t);
+    }
+
+    public List<T> create(List<T> tList) throws SharingRegistryException {
+        return update(tList);
+    }
+
+    public  T update(T t) throws SharingRegistryException {
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        E entity = mapper.map(t, dbEntityGenericClass);
+        E persistedCopy = JPAUtils.execute(entityManager -> entityManager.merge(entity));
+        return mapper.map(persistedCopy, thriftGenericClass);
+    }
+
+    public  List<T> update(List<T> tList) throws SharingRegistryException {
+        List<T> returnList = new ArrayList<>();
+        for(T temp : tList)
+            returnList.add(update(temp));
+        return returnList;
+    }
+
+    public boolean delete(Id id) throws SharingRegistryException {
+        JPAUtils.execute(entityManager -> {
+            E entity = entityManager.find(dbEntityGenericClass, id);
+            entityManager.remove(entity);
+            return entity;
+        });
+        return true;
+    }
+
+    public boolean delete(List<Id> idList) throws SharingRegistryException {
+        for(Id id : idList)
+            delete(id);
+        return true;
+    }
+
+    public T get(Id id) throws SharingRegistryException {
+        E entity = JPAUtils.execute(entityManager -> entityManager
+                .find(dbEntityGenericClass, id));
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        if(entity == null)
+            return null;
+        return mapper.map(entity, thriftGenericClass);
+    }
+
+    public boolean isExists(Id id) throws SharingRegistryException {
+        return get(id) != null;
+    }
+
+    public List<T> get(List<Id> idList) throws SharingRegistryException {
+        List<T> returnList = new ArrayList<>();
+        for(Id id : idList)
+            returnList.add(get(id));
+        return returnList;
+    }
+
+    public List<T> select(Map<String, String> filters, int offset, int limit) throws SharingRegistryException {
+        String queryString = getSelectQuery(filters);
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+        List resultSet = JPAUtils.execute(entityManager -> entityManager.createQuery(queryString).setFirstResult(offset)
+                .setMaxResults(newLimit).getResultList());
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> gatewayList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+        return gatewayList;
+    }
+
+    public List<T> select(String queryString, int offset, int limit) throws SharingRegistryException {
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+        List resultSet = JPAUtils.execute(entityManager -> entityManager.createQuery(queryString).setFirstResult(offset)
+                .setMaxResults(newLimit).getResultList());
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> gatewayList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+        return gatewayList;
+    }
+
+    private String getSelectQuery(Map<String, String> filters){
+        String query = "SELECT p from " + dbEntityGenericClass.getSimpleName() + " as p";
+        if(filters != null && filters.size() != 0){
+            query += " WHERE ";
+            for(String k : filters.keySet()){
+                query += "p." + k + " = '" + filters.get(k) + "' AND ";
+            }
+            query = query.substring(0, query.length()-5);
+        }
+
+        query += " ORDER BY p.createdTime DESC";
+
+        return query;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/DomainRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/DomainRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/DomainRepository.java
new file mode 100644
index 0000000..8cd44ef
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/DomainRepository.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.DomainEntity;
+import org.apache.airavata.sharing.registry.models.Domain;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DomainRepository extends AbstractRepository<Domain, DomainEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+
+    public DomainRepository(){
+        super(Domain.class, DomainEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
new file mode 100644
index 0000000..b7137d2
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.EntityEntity;
+import org.apache.airavata.sharing.registry.db.entities.SharingEntity;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class EntityRepository extends AbstractRepository<Entity, EntityEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(EntityRepository.class);
+
+    public EntityRepository() {
+        super(Entity.class, EntityEntity.class);
+    }
+
+    public List<Entity> getChildEntities(String parentId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.EntityTable.PARENT_ENTITY_ID, parentId);
+        return select(filters, 0, -1);
+    }
+
+    public List<Entity> searchEntities(List<String> groupIds, String entityTypeId, List<SearchCriteria> filters,
+                                       int offset, int limit) throws SharingRegistryException {
+        String groupIdString = "'";
+        for(String groupId : groupIds)
+            groupIdString += groupId + "','";
+        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
+
+        String query = "SELECT E FROM " + EntityEntity.class.getSimpleName() + " E, " + SharingEntity.class.getSimpleName() + " S WHERE " +
+                "E." + DBConstants.EntityTable.ENTITY_ID + " = S." + DBConstants.SharingTable.ENTITY_ID + " AND " +
+                "S." + DBConstants.SharingTable.GROUP_ID + " IN(" + groupIdString + ") AND E." + DBConstants.EntityTable.ENTITY_TYPE_ID + "='" +
+                entityTypeId + "' AND ";
+
+        for(SearchCriteria searchCriteria : filters){
+            if(searchCriteria.getSearchField().equals(EntitySearchField.NAME)){
+                query += "E." + DBConstants.EntityTable.NAME + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
+                query += "E." + DBConstants.EntityTable.DESCRIPTION + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
+                query += "E." + DBConstants.EntityTable.FULL_TEXT + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PRRENT_ENTITY_ID)){
+                query += "E." + DBConstants.EntityTable.PARENT_ENTITY_ID + " = '" + searchCriteria.getValue() + "' AND ";
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
+                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
+                    query += "E." + DBConstants.EntityTable.CREATED_TIME + " >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+                }else{
+                    query += "E." + DBConstants.EntityTable.CREATED_TIME + " <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.UPDATED_TIME)){
+                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
+                    query += "E." + DBConstants.EntityTable.UPDATED_TIME + " >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+                }else{
+                    query += "E." + DBConstants.EntityTable.UPDATED_TIME + " <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+                }
+            }
+        }
+
+        query = query.substring(0, query.length() - 5);
+        return select(query, offset, limit);
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java
new file mode 100644
index 0000000..ed2a7e9
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.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.EntityTypeEntity;
+import org.apache.airavata.sharing.registry.models.EntityType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EntityTypeRepository extends AbstractRepository<EntityType, EntityTypeEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(EntityTypeRepository.class);
+
+    public EntityTypeRepository() {
+        super(EntityType.class, EntityTypeEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
new file mode 100644
index 0000000..87d5d4c
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/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.SharingUserEntity;
+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 SharingRegistryException {
+        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 SharingRegistryException {
+        String queryString = "SELECT U FROM " + SharingUserEntity.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 SharingRegistryException {
+        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 SharingRegistryException {
+        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 SharingRegistryException {
+        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/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
new file mode 100644
index 0000000..c5d683c
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.SharingRegistryException;
+import org.apache.airavata.sharing.registry.models.PermissionType;
+import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class);
+
+    public PermissionTypeRepository() {
+        super(PermissionType.class, PermissionTypeEntity.class);
+    }
+
+    public String getGlobalPermissionTypeIdForDomain(String domainId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domainId);
+        filters.put(DBConstants.PermissionTypeTable.NAME, SharingRegistryServerHandler.GLOBAL_PERMISSION_NAME);
+        List<PermissionType> permissionTypeList = select(filters, 0, -1);
+        if(permissionTypeList.size() != 1){
+            throw new SharingRegistryException("GLOBAL Permission inconsistency. Found " + permissionTypeList.size()
+                    + " records with " + SharingRegistryServerHandler.GLOBAL_PERMISSION_NAME + " name");
+        }
+        return permissionTypeList.get(0).getPermissionTypeId();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
new file mode 100644
index 0000000..9c30fa4
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.db.entities.SharingEntityPK;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.Sharing;
+import org.apache.airavata.sharing.registry.models.SharingRegistryException;
+import org.apache.airavata.sharing.registry.models.SharingType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingEntityPK> {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class);
+
+    public SharingRepository() {
+        super(Sharing.class, SharingEntity.class);
+    }
+
+    public List<Sharing> getIndirectSharedChildren(String parentId, String permissionTypeId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.SharingTable.INHERITED_PARENT_ID, parentId);
+        filters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
+        filters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
+
+        return select(filters, 0, -1);
+    }
+
+    public List<Sharing> getCascadingPermissionsForEntity(String entityId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
+        query += " WHERE ";
+        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
+        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " IN('" + SharingType.DIRECT_CASCADING.toString()
+                + "', '" + SharingType.INDIRECT_CASCADING + "') ";
+        query += " ORDER BY p.createdTime DESC";
+        return select(query, 0, -1);
+    }
+
+    public boolean hasAccess(String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException {
+        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
+        query += " WHERE ";
+        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
+        String permissionTypeIdString = "'";
+        for(String permissionId : permissionTypeIds)
+            permissionTypeIdString += permissionId + "','";
+        permissionTypeIdString = permissionTypeIdString.substring(0, permissionTypeIdString.length()-2);
+        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " IN(" + permissionTypeIdString + ") AND ";
+        String groupIdString = "'";
+        for(String groupId : groupIds)
+            groupIdString += groupId + "','";
+        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
+        query += "p." + DBConstants.SharingTable.GROUP_ID + " IN(" + groupIdString + ") ";
+        query += " ORDER BY p.createdTime DESC";
+        return select(query, 0, -1).size() > 0;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
new file mode 100644
index 0000000..ed49c94
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.db.entities.UserGroupEntity;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.GroupType;
+import org.apache.airavata.sharing.registry.models.SharingRegistryException;
+import org.apache.airavata.sharing.registry.models.UserGroup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class);
+
+    public UserGroupRepository() {
+        super(UserGroup.class, UserGroupEntity.class);
+    }
+
+    public List<UserGroup> getAccessibleGroups(String entityId, String permissionTypeId) throws SharingRegistryException {
+        String query = "SELECT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
+        query += " WHERE ";
+        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
+        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = '" + permissionTypeId + "' AND ";
+        query += "g." + DBConstants.UserGroupTable.GROUP_TYPE + " = '" + GroupType.MULTI_USER.toString() + "'";
+        query += " ORDER BY s.createdTime DESC";
+        return select(query, 0, -1);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
new file mode 100644
index 0000000..845c0b9
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.db.entities.SharingUserEntity;
+import org.apache.airavata.sharing.registry.db.utils.DBConstants;
+import org.apache.airavata.sharing.registry.models.SharingRegistryException;
+import org.apache.airavata.sharing.registry.models.User;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class UserRepository extends AbstractRepository<User, SharingUserEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(UserRepository.class);
+
+    public UserRepository() {
+        super(User.class, SharingUserEntity.class);
+    }
+
+
+    public List<User> getAccessibleUsers(String entityId, String permissionTypeId) throws SharingRegistryException {
+        String query = "SELECT u from " + SharingUserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
+        query += " WHERE ";
+        query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
+        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = '" + permissionTypeId + "'";
+        query += " ORDER BY s.createdTime DESC";
+        return select(query, 0, -1);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
new file mode 100644
index 0000000..ed8c9b3
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/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


[4/6] airavata git commit: adding separate distribution

Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
deleted file mode 100644
index 7f2eb32..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ /dev/null
@@ -1,613 +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.common.exception.ApplicationSettingsException;
-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.db.utils.JPAUtils;
-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 = "OWNER";
-
-    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() throws ApplicationSettingsException, TException {
-        JPAUtils.initializeDB();
-
-        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 SharingRegistryException, TException {
-        if(domainRepository.get(domain.domainId) != null)
-            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
-        domainRepository.delete(domainId);
-        return true;
-    }
-
-    @Override
-    public Domain getDomain(String domainId) throws SharingRegistryException, 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 SharingRegistryException, TException {
-        if(userRepository.get(user.userId) != null)
-            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
-        userRepository.delete(userId);
-        userGroupRepository.delete(userId);
-        return true;
-    }
-
-    @Override
-    public User getUser(String userId) throws SharingRegistryException, TException {
-        return userRepository.get(userId);
-    }
-
-    @Override
-    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException, 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 SharingRegistryException, TException {
-        if(userGroupRepository.get(group.groupId) != null)
-            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
-        userGroupRepository.delete(groupId);
-        return true;
-    }
-
-    @Override
-    public UserGroup getGroup(String groupId) throws SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, TException {
-        if(entityTypeRepository.get(entityType.entityTypeId) != null)
-            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
-        entityTypeRepository.delete(entityTypeId);
-        return true;
-    }
-
-    @Override
-    public EntityType getEntityType(String entityTypeId) throws SharingRegistryException, 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 SharingRegistryException, TException {
-        if(permissionTypeRepository.get(permissionType.permissionTypeId) != null)
-            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
-        permissionTypeRepository.delete(entityTypeId);
-        return true;
-    }
-
-    @Override
-    public PermissionType getPermissionType(String permissionTypeId) throws SharingRegistryException, TException {
-        return permissionTypeRepository.get(permissionTypeId);
-    }
-
-    @Override
-    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException, 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 SharingRegistryException, TException {
-        if(entityRepository.get(entity.entityId) != null)
-            throw new SharingRegistryException("There exist Entity with given Entity id");
-
-        if(!userRepository.isExists(entity.getOwnerId())){
-            User user = new User();
-            user.setUserId(entity.getOwnerId());
-            user.setDomainId(entity.domainId);
-            user.setUserName(user.userId.split("@")[0]);
-
-            createUser(user);
-        }
-
-        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.setSharingType(SharingType.DIRECT_CASCADING);
-        newSharing.setInheritedParentId(entity.entityId);
-        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.getCascadingPermissionsForEntity(entity.parentEntityId);
-            for(Sharing sharing : sharings){
-                newSharing = new Sharing();
-                newSharing.setPermissionTypeId(sharing.permissionTypeId);
-                newSharing.setEntityId(entity.entityId);
-                newSharing.setGroupId(sharing.groupId);
-                newSharing.setInheritedParentId(sharing.inheritedParentId);
-                newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
-                newSharing.setCreatedTime(System.currentTimeMillis());
-                newSharing.setUpdatedTime(System.currentTimeMillis());
-
-                sharingRepository.create(newSharing);
-            }
-        }
-
-        return entity.entityId;
-    }
-
-    @Override
-    public boolean updateEntity(Entity entity) throws SharingRegistryException, 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 SharingRegistryException, TException {
-        //TODO Check for permission changes
-        entityRepository.delete(entityId);
-        return true;
-    }
-
-    @Override
-    public Entity getEntity(String entityId) throws SharingRegistryException, TException {
-        return entityRepository.get(entityId);
-    }
-
-    @Override
-    public List<Entity> searchEntities(String userId, String entityTypeId, List<SearchCriteria> filters,
-                                       int offset, int limit) throws SharingRegistryException, 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);
-    }
-
-    @Override
-    public List<User> getListOfSharedUsers(String entityId, String permissionTypeId) throws SharingRegistryException, TException {
-        return userRepository.getAccessibleUsers(entityId, permissionTypeId);
-    }
-
-    @Override
-    public List<UserGroup> getListOfSharedGroups(String entityId, String permissionTypeId) throws SharingRegistryException, TException {
-        return userGroupRepository.getAccessibleGroups(entityId, permissionTypeId);
-    }
-
-    /**
-     * * Sharing Entity with Users and Groups
-     * *
-     *
-     * @param entityId
-     * @param userList
-     * @param permissionType
-     */
-    @Override
-    public boolean shareEntityWithUsers(String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
-        return shareEntity(entityId, userList, permissionTypeId, GroupType.SINGLE_USER, cascadePermission);
-    }
-
-    @Override
-    public boolean shareEntityWithGroups(String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
-        return shareEntity(entityId, groupList, permissionTypeId, GroupType.MULTI_USER, cascadePermission);
-    }
-
-    private boolean shareEntity(String entityId, List<String> groupOrUserList, String permissionTypeId, GroupType groupType, boolean cascadePermission)  throws SharingRegistryException, 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.setInheritedParentId(entityId);
-            if(cascadePermission) {
-                sharing.setSharingType(SharingType.DIRECT_CASCADING);
-            }else {
-                sharing.setSharingType(SharingType.DIRECT_NON_CASCADING);
-            }
-            sharing.setCreatedTime(System.currentTimeMillis());
-            sharing.setUpdatedTime(System.currentTimeMillis());
-
-            sharingRepository.create(sharing);
-        }
-
-        if(cascadePermission){
-            //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;
-                for(String userId : groupOrUserList){
-                    Sharing sharing = new Sharing();
-                    sharing.setPermissionTypeId(permissionTypeId);
-                    sharing.setEntityId(childEntityId);
-                    sharing.setGroupId(userId);
-                    sharing.setInheritedParentId(entityId);
-                    sharing.setSharingType(SharingType.INDIRECT_CASCADING);
-                    sharing.setInheritedParentId(entityId);
-                    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 SharingRegistryException, TException {
-        return revokeEntitySharing(entityId, userList, permissionTypeId);
-    }
-
-
-    @Override
-    public boolean revokeEntitySharingFromGroups(String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException, TException {
-        return revokeEntitySharing(entityId, groupList, permissionTypeId);
-    }
-
-    @Override
-    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException, 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 SharingRegistryException {
-        //revoking permission for the entity
-        for(String groupId : groupOrUserList){
-            SharingEntityPK sharingEntityPK = new SharingEntityPK();
-            sharingEntityPK.setEntityId(entityId);
-            sharingEntityPK.setGroupId(groupId);
-            sharingEntityPK.setPermissionTypeId(permissionTypeId);
-            sharingEntityPK.setInheritedParentId(entityId);
-
-            sharingRepository.delete(sharingEntityPK);
-        }
-
-        //revoking permission from inheritance
-        List<Sharing> temp = new ArrayList<>();
-        sharingRepository.getIndirectSharedChildren(entityId, permissionTypeId).stream().forEach(s->temp.add(s));
-        for(Sharing sharing : temp){
-            String childEntityId = sharing.entityId;
-            for(String groupId : groupOrUserList){
-                SharingEntityPK sharingEntityPK = new SharingEntityPK();
-                sharingEntityPK.setEntityId(childEntityId);
-                sharingEntityPK.setGroupId(groupId);
-                sharingEntityPK.setPermissionTypeId(permissionTypeId);
-                sharingEntityPK.setInheritedParentId(entityId);
-
-                sharingRepository.delete(sharingEntityPK);
-            }
-        }
-        return true;
-    }
-
-
-
-    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws SharingRegistryException {
-        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 SharingRegistryException(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/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/resources/META-INF/persistence.xml b/modules/sharing-registry/sharing-registry-core/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index 7b08528..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
-
-    <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>
-        <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.SharingUserEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.UserGroupEntity</class>
-    </persistence-unit>
-</persistence>

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-derby.sql b/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-derby.sql
deleted file mode 100644
index 0e58356..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-derby.sql
+++ /dev/null
@@ -1,141 +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 SHARING_USER (
-  USER_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  USER_NAME VARCHAR(255) NOT NULL,
-  FIRST_NAME VARCHAR (255),
-  LAST_NAME VARCHAR (255),
-  ICON BLOB,
-  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 NO ACTION
-);
-
-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 NO ACTION,
-  FOREIGN KEY (OWNER_ID) REFERENCES SHARING_USER(USER_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-
-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 NO ACTION,
-  FOREIGN KEY (CHILD_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-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 NO ACTION
-);
-
-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 NO ACTION
-);
-
-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 CLOB,
-  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 NO ACTION,
-  FOREIGN KEY (ENTITY_TYPE_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (OWNER_ID) REFERENCES SHARING_USER(USER_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (PARENT_ENTITY_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
--- 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 NO ACTION
-);
-
-CREATE TABLE SHARING (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  GROUP_ID 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, INHERITED_PARENT_ID),
-  FOREIGN KEY (PERMISSION_TYPE_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (INHERITED_PARENT_ID) REFERENCES ENTITY(ENTITY_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (GROUP_ID) REFERENCES USER_GROUP(GROUP_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-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/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-mysql.sql b/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-mysql.sql
deleted file mode 100644
index 78d5d78..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/resources/sharing-registry-mysql.sql
+++ /dev/null
@@ -1,141 +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 SHARING_USER (
-  USER_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  USER_NAME VARCHAR(255) NOT NULL,
-  FIRST_NAME VARCHAR (255),
-  LAST_NAME VARCHAR (255),
-  ICON BLOB,
-  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 SHARING_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 SHARING_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,
-  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, INHERITED_PARENT_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/e36c145d/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java b/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
deleted file mode 100644
index cf92856..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
+++ /dev/null
@@ -1,290 +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;
-
-import junit.framework.Assert;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.sharing.registry.models.*;
-import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
-import org.apache.airavata.sharing.registry.util.Initialize;
-import org.apache.thrift.TException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-public class SharingRegistryServerHandlerTest {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandlerTest.class);
-
-    @BeforeClass
-    public static void setup() throws SharingRegistryException, SQLException {
-        Initialize initialize = new Initialize("sharing-registry-derby.sql");
-        initialize.initializeDB();
-    }
-
-    @Test
-    public void test() throws TException, ApplicationSettingsException {
-        SharingRegistryServerHandler sharingRegistryServerHandler = new SharingRegistryServerHandler();
-
-        //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());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createDomain(domain));
-        Assert.assertTrue(sharingRegistryServerHandler.getDomains(0, 10).size() > 0);
-
-
-        //Creating users
-        User user1 = new User();
-        String userName1 = "test-user-1." + System.currentTimeMillis();
-        String userId1 = domainId + ":" + userName1;
-        user1.setUserId(userId1);
-        user1.setUserName(userName1);
-        user1.setDomainId(domainId);
-        user1.setCreatedTime(System.currentTimeMillis());
-        user1.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user1));
-
-        User user2 = new User();
-        String userName2 = "test-user-2." + System.currentTimeMillis();
-        String userId2 = domainId + ":" + userName2;
-        user2.setUserId(userId2);
-        user2.setUserName(userName2);
-        user2.setDomainId(domainId);
-        user2.setCreatedTime(System.currentTimeMillis());
-        user2.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user2));
-
-        User user3 = new User();
-        String userName3 = "test-user-3." + System.currentTimeMillis();
-        String userId3 = domainId + ":" + userName3;
-        user3.setUserId(userId3);
-        user3.setUserName(userName3);
-        user3.setDomainId(domainId);
-        user3.setCreatedTime(System.currentTimeMillis());
-        user3.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user3));
-
-        Assert.assertTrue(sharingRegistryServerHandler.getUsers(domainId, 0, 10).size() > 0);
-
-        // Creating user groups
-        UserGroup userGroup1 = new UserGroup();
-        String groupName1 = "test-group-1." + System.currentTimeMillis();
-        String groupId1 = domainId + ":" + groupName1;
-        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());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup1));
-
-        UserGroup userGroup2 = new UserGroup();
-        String groupName2 = "test-group-2." + System.currentTimeMillis();
-        String groupId2 = domainId + ":" + groupName2;
-        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());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup2));
-
-        sharingRegistryServerHandler.addUsersToGroup(Arrays.asList(userId1), groupId1);
-        sharingRegistryServerHandler.addUsersToGroup(Arrays.asList(userId2, userId3), groupId2);
-        sharingRegistryServerHandler.addChildGroupToParentGroup(groupId2, groupId1);
-
-        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembers(groupId1, 0, 10).size() == 2);
-        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembers(groupId2, 0, 10).size() == 2);
-
-
-        //Creating permission types
-        PermissionType permissionType1 = new PermissionType();
-        String permissionName1 = "READ";
-        permissionType1.setPermissionTypeId(domainId+":"+permissionName1);
-        permissionType1.setDomainId(domainId);
-        permissionType1.setName(permissionName1);
-        permissionType1.setDescription("READ description");
-        permissionType1.setCreatedTime(System.currentTimeMillis());
-        permissionType1.setUpdatedTime(System.currentTimeMillis());
-        String permissionTypeId1 = sharingRegistryServerHandler.createPermissionType(permissionType1);
-        Assert.assertNotNull(permissionTypeId1);
-
-        PermissionType permissionType2 = new PermissionType();
-        String permissionName2 = "WRITE";
-        permissionType2.setPermissionTypeId(domainId+":"+permissionName2);
-        permissionType2.setDomainId(domainId);
-        permissionType2.setName(permissionName2);
-        permissionType2.setDescription("WRITE description");
-        permissionType2.setCreatedTime(System.currentTimeMillis());
-        permissionType2.setUpdatedTime(System.currentTimeMillis());
-        String permissionTypeId2 = sharingRegistryServerHandler.createPermissionType(permissionType2);
-        Assert.assertNotNull(permissionTypeId2);
-
-        //Creating entity types
-        EntityType entityType1 = new EntityType();
-        String entityType1Name = "Project";
-        entityType1.setEntityTypeId(domainId+":"+entityType1Name);
-        entityType1.setDomainId(domainId);
-        entityType1.setName(entityType1Name);
-        entityType1.setDescription("test entity type");
-        entityType1.setCreatedTime(System.currentTimeMillis());
-        entityType1.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId1 = sharingRegistryServerHandler.createEntityType(entityType1);
-        Assert.assertNotNull(entityTypeId1);
-
-        EntityType entityType2 = new EntityType();
-        String entityType2Name = "Experiment";
-        entityType2.setEntityTypeId(domainId+":"+entityType2Name);
-        entityType2.setDomainId(domainId);
-        entityType2.setName(entityType2Name);
-        entityType2.setDescription("test entity type");
-        entityType2.setCreatedTime(System.currentTimeMillis());
-        entityType2.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId2 = sharingRegistryServerHandler.createEntityType(entityType2);
-        Assert.assertNotNull(entityTypeId2);
-
-        EntityType entityType3 = new EntityType();
-        String entityType3Name = "FileInput";
-        entityType3.setEntityTypeId(domainId+":"+entityType3Name);
-        entityType3.setDomainId(domainId);
-        entityType3.setName(entityType3Name);
-        entityType3.setDescription("file input type");
-        entityType3.setCreatedTime(System.currentTimeMillis());
-        entityType3.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId3 = sharingRegistryServerHandler.createEntityType(entityType3);
-        Assert.assertNotNull(entityTypeId3);
-
-        //Creating Entities
-        Entity entity1 = new Entity();
-        entity1.setEntityId(domainId+":Entity1");
-        entity1.setDomainId(domainId);
-        entity1.setEntityTypeId(entityTypeId1);
-        entity1.setOwnerId(userId1);
-        entity1.setName("Project name 1");
-        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());
-
-        String entityId1 = sharingRegistryServerHandler.createEntity(entity1);
-        Assert.assertNotNull(entityId1);
-
-        Entity entity2 = new Entity();
-        entity2.setEntityId(domainId+":Entity2");
-        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());
-
-        String entityId2 = sharingRegistryServerHandler.createEntity(entity2);
-        Assert.assertNotNull(entityId2);
-
-        Entity entity3 = new Entity();
-        entity3.setEntityId(domainId+":Entity3");
-        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());
-
-        String entityId3 = sharingRegistryServerHandler.createEntity(entity3);
-        Assert.assertNotNull(entityId3);
-
-        sharingRegistryServerHandler.shareEntityWithUsers(entityId1, Arrays.asList(userId2), permissionTypeId1, true);
-        sharingRegistryServerHandler.shareEntityWithGroups(entityId3, Arrays.asList(groupId2), permissionTypeId1, true);
-
-        Entity entity4 = new Entity();
-        entity4.setEntityId(domainId+":Entity4");
-        entity4.setDomainId(domainId);
-        entity4.setEntityTypeId(entityTypeId3);
-        entity4.setOwnerId(userId3);
-        entity4.setName("Input name");
-        entity4.setDescription("Input file description");
-        entity4.setParentEntityId(entityId3);
-        metadataMap = new HashMap<>();
-        metadataMap.put("key", "val");
-        entity4.setMetadata(metadataMap);
-        entity4.setFullText("Input File");
-        entity4.setCreatedTime(System.currentTimeMillis());
-        entity4.setUpdatedTime(System.currentTimeMillis());
-
-        String entityId4 = sharingRegistryServerHandler.createEntity(entity4);
-        Assert.assertNotNull(entityId4);
-
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId4, permissionTypeId1));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId1, entityId4, permissionTypeId1));
-        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId1, permissionTypeId1));
-
-        ArrayList<SearchCriteria> filters = new ArrayList<>();
-        SearchCriteria searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.LIKE);
-        searchCriteria.setValue("Input");
-        searchCriteria.setSearchField(EntitySearchField.NAME);
-        filters.add(searchCriteria);
-        Assert.assertTrue(sharingRegistryServerHandler.searchEntities(userId1, entityTypeId3, filters, 0, -1).size() > 0);
-
-        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedUsers(entityId1, permissionTypeId1));
-        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedGroups(entityId1, permissionTypeId1));
-
-//        sharingRegistryServerHandler.revokeEntitySharingFromUsers(entityId1, Arrays.asList(userId2), permissionTypeId1);
-//        sharingRegistryServerHandler.revokeEntitySharingFromGroups(entityId3, Arrays.asList(groupId2), permissionTypeId1);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java b/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java
deleted file mode 100644
index 4a89094..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/util/Initialize.java
+++ /dev/null
@@ -1,298 +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.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.sharing.registry.db.utils.JPAUtils;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.*;
-import java.util.StringTokenizer;
-
-public class Initialize {
-    private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    public  String scriptName ;
-    private NetworkServerControl server;
-    private static final String delimiter = ";";
-    public static final String PERSISTANT_DATA = "Configuration";
-
-    public Initialize(String scriptName) {
-        this.scriptName = scriptName;
-    }
-
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-
-    private static boolean isServerStarted(NetworkServerControl server, int ntries)
-    {
-        for (int i = 1; i <= ntries; i ++)
-        {
-            try {
-                Thread.sleep(500);
-                server.ping();
-                return true;
-            }
-            catch (Exception e) {
-                if (i == ntries)
-                    return false;
-            }
-        }
-        return false;
-    }
-
-    public void initializeDB() throws SQLException{
-        String jdbcUrl = null;
-        String jdbcUser = null;
-        String jdbcPassword = null;
-        try{
-            jdbcUrl = ServerSettings.getSetting("sharingcatalog.jdbc.url");
-            jdbcUser = ServerSettings.getSetting("sharingcatalog.jdbc.user");
-            jdbcPassword = ServerSettings.getSetting("sharingcatalog.jdbc.password");
-            jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read properties", e);
-        }
-        startDerbyInServerMode();
-        if(!isServerStarted(server, 20)){
-           throw new RuntimeException("Derby server cound not started within five seconds...");
-        }
-
-        Connection conn = null;
-        try {
-            Class.forName(JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_DRIVER)).newInstance();
-            conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
-            if (!isDatabaseStructureCreated(PERSISTANT_DATA, conn)) {
-                executeSQLScript(conn);
-                logger.info("New Database created for Registry");
-            } else {
-                logger.debug("Database already created for Registry!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            try {
-                if (conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error(e.getMessage(), e);
-            }
-        }
-    }
-
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-            System.out.println("Running a query to test the database tables existence.");
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    private void executeSQLScript(Connection conn) throws Exception {
-        StringBuffer sql = new StringBuffer();
-        BufferedReader reader = null;
-        try{
-
-        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName);
-        reader = new BufferedReader(new InputStreamReader(inputStream));
-        String line;
-        while ((line = reader.readLine()) != null) {
-            line = line.trim();
-            if (line.startsWith("//")) {
-                continue;
-            }
-            if (line.startsWith("--")) {
-                continue;
-            }
-            StringTokenizer st = new StringTokenizer(line);
-            if (st.hasMoreTokens()) {
-                String token = st.nextToken();
-                if ("REM".equalsIgnoreCase(token)) {
-                    continue;
-                }
-            }
-            sql.append(" ").append(line);
-
-            // SQL defines "--" as a comment to EOL
-            // and in Oracle it may contain a hint
-            // so we cannot just remove it, instead we must end it
-            if (line.indexOf("--") >= 0) {
-                sql.append("\n");
-            }
-            if ((checkStringBufferEndsWith(sql, delimiter))) {
-                executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
-                sql.replace(0, sql.length(), "");
-            }
-        }
-        // Catch any statements not followed by ;
-        if (sql.length() > 0) {
-            executeSQL(sql.toString(), conn);
-        }
-        }catch (IOException e){
-            logger.error("Error occurred while executing SQL script for creating Airavata database", e);
-            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
-        }finally {
-            if (reader != null) {
-                reader.close();
-            }
-
-        }
-
-    }
-
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            logger.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            logger.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                logger.warn(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                logger.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    logger.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    private void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            String jdbcURL = JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_URL);
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            server = new NetworkServerControl(InetAddress.getByName(uri.getHost()),
-                    20000,
-                    JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_USER), JPAUtils.readServerProperties(JPAUtils.SHARING_REG_JDBC_USER));
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-
-    }
-
-    public void stopDerbyServer() throws SQLException{
-        try {
-            server.shutdown();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new SQLException("Error while stopping derby server", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-distribution/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-distribution/pom.xml b/modules/sharing-registry/sharing-registry-distribution/pom.xml
new file mode 100644
index 0000000..f818807
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-distribution/pom.xml
@@ -0,0 +1,91 @@
+<?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>
+        <version>${global.version}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>airavata-sharing-distribution</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-sharing-registry-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-server-configuration</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-commons</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.dozer</groupId>
+            <artifactId>dozer</artifactId>
+            <version>5.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa-all</artifactId>
+            <version>2.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.connector.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-sharing-registry-server</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-sharing-registry-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.3</version>
+                <executions>
+                    <execution>
+                        <id>distribution-package</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>src/main/assembly/bin-assembly.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-distribution/src/main/assembly/bin-assembly.xml b/modules/sharing-registry/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
new file mode 100644
index 0000000..b8fdfd4
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
@@ -0,0 +1,69 @@
+<!--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.
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
+          http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>bin</id>
+    <includeBaseDirectory>true</includeBaseDirectory>
+    <baseDirectory>sharing-registry</baseDirectory>
+    <formats>
+        <format>tar.gz</format>
+    </formats>
+
+    <fileSets>
+        <fileSet>
+            <directory>src/main/resources/bin</directory>
+            <outputDirectory>bin</outputDirectory>
+            <includes>
+                <include>*.sh</include>
+            </includes>
+            <fileMode>755</fileMode>
+        </fileSet>
+
+        <!-- ********************** copy airavata-server.properties ********************** -->
+        <fileSet>
+            <directory>../../configuration/server/src/main/resources/</directory>
+            <outputDirectory>bin</outputDirectory>
+            <includes>
+                <include>airavata-server.properties</include>
+            </includes>
+        </fileSet>
+
+        <!-- ********************** copy database scripts ********************** -->
+        <fileSet>
+            <directory>../sharing-registry-server/src/main/resources/
+            </directory>
+            <outputDirectory>bin/database_scripts
+            </outputDirectory>
+            <includes>
+                <include>*sql*</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <includes>
+                <include>*:jar:*</include>
+            </includes>
+        </dependencySet>
+    </dependencySets>
+</assembly>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/setenv.sh
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/setenv.sh b/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/setenv.sh
new file mode 100644
index 0000000..1dcf419
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/setenv.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# 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.
+
+# Get standard environment variables
+# if JAVA_HOME is not set we're not happy
+if [ -z "$JAVA_HOME" ]; then
+  echo "You must set the JAVA_HOME variable before running sharing-registry scripts."
+  exit 1
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false
+os400=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+OS400*) os400=true;;
+esac
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '.*/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+PRGDIR=`dirname "$PRG"`
+
+# Only set SHARING_REGISTRY_HOME if not already set
+[ -z "$SHARING_REGISTRY_HOME" ] && SHARING_REGISTRY_HOME=`cd "$PRGDIR/.." ; pwd`
+
+SHARING_REGISTRY_CLASSPATH=""
+
+
+
+for f in "SHARING_REGISTRY_HOME"/lib/*.jar
+do
+  SHARING_REGISTRY_CLASSPATH="$SHARING_REGISTRY_CLASSPATH":$f
+done
+
+SHARING_REGISTRY_CLASSPATH="$SHARING_REGISTRY_CLASSPATH":"$SHARING_REGISTRY_HOME"/conf/log4j.properties
+
+export SHARING_REGISTRY_HOME
+export SHARING_REGISTRY_CLASSPATH
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh b/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
new file mode 100644
index 0000000..10e0619
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# 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.
+
+. `dirname $0`/setenv.sh
+cd $SHARING_REGISTRY_HOME
+
+IS_DAEMON_MODE=false
+SHARING_REGISTRY_COMMAND=""
+STOP=false
+FORCE=false
+
+for var in "$@"
+do
+    case $var in
+	start)
+	    IS_DAEMON_MODE=true
+            shift
+        ;;
+	stop)
+	    STOP=true
+	    SHARING_REGISTRY_COMMAND="$
+	    SHARING_REGISTRY_COMMAND $var"
+            shift
+        ;;
+        -h)
+            echo "Usage: sharing-registry.sh [command-options]"
+            echo "command options:"
+	    echo "  start              Start server in daemon mode"
+	    echo "  stop               Stop server."
+	    echo "  -h                 Display this help and exit"
+	        shift
+            exit 0
+        ;;
+	*)
+	    SHARING_REGISTRY_COMMAND="$SHARING_REGISTRY_COMMAND $var"
+            shift
+    esac
+done
+
+if $STOP;
+then
+	for f in `find . -name "*-start_*"`; do
+		IFS='_' read -a f_split <<< "$f"
+		echo "Found process file : $f"
+		echo -n "    Sending kill signals to process ${f_split[1]}..."
+		out=`kill -9 ${f_split[1]} 2>&1`
+		if [ -z "$out" ]; then
+		    echo "done"
+		else
+		    echo "failed (REASON: $out)"
+		fi
+		echo -n "    Removing process file..."
+		out=`rm $f 2>&1`
+		if [ -z "$out" ]; then
+		    echo "done"
+		else
+		    echo "failed (REASON: $out)"
+		fi
+	done
+else
+	if $IS_DAEMON_MODE ; then
+		echo "Starting Sharing Catalog in daemon mode..."
+		cd "$SHARING_REGISTRY_HOME"/lib
+		nohup $JAVA_HOME/bin/java -jar "$SHARING_REGISTRY_HOME"/lib/airavata-sharing-registry-server-0.7-SNAPSHOT.jar > ../sharing-registry.out & echo $! > "../sharing-registry-start_$!"
+		cd ..
+	else
+        cd "$SHARING_REGISTRY_HOME"/lib
+		$JAVA_HOME/bin/java -jar "$SHARING_REGISTRY_HOME"/lib/airavata-sharing-registry-server-0.17-SNAPSHOT.jar
+		cd ..
+	fi
+fi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/pom.xml b/modules/sharing-registry/sharing-registry-server/pom.xml
new file mode 100644
index 0000000..730469b
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/pom.xml
@@ -0,0 +1,99 @@
+<?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-server</artifactId>
+    <packaging>jar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-sharing-registry-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-server-configuration</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-commons</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.dozer</groupId>
+            <artifactId>dozer</artifactId>
+            <version>5.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa-all</artifactId>
+            <version>2.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.connector.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.openjpa</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <version>2.2.0</version>
+                <configuration>
+                    <includes>**/entities/*.class</includes>
+                    <excludes>**/entities/XML*.class</excludes>
+                    <addDefaultConstructor>true</addDefaultConstructor>
+                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>enhancer</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.openjpa</groupId>
+                        <artifactId>openjpa</artifactId>
+                        <version>2.2.0</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java
new file mode 100644
index 0000000..48b5314
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/DomainEntity.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "DOMAIN", schema = "" )
+public class DomainEntity {
+    private final static Logger logger = LoggerFactory.getLogger(DomainEntity.class);
+    private String domainId;
+    private String name;
+    private String description;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        DomainEntity that = (DomainEntity) o;
+
+        if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false;
+        if (name != null ? !name.equals(that.name) : that.name != null) return false;
+        if (description != null ? !description.equals(that.description) : that.description != null) return false;
+        if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
+        if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = domainId != null ? domainId.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        result = 31 * result + (description != null ? description.hashCode() : 0);
+        result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
+        result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file


[5/6] airavata git commit: adding separate distribution

Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
deleted file mode 100644
index 9c30fa4..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
+++ /dev/null
@@ -1,80 +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.db.repositories;
-
-import org.apache.airavata.sharing.registry.db.entities.SharingEntity;
-import org.apache.airavata.sharing.registry.db.entities.SharingEntityPK;
-import org.apache.airavata.sharing.registry.db.utils.DBConstants;
-import org.apache.airavata.sharing.registry.models.Sharing;
-import org.apache.airavata.sharing.registry.models.SharingRegistryException;
-import org.apache.airavata.sharing.registry.models.SharingType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-
-public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingEntityPK> {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class);
-
-    public SharingRepository() {
-        super(Sharing.class, SharingEntity.class);
-    }
-
-    public List<Sharing> getIndirectSharedChildren(String parentId, String permissionTypeId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.SharingTable.INHERITED_PARENT_ID, parentId);
-        filters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
-        filters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
-
-        return select(filters, 0, -1);
-    }
-
-    public List<Sharing> getCascadingPermissionsForEntity(String entityId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
-        query += " WHERE ";
-        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
-        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " IN('" + SharingType.DIRECT_CASCADING.toString()
-                + "', '" + SharingType.INDIRECT_CASCADING + "') ";
-        query += " ORDER BY p.createdTime DESC";
-        return select(query, 0, -1);
-    }
-
-    public boolean hasAccess(String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException {
-        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
-        query += " WHERE ";
-        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
-        String permissionTypeIdString = "'";
-        for(String permissionId : permissionTypeIds)
-            permissionTypeIdString += permissionId + "','";
-        permissionTypeIdString = permissionTypeIdString.substring(0, permissionTypeIdString.length()-2);
-        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " IN(" + permissionTypeIdString + ") AND ";
-        String groupIdString = "'";
-        for(String groupId : groupIds)
-            groupIdString += groupId + "','";
-        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
-        query += "p." + DBConstants.SharingTable.GROUP_ID + " IN(" + groupIdString + ") ";
-        query += " ORDER BY p.createdTime DESC";
-        return select(query, 0, -1).size() > 0;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
deleted file mode 100644
index ed49c94..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
+++ /dev/null
@@ -1,51 +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.db.repositories;
-
-import org.apache.airavata.sharing.registry.db.entities.SharingEntity;
-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.GroupType;
-import org.apache.airavata.sharing.registry.models.SharingRegistryException;
-import org.apache.airavata.sharing.registry.models.UserGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, String> {
-    private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class);
-
-    public UserGroupRepository() {
-        super(UserGroup.class, UserGroupEntity.class);
-    }
-
-    public List<UserGroup> getAccessibleGroups(String entityId, String permissionTypeId) throws SharingRegistryException {
-        String query = "SELECT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
-        query += " WHERE ";
-        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
-        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = '" + permissionTypeId + "' AND ";
-        query += "g." + DBConstants.UserGroupTable.GROUP_TYPE + " = '" + GroupType.MULTI_USER.toString() + "'";
-        query += " ORDER BY s.createdTime DESC";
-        return select(query, 0, -1);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
deleted file mode 100644
index 845c0b9..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
+++ /dev/null
@@ -1,51 +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.db.repositories;
-
-
-import org.apache.airavata.sharing.registry.db.entities.SharingEntity;
-import org.apache.airavata.sharing.registry.db.entities.SharingUserEntity;
-import org.apache.airavata.sharing.registry.db.utils.DBConstants;
-import org.apache.airavata.sharing.registry.models.SharingRegistryException;
-import org.apache.airavata.sharing.registry.models.User;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class UserRepository extends AbstractRepository<User, SharingUserEntity, String> {
-    private final static Logger logger = LoggerFactory.getLogger(UserRepository.class);
-
-    public UserRepository() {
-        super(User.class, SharingUserEntity.class);
-    }
-
-
-    public List<User> getAccessibleUsers(String entityId, String permissionTypeId) throws SharingRegistryException {
-        String query = "SELECT u from " + SharingUserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
-        query += " WHERE ";
-        query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
-        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = '" + permissionTypeId + "'";
-        query += " ORDER BY s.createdTime DESC";
-        return select(query, 0, -1);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
deleted file mode 100644
index ed8c9b3..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/Committer.java
+++ /dev/null
@@ -1,27 +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.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/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java
deleted file mode 100644
index 02484f7..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java
+++ /dev/null
@@ -1,382 +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.db.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Stack;
-import java.util.concurrent.Semaphore;
-
-
-/**
- * A class for preallocating, recycling, and managing JDBC connections.
- */
-public class ConnectionPool {
-    private static final Logger logger = LoggerFactory.getLogger(ConnectionPool.class);
-
-    private long MAX_IDLE_TIME = 5 * 60 * 1000; // 5 minutes
-
-    private String driver;
-    private String url;
-    private String username;
-    private String password;
-    private String jdbcUrl;
-
-    private int maxConnections;
-
-    private boolean autoCommit = true;
-    private boolean waitIfBusy;
-
-    private Semaphore needConnection = new Semaphore(0);
-    private boolean stop;
-
-    private Stack<Connection> availableConnections;
-    private Stack<Connection> busyConnections;
-
-    private HashMap<Connection, Long> lastAccessTimeRecord = new HashMap<Connection, Long>();
-
-    private String urlType = "";
-
-    private DataSource datasource;
-
-    private int transactionIsolation = Connection.TRANSACTION_NONE;
-
-    private Thread clenupThread;
-    private Thread producerThread;
-
-    public ConnectionPool(String driver, String url, String username, String password, int initialConnections,
-                          int maxConnections, boolean waitIfBusy) throws SQLException {
-        this.driver = driver;
-        this.url = url;
-        this.username = username;
-        this.password = password;
-        this.urlType = "speratedURL";
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections,
-                          boolean waitIfBusy, boolean autoCommit, int transactionIsolation) throws SQLException {
-        this.driver = driver;
-        this.jdbcUrl = jdbcUrl;
-        this.urlType = "simpleURL";
-        this.autoCommit = autoCommit;
-        this.transactionIsolation = transactionIsolation;
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections, boolean waitIfBusy)
-            throws SQLException {
-        this.driver = driver;
-        this.jdbcUrl = jdbcUrl;
-        this.urlType = "simpleURL";
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    public ConnectionPool(DataSource dataSource, int initialConnections, int maxConnections, boolean waitIfBusy)
-            throws SQLException {
-        this.urlType = "dataSource";
-        this.datasource = dataSource;
-        initialize(initialConnections, maxConnections, waitIfBusy);
-    }
-
-    /**
-     * Check if this connection pool is auto commit or not
-     *
-     * @return
-     */
-    public boolean isAutoCommit() {
-        return this.autoCommit;
-    }
-
-    private void initialize(int initialConnections, int maxConnections, boolean waitIfBusy) throws SQLException {
-        this.maxConnections = maxConnections;
-        this.waitIfBusy = waitIfBusy;
-
-        int sizeOfConnections = (initialConnections > maxConnections) ? maxConnections : initialConnections;
-
-        availableConnections = new Stack<Connection>();
-        busyConnections = new Stack<Connection>();
-
-        for (int i = 0; i < sizeOfConnections; i++) {
-            Connection con = makeNewConnection();
-            setTimeStamp(con);
-            availableConnections.push(con);
-
-        }
-
-        producerThread = new Thread(new FillUpThread());
-        producerThread.start();
-
-        clenupThread = new Thread(new CleanUpThread());
-        clenupThread.start();
-    }
-
-    public synchronized Connection getConnection() throws SQLException {
-        if (!availableConnections.isEmpty()) {
-            Connection existingConnection = availableConnections.pop();
-
-            // If connection on available list is closed (e.g.,
-            // it timed out), then remove it from available list
-            // and race for a connection again.
-            if (existingConnection.isClosed()) {
-                lastAccessTimeRecord.remove(existingConnection);
-                // notifyAll for fairness
-                notifyAll();
-            } else {
-                busyConnections.push(existingConnection);
-                setTimeStamp(existingConnection);
-                return existingConnection;
-            }
-        } else if (!waitIfBusy && busyConnections.size() >= maxConnections) {
-            // You reached maxConnections limit and waitIfBusy flag is false.
-            // Throw SQLException in such a case.
-            throw new SQLException("Connection limit reached");
-        } else {
-
-            if (busyConnections.size() < maxConnections) {
-                // available connection is empty, but total number of connection
-                // doesn't reach maxConnection. Request for more connection
-                needConnection.release();
-            }
-
-            try {
-                // wait for free connection
-                wait();
-            } catch (InterruptedException ie) {
-            }
-        }
-        // always race for connection forever
-        return getConnection();
-    }
-
-    // This explicitly makes a new connection. Called in
-    // the foreground when initializing the ConnectionPool,
-    // and called in the background when running.
-    private Connection makeNewConnection() throws SQLException {
-        try {
-            // Load database driver if not already loaded
-            Class.forName(driver);
-            Connection connection;
-            // Establish network connection to database
-            if (urlType.equals("speratedURL")) {
-                connection = DriverManager.getConnection(url, username, password);
-            } else if (urlType.equals("simpleURL")) {
-                connection = DriverManager.getConnection(jdbcUrl);
-            } else { // if(urlType.equals("dataSource")){
-                connection = datasource.getConnection();
-            }
-            connection.setTransactionIsolation(this.transactionIsolation);
-            connection.setAutoCommit(this.autoCommit);
-            return connection;
-        } catch (ClassNotFoundException cnfe) {
-            // Simplify try/catch blocks of people using this by
-            // throwing only one exception type.
-            throw new SQLException("Can't find class for driver: " + driver);
-        }
-    }
-
-    private synchronized void fillUpConnection(Connection conn) {
-        setTimeStamp(conn);
-        availableConnections.push(conn);
-
-        // notify all since new connection is created
-        notifyAll();
-    }
-
-    private void setTimeStamp(Connection connection) {
-        lastAccessTimeRecord.put(connection, System.currentTimeMillis());
-    }
-
-    // The database connection cannot be left idle for too long, otherwise TCP
-    // connection will be broken.
-    /**
-     * From http://forums.mysql.com/read.php?39,28450,57460#msg-57460 Okay, then it looks like wait_timeout on the
-     * server is killing your connection (it is set to 8 hours of idle time by default). Either set that value higher on
-     * your server, or configure your connection pool to not hold connections idle that long (I prefer the latter). Most
-     * folks I know that run MySQL with a connection pool in high-load production environments only let connections sit
-     * idle for a matter of minutes, since it only takes a few milliseconds to open a connection, and the longer one
-     * sits idle the more chance it will go "bad" because of a network hiccup or the MySQL server being restarted.
-     *
-     * @throws java.sql.SQLException
-     */
-    private boolean isConnectionStale(Connection connection) {
-        long currentTime = System.currentTimeMillis();
-        long lastAccess = lastAccessTimeRecord.get(connection);
-        if (currentTime - lastAccess > MAX_IDLE_TIME) {
-            return true;
-        } else
-            return false;
-    }
-
-    private synchronized void closeStaleConnections() {
-        // close idle connections
-        Iterator<Connection> iter = availableConnections.iterator();
-        while (iter.hasNext()) {
-            Connection existingConnection = iter.next();
-            if (isConnectionStale(existingConnection)) {
-                try {
-                    existingConnection.close();
-                    iter.remove();
-                } catch (SQLException sql) {
-                    logger.error(sql.getMessage(), sql);
-                }
-            }
-        }
-        // close busy connections that have been checked out for too long.
-        // This should not happen since this means program has bug for not
-        // releasing connections .
-        iter = busyConnections.iterator();
-        while (iter.hasNext()) {
-            Connection busyConnection = iter.next();
-            if (isConnectionStale(busyConnection)) {
-                try {
-                    busyConnection.close();
-                    iter.remove();
-                    logger.warn("****Connection has checked out too long. Forced release. Check the program for calling release connection [free(Connection) method]");
-                } catch (SQLException sql) {
-                    logger.error(sql.getMessage(), sql);
-                }
-            }
-        }
-    }
-
-    public synchronized void free(Connection connection) {
-        busyConnections.removeElement(connection);
-        availableConnections.addElement(connection);
-        // Wake up threads that are waiting for a connection
-        notifyAll();
-    }
-
-    /**
-     * Close all the connections. Use with caution: be sure no connections are in use before calling. Note that you are
-     * not <I>required</I> to call this when done with a ConnectionPool, since connections are guaranteed to be closed
-     * when garbage collected. But this method gives more control regarding when the connections are closed.
-     */
-    public synchronized void dispose() {
-        logger.info("Connection Pool Shutting down");
-
-        // stop clean up thread
-        this.stop = true;
-        this.clenupThread.interrupt();
-
-        // stop producer up thread
-        this.producerThread.interrupt();
-
-        // close all connection
-        closeConnections(availableConnections);
-        availableConnections = new Stack<Connection>();
-        closeConnections(busyConnections);
-        busyConnections = new Stack<Connection>();
-        lastAccessTimeRecord.clear();
-
-        logger.info("All connection is closed");
-
-        try {
-            this.clenupThread.join();
-            this.producerThread.join();
-        } catch (Exception e) {
-            logger.error("Cannot shutdown cleanup thread", e);
-        }
-
-        logger.info("Connection Pool Shutdown");
-    }
-
-    private void closeConnections(Stack<Connection> connections) {
-        while (!connections.isEmpty()) {
-            Connection connection = connections.pop();
-            try {
-                if (!connection.isClosed()) {
-                    connection.close();
-                }
-            } catch (SQLException sqle) {
-                // Ignore errors; garbage collect anyhow
-                logger.warn(sqle.getMessage());
-            }
-        }
-    }
-
-    public synchronized String toString() {
-        String info = "ConnectionPool(" + url + "," + username + ")" + ", available=" + availableConnections.size()
-                + ", busy=" + busyConnections.size() + ", max=" + maxConnections;
-        return (info);
-    }
-
-    class CleanUpThread implements Runnable {
-        public void run() {
-            while (!stop) {
-                try {
-                    Thread.sleep(MAX_IDLE_TIME);
-                    closeStaleConnections();
-                } catch (InterruptedException e) {
-                    logger.info("Clean up thread is interrupted to close");
-                }
-            }
-        }
-    }
-
-    class FillUpThread implements Runnable {
-        public void run() {
-            while (!stop) {
-                try {
-                    // block until get
-                    needConnection.acquire();
-
-                    Connection conn = makeNewConnection();
-                    fillUpConnection(conn);
-                } catch (SQLException e) {
-                    // cannot create connection (increase semaphore value back)
-                    needConnection.release();
-                    logger.error(e.getMessage(), e);
-                } catch (InterruptedException e) {
-                    logger.info("Fill up thread is interrupted to close");
-                    break;
-                }
-            }
-        }
-    }
-
-    public void shutdown() throws SQLException{
-        for (Connection c : availableConnections) {
-            try {
-                c.close();
-            } catch (SQLException e) {
-                logger.error("Error while closing the connection", e);
-                throw new SQLException("Error while closing the connection", e);
-            }
-        }
-
-        for (Connection c : busyConnections) {
-            try {
-                c.close();
-            } catch (SQLException e) {
-                logger.error("Error while closing the connection", e);
-                throw new SQLException("Error while closing the connection", e);
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
deleted file mode 100644
index 387e0e5..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
+++ /dev/null
@@ -1,101 +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.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 = 1000;
-
-    public static class DomainTable {
-        public static String DOMAIN_ID = "domainId";
-        public static String NAME = "name";
-        public static String DESCRIPTION = "description";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class UserTable {
-        public static String USER_ID = "userId";
-        public static String DOMAIN_ID = "domainId";
-        public static String USER_NAME = "userName";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    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 final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class GroupMembershipTable {
-        public static String PARENT_ID = "parentId";
-        public static String CHILD_ID = "childId";
-        public static String CHILD_TYPE = "childType";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class EntityTypeTable {
-        public static String ENTITY_TYPE_ID = "entityTypeId";
-        public static String DOMAIN_ID = "domainId";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class PermissionTypeTable {
-        public static String ENTITY_TYPE_ID = "permissionTypeId";
-        public static String DOMAIN_ID = "domainId";
-        public static String NAME = "name";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class EntityTable {
-        public static String ENTITY_ID = "entityId";
-        public static String PARENT_ENTITY_ID = "parentEntityId";
-        public static String ENTITY_TYPE_ID = "entityTypeId";
-        public static String NAME = "name";
-        public static String DESCRIPTION = "description";
-        public static String FULL_TEXT = "fullText";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class SharingTable {
-        public static String PERMISSION_TYPE_ID = "permissionTypeId";
-        public static String ENTITY_ID = "entityId";
-        public static String GROUP_ID = "groupId";
-        public static String INHERITED_PARENT_ID = "inheritedParentId";
-        public static final String SHARING_TYPE = "sharingType";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
deleted file mode 100644
index 5aa423c..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
+++ /dev/null
@@ -1,353 +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.db.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.*;
-import java.util.StringTokenizer;
-
-/**
- * This class creates the database tables required for airavata with default configuration this
- * class creates derby database in server mode. User can specify required database in appropriate
- * properties files.
- */
-public class DatabaseCreator {
-    private final static Logger logger = LoggerFactory.getLogger(DatabaseCreator.class);
-
-    public enum DatabaseType {
-        derby("(?i).*derby.*"), mysql("(?i).*mysql.*"), other("");
-
-        private String pattern;
-
-        private DatabaseType(String matchingPattern) {
-            this.pattern = matchingPattern;
-        }
-
-        public String getMatchingPattern() {
-            return this.pattern;
-        }
-    }
-
-    private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
-
-    private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
-    private static final String delimiter = ";";
-
-    /**
-     * Creates database
-     *
-     * @throws Exception
-     */
-    public static void createRegistryDatabase(String prefix, Connection conn) throws Exception {
-        createDatabase(prefix, conn);
-    }
-
-
-
-    /**
-     * Checks whether database tables are created by using select * on given table name
-     *
-     * @param tableName
-     *            Table which should be existed
-     * @return <code>true</core> if checkSQL is success, else <code>false</code> .
-     */
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-
-            log.debug("Running a query to test the database tables existence.");
-
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * executes given sql
-     *
-     * @param sql
-     * @throws Exception
-     */
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            log.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            log.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                log.info(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                log.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    log.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    /**
-     * computes relatational database type using database name
-     *
-     * @return DatabaseType
-     * @throws Exception
-     *
-     */
-    public static DatabaseType getDatabaseType(Connection conn) throws Exception {
-        try {
-            if (conn != null && (!conn.isClosed())) {
-                DatabaseMetaData metaData = conn.getMetaData();
-                String databaseProductName = metaData.getDatabaseProductName();
-                return checkType(databaseProductName);
-            }
-        } catch (SQLException e) {
-            String msg = "Failed to create Airavata database." + e.getMessage();
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        return DatabaseType.other;
-    }
-
-    /**
-     * Overloaded method with String input
-     *
-     * @return DatabaseType
-     * @throws Exception
-     *
-     */
-    public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
-        return checkType(dbUrl);
-    }
-
-    private static DatabaseType checkType(String text) throws Exception {
-        try {
-            if (text != null) {
-                for (DatabaseType type : supportedDatabase) {
-                    if (text.matches(type.getMatchingPattern()))
-                        return type;
-                }
-            }
-            String msg = "Unsupported database: " + text
-                    + ". Database will not be created automatically by the Airavata. "
-                    + "Please create the database using appropriate database scripts for " + "the database.";
-            throw new Exception(msg);
-
-        } catch (SQLException e) {
-            String msg = "Failed to create Airavatadatabase." + e.getMessage();
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-    }
-
-    /**
-     * Get scripts location which is prefix + "-" + databaseType + ".sql"
-     *
-     * @param prefix
-     * @param databaseType
-     * @return script location
-     */
-    private static String getScriptLocation(String prefix, DatabaseType databaseType) {
-        String scriptName = prefix + "-" + databaseType + ".sql";
-        log.debug("Loading database script from :" + scriptName);
-        return  scriptName;
-    }
-
-    private static void createDatabase(String prefix, Connection conn) throws Exception {
-        Statement statement = null;
-        try {
-            conn.setAutoCommit(false);
-            statement = conn.createStatement();
-            executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
-            conn.commit();
-            log.debug("Tables are created successfully.");
-        } catch (SQLException e) {
-            String msg = "Failed to create database tables for Airavata resource store. " + e.getMessage();
-            log.error(msg, e);
-            conn.rollback();
-            throw new Exception(msg, e);
-        } finally {
-            conn.setAutoCommit(true);
-            try {
-                if (statement != null) {
-                    statement.close();
-                }
-            } catch (SQLException e) {
-                log.error("Failed to close statement.", e);
-            }
-        }
-    }
-
-    private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
-        StringBuffer sql = new StringBuffer();
-        BufferedReader reader = null;
-
-        try {
-            InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
-            if(is == null) {
-                logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
-                DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
-                if(databaseType.equals(DatabaseType.derby)){
-                    is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-derby.sql");
-                }else if(databaseType.equals(DatabaseType.mysql)){
-                    is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-mysql.sql");
-                }
-            }
-            reader = new BufferedReader(new InputStreamReader(is));
-            String line;
-            while ((line = reader.readLine()) != null) {
-                line = line.trim();
-                if (line.startsWith("//")) {
-                    continue;
-                }
-                if (line.startsWith("--")) {
-                    continue;
-                }
-                StringTokenizer st = new StringTokenizer(line);
-                if (st.hasMoreTokens()) {
-                    String token = st.nextToken();
-                    if ("REM".equalsIgnoreCase(token)) {
-                        continue;
-                    }
-                }
-                sql.append(" ").append(line);
-
-                // SQL defines "--" as a comment to EOL
-                // and in Oracle it may contain a hint
-                // so we cannot just remove it, instead we must end it
-                if (line.indexOf("--") >= 0) {
-                    sql.append("\n");
-                }
-                if ((checkStringBufferEndsWith(sql, delimiter))) {
-                    executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
-                    sql.replace(0, sql.length(), "");
-                }
-            }
-            // Catch any statements not followed by ;
-            if (sql.length() > 0) {
-                executeSQL(sql.toString(), conn);
-            }
-        } catch (IOException e) {
-            log.error("Error occurred while executing SQL script for creating Airavata database", e);
-            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
-
-        } finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
-    }
-
-    /**
-     * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
-     * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
-     * massive memory allocation and copying. See
-     *
-     * @param buffer
-     *            the buffer to perform the check on
-     * @param suffix
-     *            the suffix
-     * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
-     *         sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
-     *         be <code>true</code> if the argument is the empty string.
-     */
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
deleted file mode 100644
index f879c15..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
+++ /dev/null
@@ -1,230 +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.db.utils;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.sharing.registry.models.SharingRegistryException;
-import org.apache.derby.drda.NetworkServerControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class JPAUtils {
-    private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
-
-    public static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
-    public static final String SHARING_REG_JDBC_DRIVER = "sharingcatalog.jdbc.driver";
-    public static final String SHARING_REG_JDBC_URL = "sharingcatalog.jdbc.url";
-    public static final String SHARING_REG_JDBC_USER = "sharingcatalog.jdbc.user";
-    public static final String SHARING_REG_JDBC_PWD = "sharingcatalog.jdbc.password";
-    public static final String SHARING_REG_VALIDATION_QUERY = "sharingcatalog.validationQuery";
-    public static final String JPA_CACHE_SIZE = "jpa.cache.size";
-    public static final String JPA_CACHE_ENABLED = "cache.enable";
-
-    public static final String CONFIGURATION = "CONFIGURATION";
-    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
-    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
-    private static NetworkServerControl server;
-    private static JdbcStorage db;
-    private static String jdbcURl;
-    private static String jdbcDriver;
-    private static String jdbcUser;
-    private static String jdbcPassword;
-
-
-    @PersistenceUnit(unitName = PERSISTENCE_UNIT_NAME)
-    protected static EntityManagerFactory factory;
-    @PersistenceContext(unitName = PERSISTENCE_UNIT_NAME)
-    private static EntityManager entityManager;
-
-    public static EntityManager getEntityManager() throws SharingRegistryException {
-        if (factory == null) {
-            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," +
-//                    "Url=jdbc:mysql://localhost:3306/airavata_sharing_catalog?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;
-    }
-
-    public static <R> R execute(Committer<EntityManager, R> committer) throws SharingRegistryException {
-        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();
-            }
-        }
-    }
-
-    public static void initializeDB() throws SharingRegistryException {
-        jdbcDriver = readServerProperties(SHARING_REG_JDBC_DRIVER);
-        jdbcURl = readServerProperties(SHARING_REG_JDBC_URL);
-        jdbcUser = readServerProperties(SHARING_REG_JDBC_USER);
-        jdbcPassword = readServerProperties(SHARING_REG_JDBC_PWD);
-        jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-
-        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
-            startDerbyInServerMode();
-        }
-        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
-
-        Connection conn = null;
-        try {
-            conn = db.connect();
-            if (!DatabaseCreator.isDatabaseStructureCreated(CONFIGURATION, conn)) {
-                DatabaseCreator.createRegistryDatabase("database_scripts/sharing-registry", conn);
-                logger.info("New Database created for Sharing Catalog !!! ");
-            } else {
-                logger.info("Database already created for Sharing Catalog !!!");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Database failure", e);
-        } finally {
-            db.closeConnection(conn);
-            try {
-                if(conn != null){
-                    if (!conn.getAutoCommit()) {
-                        conn.commit();
-                    }
-                    conn.close();
-                }
-            } catch (SQLException e) {
-                logger.error("Error while closing database connection...", e.getMessage(), e);
-            }
-        }
-    }
-
-    public static String getDBType(String jdbcUrl){
-        try{
-            String cleanURI = jdbcUrl.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        }  catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata server properties", e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static void startDerbyInServerMode() {
-        try {
-            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
-                    getPort(jdbcURl),
-                    jdbcUser, jdbcPassword);
-            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
-            server.start(consoleWriter);
-        } catch (IOException e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        } catch (Exception e) {
-            logger.error("Unable to start Apache derby in the server mode! Check whether " +
-                    "specified port is available");
-        }
-    }
-
-    public static void stopDerbyInServerMode() {
-        System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
-        if (server!=null){
-            try {
-                server.shutdown();
-            } catch (Exception e) {
-                logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
-            }
-        }
-    }
-
-    public static int getPort(String jdbcURL){
-        try{
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static String readServerProperties(String propertyName) throws SharingRegistryException {
-        try {
-            return ServerSettings.getSetting(propertyName);
-        } catch (ApplicationSettingsException e) {
-            logger.error("Unable to read airavata-server.properties...", e);
-            throw new SharingRegistryException("Unable to read airavata-server.properties...");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java
deleted file mode 100644
index 377c50b..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java
+++ /dev/null
@@ -1,175 +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.db.utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.*;
-
-public class JdbcStorage {
-    private static Logger log = LoggerFactory.getLogger(JdbcStorage.class);
-
-    private ConnectionPool connectionPool;
-
-    public JdbcStorage(String jdbcUrl, String jdbcDriver) {
-        // default init connection and max connection
-        this(3, 50, jdbcUrl, jdbcDriver, true);
-    }
-
-    public JdbcStorage(int initCon, int maxCon, String url, String driver, boolean enableTransactions) {
-        try {
-            if (enableTransactions) {
-                connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true, false,
-                        Connection.TRANSACTION_SERIALIZABLE);
-            } else {
-                connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true);
-            }
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to create database connection pool.", e);
-        }
-    }
-
-    /**
-     * Check if this connection pool is auto commit or not
-     *
-     * @return
-     */
-    public boolean isAutoCommit() {
-        return connectionPool.isAutoCommit();
-    }
-
-    public void commit(Connection conn) {
-        try {
-            if (conn != null && !conn.getAutoCommit()) {
-                conn.commit();
-            }
-        } catch (SQLException sqle) {
-            log.error("Cannot commit data", sqle);
-        }
-    }
-
-    public void commitAndFree(Connection conn) {
-        commit(conn);
-        closeConnection(conn);
-    }
-
-    public void rollback(Connection conn) {
-        try {
-            if (conn != null && !conn.getAutoCommit()) {
-                conn.rollback();
-            }
-        } catch (SQLException sqle) {
-            log.error("Cannot Rollback data", sqle);
-        }
-    }
-
-    public void rollbackAndFree(Connection conn) {
-        rollback(conn);
-        closeConnection(conn);
-    }
-
-    public Connection connect() {
-
-        Connection conn = null;
-        try {
-            conn = connectionPool.getConnection();
-        } catch (SQLException e) {
-            log.error(e.getMessage(), e);
-        }
-        return conn;
-    }
-
-    /**
-     * This method is provided so that you can have better control over the statement. For example: You can use
-     * stmt.setString to convert quotation mark automatically in an UPDATE statement
-     *
-     * NOTE: Statement is closed after execution
-     */
-    public int executeUpdateAndClose(PreparedStatement stmt) throws SQLException {
-        int rows = 0;
-        try {
-            rows = stmt.executeUpdate();
-            if (rows == 0) {
-                log.info("Problem: 0 rows affected by insert/update/delete statement.");
-            }
-        } finally {
-            stmt.close();
-        }
-        return rows;
-    }
-
-    public int countRow(String tableName, String columnName) throws SQLException {
-        String query = new String("SELECT COUNT(" + columnName + ") FROM " + tableName);
-        int count = -1;
-        Connection conn = null;
-        PreparedStatement stmt = null;
-        try {
-            conn = connectionPool.getConnection();
-            stmt = conn.prepareStatement(query);
-            ResultSet rs = stmt.executeQuery();
-            rs.next();
-            count = rs.getInt(1);
-            commit(conn);
-        } catch (SQLException sql) {
-            rollback(conn);
-            throw sql;
-        } finally {
-            try {
-                if (stmt != null && !stmt.isClosed()) {
-                    stmt.close();
-                }
-            } finally {
-                closeConnection(conn);
-            }
-        }
-        return count;
-    }
-
-    public void quietlyClose(Connection conn, Statement... stmts) {
-        if (stmts != null) {
-            for (Statement stmt : stmts) {
-                try {
-                    if (stmt != null && !stmt.isClosed()) {
-                        stmt.close();
-                    }
-                } catch (SQLException sql) {
-                    log.error(sql.getMessage(), sql);
-                }
-            }
-        }
-        closeConnection(conn);
-    }
-
-    public void closeConnection(Connection conn) {
-        if (conn != null) {
-            connectionPool.free(conn);
-        }
-    }
-
-    public void closeAllConnections() {
-        if (connectionPool != null)
-            connectionPool.dispose();
-    }
-
-    public void shutdown() throws SQLException {
-        connectionPool.shutdown();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
deleted file mode 100644
index de6bea9..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
+++ /dev/null
@@ -1,39 +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.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/e36c145d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
deleted file mode 100644
index 96fdb90..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.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 SharingRegistryServer {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServer.class);
-}
\ No newline at end of file


[2/6] airavata git commit: adding separate distribution

Posted by sc...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java
new file mode 100644
index 0000000..02484f7
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ConnectionPool.java
@@ -0,0 +1,382 @@
+/*
+ *
+ * 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;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Stack;
+import java.util.concurrent.Semaphore;
+
+
+/**
+ * A class for preallocating, recycling, and managing JDBC connections.
+ */
+public class ConnectionPool {
+    private static final Logger logger = LoggerFactory.getLogger(ConnectionPool.class);
+
+    private long MAX_IDLE_TIME = 5 * 60 * 1000; // 5 minutes
+
+    private String driver;
+    private String url;
+    private String username;
+    private String password;
+    private String jdbcUrl;
+
+    private int maxConnections;
+
+    private boolean autoCommit = true;
+    private boolean waitIfBusy;
+
+    private Semaphore needConnection = new Semaphore(0);
+    private boolean stop;
+
+    private Stack<Connection> availableConnections;
+    private Stack<Connection> busyConnections;
+
+    private HashMap<Connection, Long> lastAccessTimeRecord = new HashMap<Connection, Long>();
+
+    private String urlType = "";
+
+    private DataSource datasource;
+
+    private int transactionIsolation = Connection.TRANSACTION_NONE;
+
+    private Thread clenupThread;
+    private Thread producerThread;
+
+    public ConnectionPool(String driver, String url, String username, String password, int initialConnections,
+                          int maxConnections, boolean waitIfBusy) throws SQLException {
+        this.driver = driver;
+        this.url = url;
+        this.username = username;
+        this.password = password;
+        this.urlType = "speratedURL";
+        initialize(initialConnections, maxConnections, waitIfBusy);
+    }
+
+    public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections,
+                          boolean waitIfBusy, boolean autoCommit, int transactionIsolation) throws SQLException {
+        this.driver = driver;
+        this.jdbcUrl = jdbcUrl;
+        this.urlType = "simpleURL";
+        this.autoCommit = autoCommit;
+        this.transactionIsolation = transactionIsolation;
+        initialize(initialConnections, maxConnections, waitIfBusy);
+    }
+
+    public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections, boolean waitIfBusy)
+            throws SQLException {
+        this.driver = driver;
+        this.jdbcUrl = jdbcUrl;
+        this.urlType = "simpleURL";
+        initialize(initialConnections, maxConnections, waitIfBusy);
+    }
+
+    public ConnectionPool(DataSource dataSource, int initialConnections, int maxConnections, boolean waitIfBusy)
+            throws SQLException {
+        this.urlType = "dataSource";
+        this.datasource = dataSource;
+        initialize(initialConnections, maxConnections, waitIfBusy);
+    }
+
+    /**
+     * Check if this connection pool is auto commit or not
+     *
+     * @return
+     */
+    public boolean isAutoCommit() {
+        return this.autoCommit;
+    }
+
+    private void initialize(int initialConnections, int maxConnections, boolean waitIfBusy) throws SQLException {
+        this.maxConnections = maxConnections;
+        this.waitIfBusy = waitIfBusy;
+
+        int sizeOfConnections = (initialConnections > maxConnections) ? maxConnections : initialConnections;
+
+        availableConnections = new Stack<Connection>();
+        busyConnections = new Stack<Connection>();
+
+        for (int i = 0; i < sizeOfConnections; i++) {
+            Connection con = makeNewConnection();
+            setTimeStamp(con);
+            availableConnections.push(con);
+
+        }
+
+        producerThread = new Thread(new FillUpThread());
+        producerThread.start();
+
+        clenupThread = new Thread(new CleanUpThread());
+        clenupThread.start();
+    }
+
+    public synchronized Connection getConnection() throws SQLException {
+        if (!availableConnections.isEmpty()) {
+            Connection existingConnection = availableConnections.pop();
+
+            // If connection on available list is closed (e.g.,
+            // it timed out), then remove it from available list
+            // and race for a connection again.
+            if (existingConnection.isClosed()) {
+                lastAccessTimeRecord.remove(existingConnection);
+                // notifyAll for fairness
+                notifyAll();
+            } else {
+                busyConnections.push(existingConnection);
+                setTimeStamp(existingConnection);
+                return existingConnection;
+            }
+        } else if (!waitIfBusy && busyConnections.size() >= maxConnections) {
+            // You reached maxConnections limit and waitIfBusy flag is false.
+            // Throw SQLException in such a case.
+            throw new SQLException("Connection limit reached");
+        } else {
+
+            if (busyConnections.size() < maxConnections) {
+                // available connection is empty, but total number of connection
+                // doesn't reach maxConnection. Request for more connection
+                needConnection.release();
+            }
+
+            try {
+                // wait for free connection
+                wait();
+            } catch (InterruptedException ie) {
+            }
+        }
+        // always race for connection forever
+        return getConnection();
+    }
+
+    // This explicitly makes a new connection. Called in
+    // the foreground when initializing the ConnectionPool,
+    // and called in the background when running.
+    private Connection makeNewConnection() throws SQLException {
+        try {
+            // Load database driver if not already loaded
+            Class.forName(driver);
+            Connection connection;
+            // Establish network connection to database
+            if (urlType.equals("speratedURL")) {
+                connection = DriverManager.getConnection(url, username, password);
+            } else if (urlType.equals("simpleURL")) {
+                connection = DriverManager.getConnection(jdbcUrl);
+            } else { // if(urlType.equals("dataSource")){
+                connection = datasource.getConnection();
+            }
+            connection.setTransactionIsolation(this.transactionIsolation);
+            connection.setAutoCommit(this.autoCommit);
+            return connection;
+        } catch (ClassNotFoundException cnfe) {
+            // Simplify try/catch blocks of people using this by
+            // throwing only one exception type.
+            throw new SQLException("Can't find class for driver: " + driver);
+        }
+    }
+
+    private synchronized void fillUpConnection(Connection conn) {
+        setTimeStamp(conn);
+        availableConnections.push(conn);
+
+        // notify all since new connection is created
+        notifyAll();
+    }
+
+    private void setTimeStamp(Connection connection) {
+        lastAccessTimeRecord.put(connection, System.currentTimeMillis());
+    }
+
+    // The database connection cannot be left idle for too long, otherwise TCP
+    // connection will be broken.
+    /**
+     * From http://forums.mysql.com/read.php?39,28450,57460#msg-57460 Okay, then it looks like wait_timeout on the
+     * server is killing your connection (it is set to 8 hours of idle time by default). Either set that value higher on
+     * your server, or configure your connection pool to not hold connections idle that long (I prefer the latter). Most
+     * folks I know that run MySQL with a connection pool in high-load production environments only let connections sit
+     * idle for a matter of minutes, since it only takes a few milliseconds to open a connection, and the longer one
+     * sits idle the more chance it will go "bad" because of a network hiccup or the MySQL server being restarted.
+     *
+     * @throws java.sql.SQLException
+     */
+    private boolean isConnectionStale(Connection connection) {
+        long currentTime = System.currentTimeMillis();
+        long lastAccess = lastAccessTimeRecord.get(connection);
+        if (currentTime - lastAccess > MAX_IDLE_TIME) {
+            return true;
+        } else
+            return false;
+    }
+
+    private synchronized void closeStaleConnections() {
+        // close idle connections
+        Iterator<Connection> iter = availableConnections.iterator();
+        while (iter.hasNext()) {
+            Connection existingConnection = iter.next();
+            if (isConnectionStale(existingConnection)) {
+                try {
+                    existingConnection.close();
+                    iter.remove();
+                } catch (SQLException sql) {
+                    logger.error(sql.getMessage(), sql);
+                }
+            }
+        }
+        // close busy connections that have been checked out for too long.
+        // This should not happen since this means program has bug for not
+        // releasing connections .
+        iter = busyConnections.iterator();
+        while (iter.hasNext()) {
+            Connection busyConnection = iter.next();
+            if (isConnectionStale(busyConnection)) {
+                try {
+                    busyConnection.close();
+                    iter.remove();
+                    logger.warn("****Connection has checked out too long. Forced release. Check the program for calling release connection [free(Connection) method]");
+                } catch (SQLException sql) {
+                    logger.error(sql.getMessage(), sql);
+                }
+            }
+        }
+    }
+
+    public synchronized void free(Connection connection) {
+        busyConnections.removeElement(connection);
+        availableConnections.addElement(connection);
+        // Wake up threads that are waiting for a connection
+        notifyAll();
+    }
+
+    /**
+     * Close all the connections. Use with caution: be sure no connections are in use before calling. Note that you are
+     * not <I>required</I> to call this when done with a ConnectionPool, since connections are guaranteed to be closed
+     * when garbage collected. But this method gives more control regarding when the connections are closed.
+     */
+    public synchronized void dispose() {
+        logger.info("Connection Pool Shutting down");
+
+        // stop clean up thread
+        this.stop = true;
+        this.clenupThread.interrupt();
+
+        // stop producer up thread
+        this.producerThread.interrupt();
+
+        // close all connection
+        closeConnections(availableConnections);
+        availableConnections = new Stack<Connection>();
+        closeConnections(busyConnections);
+        busyConnections = new Stack<Connection>();
+        lastAccessTimeRecord.clear();
+
+        logger.info("All connection is closed");
+
+        try {
+            this.clenupThread.join();
+            this.producerThread.join();
+        } catch (Exception e) {
+            logger.error("Cannot shutdown cleanup thread", e);
+        }
+
+        logger.info("Connection Pool Shutdown");
+    }
+
+    private void closeConnections(Stack<Connection> connections) {
+        while (!connections.isEmpty()) {
+            Connection connection = connections.pop();
+            try {
+                if (!connection.isClosed()) {
+                    connection.close();
+                }
+            } catch (SQLException sqle) {
+                // Ignore errors; garbage collect anyhow
+                logger.warn(sqle.getMessage());
+            }
+        }
+    }
+
+    public synchronized String toString() {
+        String info = "ConnectionPool(" + url + "," + username + ")" + ", available=" + availableConnections.size()
+                + ", busy=" + busyConnections.size() + ", max=" + maxConnections;
+        return (info);
+    }
+
+    class CleanUpThread implements Runnable {
+        public void run() {
+            while (!stop) {
+                try {
+                    Thread.sleep(MAX_IDLE_TIME);
+                    closeStaleConnections();
+                } catch (InterruptedException e) {
+                    logger.info("Clean up thread is interrupted to close");
+                }
+            }
+        }
+    }
+
+    class FillUpThread implements Runnable {
+        public void run() {
+            while (!stop) {
+                try {
+                    // block until get
+                    needConnection.acquire();
+
+                    Connection conn = makeNewConnection();
+                    fillUpConnection(conn);
+                } catch (SQLException e) {
+                    // cannot create connection (increase semaphore value back)
+                    needConnection.release();
+                    logger.error(e.getMessage(), e);
+                } catch (InterruptedException e) {
+                    logger.info("Fill up thread is interrupted to close");
+                    break;
+                }
+            }
+        }
+    }
+
+    public void shutdown() throws SQLException{
+        for (Connection c : availableConnections) {
+            try {
+                c.close();
+            } catch (SQLException e) {
+                logger.error("Error while closing the connection", e);
+                throw new SQLException("Error while closing the connection", e);
+            }
+        }
+
+        for (Connection c : busyConnections) {
+            try {
+                c.close();
+            } catch (SQLException e) {
+                logger.error("Error while closing the connection", e);
+                throw new SQLException("Error while closing the connection", e);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
new file mode 100644
index 0000000..387e0e5
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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 = 1000;
+
+    public static class DomainTable {
+        public static String DOMAIN_ID = "domainId";
+        public static String NAME = "name";
+        public static String DESCRIPTION = "description";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class UserTable {
+        public static String USER_ID = "userId";
+        public static String DOMAIN_ID = "domainId";
+        public static String USER_NAME = "userName";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    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 final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class GroupMembershipTable {
+        public static String PARENT_ID = "parentId";
+        public static String CHILD_ID = "childId";
+        public static String CHILD_TYPE = "childType";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class EntityTypeTable {
+        public static String ENTITY_TYPE_ID = "entityTypeId";
+        public static String DOMAIN_ID = "domainId";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class PermissionTypeTable {
+        public static String ENTITY_TYPE_ID = "permissionTypeId";
+        public static String DOMAIN_ID = "domainId";
+        public static String NAME = "name";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class EntityTable {
+        public static String ENTITY_ID = "entityId";
+        public static String PARENT_ENTITY_ID = "parentEntityId";
+        public static String ENTITY_TYPE_ID = "entityTypeId";
+        public static String NAME = "name";
+        public static String DESCRIPTION = "description";
+        public static String FULL_TEXT = "fullText";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class SharingTable {
+        public static String PERMISSION_TYPE_ID = "permissionTypeId";
+        public static String ENTITY_ID = "entityId";
+        public static String GROUP_ID = "groupId";
+        public static String INHERITED_PARENT_ID = "inheritedParentId";
+        public static final String SHARING_TYPE = "sharingType";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
new file mode 100644
index 0000000..5aa423c
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.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.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.*;
+import java.util.StringTokenizer;
+
+/**
+ * This class creates the database tables required for airavata with default configuration this
+ * class creates derby database in server mode. User can specify required database in appropriate
+ * properties files.
+ */
+public class DatabaseCreator {
+    private final static Logger logger = LoggerFactory.getLogger(DatabaseCreator.class);
+
+    public enum DatabaseType {
+        derby("(?i).*derby.*"), mysql("(?i).*mysql.*"), other("");
+
+        private String pattern;
+
+        private DatabaseType(String matchingPattern) {
+            this.pattern = matchingPattern;
+        }
+
+        public String getMatchingPattern() {
+            return this.pattern;
+        }
+    }
+
+    private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
+
+    private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
+    private static final String delimiter = ";";
+
+    /**
+     * Creates database
+     *
+     * @throws Exception
+     */
+    public static void createRegistryDatabase(String prefix, Connection conn) throws Exception {
+        createDatabase(prefix, conn);
+    }
+
+
+
+    /**
+     * Checks whether database tables are created by using select * on given table name
+     *
+     * @param tableName
+     *            Table which should be existed
+     * @return <code>true</core> if checkSQL is success, else <code>false</code> .
+     */
+    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
+        try {
+
+            log.debug("Running a query to test the database tables existence.");
+
+            // check whether the tables are already created with a query
+            Statement statement = null;
+            try {
+                statement = conn.createStatement();
+                ResultSet rs = statement.executeQuery("select * from " + tableName);
+                if (rs != null) {
+                    rs.close();
+                }
+            } finally {
+                try {
+                    if (statement != null) {
+                        statement.close();
+                    }
+                } catch (SQLException e) {
+                    return false;
+                }
+            }
+        } catch (SQLException e) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * executes given sql
+     *
+     * @param sql
+     * @throws Exception
+     */
+    private static void executeSQL(String sql, Connection conn) throws Exception {
+        // Check and ignore empty statements
+        if ("".equals(sql.trim())) {
+            return;
+        }
+
+        Statement statement = null;
+        try {
+            log.debug("SQL : " + sql);
+
+            boolean ret;
+            int updateCount = 0, updateCountTotal = 0;
+            statement = conn.createStatement();
+            ret = statement.execute(sql);
+            updateCount = statement.getUpdateCount();
+            do {
+                if (!ret) {
+                    if (updateCount != -1) {
+                        updateCountTotal += updateCount;
+                    }
+                }
+                ret = statement.getMoreResults();
+                if (ret) {
+                    updateCount = statement.getUpdateCount();
+                }
+            } while (ret);
+
+            log.debug(sql + " : " + updateCountTotal + " rows affected");
+
+            SQLWarning warning = conn.getWarnings();
+            while (warning != null) {
+                log.info(warning + " sql warning");
+                warning = warning.getNextWarning();
+            }
+            conn.clearWarnings();
+        } catch (SQLException e) {
+            if (e.getSQLState().equals("X0Y32")) {
+                // eliminating the table already exception for the derby
+                // database
+                log.info("Table Already Exists", e);
+            } else {
+                throw new Exception("Error occurred while executing : " + sql, e);
+            }
+        } finally {
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (SQLException e) {
+                    log.error("Error occurred while closing result set.", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * computes relatational database type using database name
+     *
+     * @return DatabaseType
+     * @throws Exception
+     *
+     */
+    public static DatabaseType getDatabaseType(Connection conn) throws Exception {
+        try {
+            if (conn != null && (!conn.isClosed())) {
+                DatabaseMetaData metaData = conn.getMetaData();
+                String databaseProductName = metaData.getDatabaseProductName();
+                return checkType(databaseProductName);
+            }
+        } catch (SQLException e) {
+            String msg = "Failed to create Airavata database." + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        return DatabaseType.other;
+    }
+
+    /**
+     * Overloaded method with String input
+     *
+     * @return DatabaseType
+     * @throws Exception
+     *
+     */
+    public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
+        return checkType(dbUrl);
+    }
+
+    private static DatabaseType checkType(String text) throws Exception {
+        try {
+            if (text != null) {
+                for (DatabaseType type : supportedDatabase) {
+                    if (text.matches(type.getMatchingPattern()))
+                        return type;
+                }
+            }
+            String msg = "Unsupported database: " + text
+                    + ". Database will not be created automatically by the Airavata. "
+                    + "Please create the database using appropriate database scripts for " + "the database.";
+            throw new Exception(msg);
+
+        } catch (SQLException e) {
+            String msg = "Failed to create Airavatadatabase." + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+
+    /**
+     * Get scripts location which is prefix + "-" + databaseType + ".sql"
+     *
+     * @param prefix
+     * @param databaseType
+     * @return script location
+     */
+    private static String getScriptLocation(String prefix, DatabaseType databaseType) {
+        String scriptName = prefix + "-" + databaseType + ".sql";
+        log.debug("Loading database script from :" + scriptName);
+        return  scriptName;
+    }
+
+    private static void createDatabase(String prefix, Connection conn) throws Exception {
+        Statement statement = null;
+        try {
+            conn.setAutoCommit(false);
+            statement = conn.createStatement();
+            executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
+            conn.commit();
+            log.debug("Tables are created successfully.");
+        } catch (SQLException e) {
+            String msg = "Failed to create database tables for Airavata resource store. " + e.getMessage();
+            log.error(msg, e);
+            conn.rollback();
+            throw new Exception(msg, e);
+        } finally {
+            conn.setAutoCommit(true);
+            try {
+                if (statement != null) {
+                    statement.close();
+                }
+            } catch (SQLException e) {
+                log.error("Failed to close statement.", e);
+            }
+        }
+    }
+
+    private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
+        StringBuffer sql = new StringBuffer();
+        BufferedReader reader = null;
+
+        try {
+            InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
+            if(is == null) {
+                logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
+                DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
+                if(databaseType.equals(DatabaseType.derby)){
+                    is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-derby.sql");
+                }else if(databaseType.equals(DatabaseType.mysql)){
+                    is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-mysql.sql");
+                }
+            }
+            reader = new BufferedReader(new InputStreamReader(is));
+            String line;
+            while ((line = reader.readLine()) != null) {
+                line = line.trim();
+                if (line.startsWith("//")) {
+                    continue;
+                }
+                if (line.startsWith("--")) {
+                    continue;
+                }
+                StringTokenizer st = new StringTokenizer(line);
+                if (st.hasMoreTokens()) {
+                    String token = st.nextToken();
+                    if ("REM".equalsIgnoreCase(token)) {
+                        continue;
+                    }
+                }
+                sql.append(" ").append(line);
+
+                // SQL defines "--" as a comment to EOL
+                // and in Oracle it may contain a hint
+                // so we cannot just remove it, instead we must end it
+                if (line.indexOf("--") >= 0) {
+                    sql.append("\n");
+                }
+                if ((checkStringBufferEndsWith(sql, delimiter))) {
+                    executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
+                    sql.replace(0, sql.length(), "");
+                }
+            }
+            // Catch any statements not followed by ;
+            if (sql.length() > 0) {
+                executeSQL(sql.toString(), conn);
+            }
+        } catch (IOException e) {
+            log.error("Error occurred while executing SQL script for creating Airavata database", e);
+            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
+
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+        }
+    }
+
+    /**
+     * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
+     * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
+     * massive memory allocation and copying. See
+     *
+     * @param buffer
+     *            the buffer to perform the check on
+     * @param suffix
+     *            the suffix
+     * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
+     *         sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
+     *         be <code>true</code> if the argument is the empty string.
+     */
+    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
+        if (suffix.length() > buffer.length()) {
+            return false;
+        }
+        // this loop is done on purpose to avoid memory allocation performance
+        // problems on various JDKs
+        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
+        // implementation is ok though does allocation/copying
+        // StringBuffer.toString().endsWith() does massive memory
+        // allocation/copying on JDK 1.5
+        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
+        int endIndex = suffix.length() - 1;
+        int bufferIndex = buffer.length() - 1;
+        while (endIndex >= 0) {
+            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
+                return false;
+            }
+            bufferIndex--;
+            endIndex--;
+        }
+        return true;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
new file mode 100644
index 0000000..f879c15
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JPAUtils.java
@@ -0,0 +1,230 @@
+/*
+ *
+ * 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.SharingRegistryException;
+import org.apache.derby.drda.NetworkServerControl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.URI;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class JPAUtils {
+    private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
+
+    public static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
+    public static final String SHARING_REG_JDBC_DRIVER = "sharingcatalog.jdbc.driver";
+    public static final String SHARING_REG_JDBC_URL = "sharingcatalog.jdbc.url";
+    public static final String SHARING_REG_JDBC_USER = "sharingcatalog.jdbc.user";
+    public static final String SHARING_REG_JDBC_PWD = "sharingcatalog.jdbc.password";
+    public static final String SHARING_REG_VALIDATION_QUERY = "sharingcatalog.validationQuery";
+    public static final String JPA_CACHE_SIZE = "jpa.cache.size";
+    public static final String JPA_CACHE_ENABLED = "cache.enable";
+
+    public static final String CONFIGURATION = "CONFIGURATION";
+    public static final String START_DERBY_ENABLE = "start.derby.server.mode";
+    public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
+    private static NetworkServerControl server;
+    private static JdbcStorage db;
+    private static String jdbcURl;
+    private static String jdbcDriver;
+    private static String jdbcUser;
+    private static String jdbcPassword;
+
+
+    @PersistenceUnit(unitName = PERSISTENCE_UNIT_NAME)
+    protected static EntityManagerFactory factory;
+    @PersistenceContext(unitName = PERSISTENCE_UNIT_NAME)
+    private static EntityManager entityManager;
+
+    public static EntityManager getEntityManager() throws SharingRegistryException {
+        if (factory == null) {
+            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," +
+//                    "Url=jdbc:mysql://localhost:3306/airavata_sharing_catalog?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;
+    }
+
+    public static <R> R execute(Committer<EntityManager, R> committer) throws SharingRegistryException {
+        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();
+            }
+        }
+    }
+
+    public static void initializeDB() throws SharingRegistryException {
+        jdbcDriver = readServerProperties(SHARING_REG_JDBC_DRIVER);
+        jdbcURl = readServerProperties(SHARING_REG_JDBC_URL);
+        jdbcUser = readServerProperties(SHARING_REG_JDBC_USER);
+        jdbcPassword = readServerProperties(SHARING_REG_JDBC_PWD);
+        jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
+
+        if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
+            startDerbyInServerMode();
+        }
+        db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
+
+        Connection conn = null;
+        try {
+            conn = db.connect();
+            if (!DatabaseCreator.isDatabaseStructureCreated(CONFIGURATION, conn)) {
+                DatabaseCreator.createRegistryDatabase("database_scripts/sharing-registry", conn);
+                logger.info("New Database created for Sharing Catalog !!! ");
+            } else {
+                logger.info("Database already created for Sharing Catalog !!!");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RuntimeException("Database failure", e);
+        } finally {
+            db.closeConnection(conn);
+            try {
+                if(conn != null){
+                    if (!conn.getAutoCommit()) {
+                        conn.commit();
+                    }
+                    conn.close();
+                }
+            } catch (SQLException e) {
+                logger.error("Error while closing database connection...", e.getMessage(), e);
+            }
+        }
+    }
+
+    public static String getDBType(String jdbcUrl){
+        try{
+            String cleanURI = jdbcUrl.substring(5);
+            URI uri = URI.create(cleanURI);
+            return uri.getScheme();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return null;
+        }
+    }
+
+    public static boolean isDerbyStartEnabled(){
+        try {
+            String s = ServerSettings.getSetting(START_DERBY_ENABLE);
+            if("true".equals(s)){
+                return true;
+            }
+        }  catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata server properties", e.getMessage(), e);
+            return false;
+        }
+        return false;
+    }
+
+    public static void startDerbyInServerMode() {
+        try {
+            System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
+            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
+                    getPort(jdbcURl),
+                    jdbcUser, jdbcPassword);
+            java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
+            server.start(consoleWriter);
+        } catch (IOException e) {
+            logger.error("Unable to start Apache derby in the server mode! Check whether " +
+                    "specified port is available");
+        } catch (Exception e) {
+            logger.error("Unable to start Apache derby in the server mode! Check whether " +
+                    "specified port is available");
+        }
+    }
+
+    public static void stopDerbyInServerMode() {
+        System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "false");
+        if (server!=null){
+            try {
+                server.shutdown();
+            } catch (Exception e) {
+                logger.error("Error when stopping the derby server : "+e.getLocalizedMessage());
+            }
+        }
+    }
+
+    public static int getPort(String jdbcURL){
+        try{
+            String cleanURI = jdbcURL.substring(5);
+            URI uri = URI.create(cleanURI);
+            return uri.getPort();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return -1;
+        }
+    }
+
+    public static String readServerProperties(String propertyName) throws SharingRegistryException {
+        try {
+            return ServerSettings.getSetting(propertyName);
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server.properties...", e);
+            throw new SharingRegistryException("Unable to read airavata-server.properties...");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java
new file mode 100644
index 0000000..377c50b
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/JdbcStorage.java
@@ -0,0 +1,175 @@
+/*
+ *
+ * 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;
+
+import java.sql.*;
+
+public class JdbcStorage {
+    private static Logger log = LoggerFactory.getLogger(JdbcStorage.class);
+
+    private ConnectionPool connectionPool;
+
+    public JdbcStorage(String jdbcUrl, String jdbcDriver) {
+        // default init connection and max connection
+        this(3, 50, jdbcUrl, jdbcDriver, true);
+    }
+
+    public JdbcStorage(int initCon, int maxCon, String url, String driver, boolean enableTransactions) {
+        try {
+            if (enableTransactions) {
+                connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true, false,
+                        Connection.TRANSACTION_SERIALIZABLE);
+            } else {
+                connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to create database connection pool.", e);
+        }
+    }
+
+    /**
+     * Check if this connection pool is auto commit or not
+     *
+     * @return
+     */
+    public boolean isAutoCommit() {
+        return connectionPool.isAutoCommit();
+    }
+
+    public void commit(Connection conn) {
+        try {
+            if (conn != null && !conn.getAutoCommit()) {
+                conn.commit();
+            }
+        } catch (SQLException sqle) {
+            log.error("Cannot commit data", sqle);
+        }
+    }
+
+    public void commitAndFree(Connection conn) {
+        commit(conn);
+        closeConnection(conn);
+    }
+
+    public void rollback(Connection conn) {
+        try {
+            if (conn != null && !conn.getAutoCommit()) {
+                conn.rollback();
+            }
+        } catch (SQLException sqle) {
+            log.error("Cannot Rollback data", sqle);
+        }
+    }
+
+    public void rollbackAndFree(Connection conn) {
+        rollback(conn);
+        closeConnection(conn);
+    }
+
+    public Connection connect() {
+
+        Connection conn = null;
+        try {
+            conn = connectionPool.getConnection();
+        } catch (SQLException e) {
+            log.error(e.getMessage(), e);
+        }
+        return conn;
+    }
+
+    /**
+     * This method is provided so that you can have better control over the statement. For example: You can use
+     * stmt.setString to convert quotation mark automatically in an UPDATE statement
+     *
+     * NOTE: Statement is closed after execution
+     */
+    public int executeUpdateAndClose(PreparedStatement stmt) throws SQLException {
+        int rows = 0;
+        try {
+            rows = stmt.executeUpdate();
+            if (rows == 0) {
+                log.info("Problem: 0 rows affected by insert/update/delete statement.");
+            }
+        } finally {
+            stmt.close();
+        }
+        return rows;
+    }
+
+    public int countRow(String tableName, String columnName) throws SQLException {
+        String query = new String("SELECT COUNT(" + columnName + ") FROM " + tableName);
+        int count = -1;
+        Connection conn = null;
+        PreparedStatement stmt = null;
+        try {
+            conn = connectionPool.getConnection();
+            stmt = conn.prepareStatement(query);
+            ResultSet rs = stmt.executeQuery();
+            rs.next();
+            count = rs.getInt(1);
+            commit(conn);
+        } catch (SQLException sql) {
+            rollback(conn);
+            throw sql;
+        } finally {
+            try {
+                if (stmt != null && !stmt.isClosed()) {
+                    stmt.close();
+                }
+            } finally {
+                closeConnection(conn);
+            }
+        }
+        return count;
+    }
+
+    public void quietlyClose(Connection conn, Statement... stmts) {
+        if (stmts != null) {
+            for (Statement stmt : stmts) {
+                try {
+                    if (stmt != null && !stmt.isClosed()) {
+                        stmt.close();
+                    }
+                } catch (SQLException sql) {
+                    log.error(sql.getMessage(), sql);
+                }
+            }
+        }
+        closeConnection(conn);
+    }
+
+    public void closeConnection(Connection conn) {
+        if (conn != null) {
+            connectionPool.free(conn);
+        }
+    }
+
+    public void closeAllConnections() {
+        if (connectionPool != null)
+            connectionPool.dispose();
+    }
+
+    public void shutdown() throws SQLException {
+        connectionPool.shutdown();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/ObjectMapperSingleton.java
new file mode 100644
index 0000000..de6bea9
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/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/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServer.java
new file mode 100644
index 0000000..96fdb90
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/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/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
new file mode 100644
index 0000000..7f2eb32
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -0,0 +1,613 @@
+/*
+ *
+ * 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.common.exception.ApplicationSettingsException;
+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.db.utils.JPAUtils;
+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 = "OWNER";
+
+    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() throws ApplicationSettingsException, TException {
+        JPAUtils.initializeDB();
+
+        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 SharingRegistryException, TException {
+        if(domainRepository.get(domain.domainId) != null)
+            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
+        domainRepository.delete(domainId);
+        return true;
+    }
+
+    @Override
+    public Domain getDomain(String domainId) throws SharingRegistryException, 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 SharingRegistryException, TException {
+        if(userRepository.get(user.userId) != null)
+            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
+        userRepository.delete(userId);
+        userGroupRepository.delete(userId);
+        return true;
+    }
+
+    @Override
+    public User getUser(String userId) throws SharingRegistryException, TException {
+        return userRepository.get(userId);
+    }
+
+    @Override
+    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException, 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 SharingRegistryException, TException {
+        if(userGroupRepository.get(group.groupId) != null)
+            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
+        userGroupRepository.delete(groupId);
+        return true;
+    }
+
+    @Override
+    public UserGroup getGroup(String groupId) throws SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, 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 SharingRegistryException, TException {
+        if(entityTypeRepository.get(entityType.entityTypeId) != null)
+            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
+        entityTypeRepository.delete(entityTypeId);
+        return true;
+    }
+
+    @Override
+    public EntityType getEntityType(String entityTypeId) throws SharingRegistryException, 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 SharingRegistryException, TException {
+        if(permissionTypeRepository.get(permissionType.permissionTypeId) != null)
+            throw new SharingRegistryException("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 SharingRegistryException, 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 SharingRegistryException, TException {
+        permissionTypeRepository.delete(entityTypeId);
+        return true;
+    }
+
+    @Override
+    public PermissionType getPermissionType(String permissionTypeId) throws SharingRegistryException, TException {
+        return permissionTypeRepository.get(permissionTypeId);
+    }
+
+    @Override
+    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException, 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 SharingRegistryException, TException {
+        if(entityRepository.get(entity.entityId) != null)
+            throw new SharingRegistryException("There exist Entity with given Entity id");
+
+        if(!userRepository.isExists(entity.getOwnerId())){
+            User user = new User();
+            user.setUserId(entity.getOwnerId());
+            user.setDomainId(entity.domainId);
+            user.setUserName(user.userId.split("@")[0]);
+
+            createUser(user);
+        }
+
+        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.setSharingType(SharingType.DIRECT_CASCADING);
+        newSharing.setInheritedParentId(entity.entityId);
+        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.getCascadingPermissionsForEntity(entity.parentEntityId);
+            for(Sharing sharing : sharings){
+                newSharing = new Sharing();
+                newSharing.setPermissionTypeId(sharing.permissionTypeId);
+                newSharing.setEntityId(entity.entityId);
+                newSharing.setGroupId(sharing.groupId);
+                newSharing.setInheritedParentId(sharing.inheritedParentId);
+                newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
+                newSharing.setCreatedTime(System.currentTimeMillis());
+                newSharing.setUpdatedTime(System.currentTimeMillis());
+
+                sharingRepository.create(newSharing);
+            }
+        }
+
+        return entity.entityId;
+    }
+
+    @Override
+    public boolean updateEntity(Entity entity) throws SharingRegistryException, 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 SharingRegistryException, TException {
+        //TODO Check for permission changes
+        entityRepository.delete(entityId);
+        return true;
+    }
+
+    @Override
+    public Entity getEntity(String entityId) throws SharingRegistryException, TException {
+        return entityRepository.get(entityId);
+    }
+
+    @Override
+    public List<Entity> searchEntities(String userId, String entityTypeId, List<SearchCriteria> filters,
+                                       int offset, int limit) throws SharingRegistryException, 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);
+    }
+
+    @Override
+    public List<User> getListOfSharedUsers(String entityId, String permissionTypeId) throws SharingRegistryException, TException {
+        return userRepository.getAccessibleUsers(entityId, permissionTypeId);
+    }
+
+    @Override
+    public List<UserGroup> getListOfSharedGroups(String entityId, String permissionTypeId) throws SharingRegistryException, TException {
+        return userGroupRepository.getAccessibleGroups(entityId, permissionTypeId);
+    }
+
+    /**
+     * * Sharing Entity with Users and Groups
+     * *
+     *
+     * @param entityId
+     * @param userList
+     * @param permissionType
+     */
+    @Override
+    public boolean shareEntityWithUsers(String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
+        return shareEntity(entityId, userList, permissionTypeId, GroupType.SINGLE_USER, cascadePermission);
+    }
+
+    @Override
+    public boolean shareEntityWithGroups(String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
+        return shareEntity(entityId, groupList, permissionTypeId, GroupType.MULTI_USER, cascadePermission);
+    }
+
+    private boolean shareEntity(String entityId, List<String> groupOrUserList, String permissionTypeId, GroupType groupType, boolean cascadePermission)  throws SharingRegistryException, 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.setInheritedParentId(entityId);
+            if(cascadePermission) {
+                sharing.setSharingType(SharingType.DIRECT_CASCADING);
+            }else {
+                sharing.setSharingType(SharingType.DIRECT_NON_CASCADING);
+            }
+            sharing.setCreatedTime(System.currentTimeMillis());
+            sharing.setUpdatedTime(System.currentTimeMillis());
+
+            sharingRepository.create(sharing);
+        }
+
+        if(cascadePermission){
+            //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;
+                for(String userId : groupOrUserList){
+                    Sharing sharing = new Sharing();
+                    sharing.setPermissionTypeId(permissionTypeId);
+                    sharing.setEntityId(childEntityId);
+                    sharing.setGroupId(userId);
+                    sharing.setInheritedParentId(entityId);
+                    sharing.setSharingType(SharingType.INDIRECT_CASCADING);
+                    sharing.setInheritedParentId(entityId);
+                    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 SharingRegistryException, TException {
+        return revokeEntitySharing(entityId, userList, permissionTypeId);
+    }
+
+
+    @Override
+    public boolean revokeEntitySharingFromGroups(String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException, TException {
+        return revokeEntitySharing(entityId, groupList, permissionTypeId);
+    }
+
+    @Override
+    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException, 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 SharingRegistryException {
+        //revoking permission for the entity
+        for(String groupId : groupOrUserList){
+            SharingEntityPK sharingEntityPK = new SharingEntityPK();
+            sharingEntityPK.setEntityId(entityId);
+            sharingEntityPK.setGroupId(groupId);
+            sharingEntityPK.setPermissionTypeId(permissionTypeId);
+            sharingEntityPK.setInheritedParentId(entityId);
+
+            sharingRepository.delete(sharingEntityPK);
+        }
+
+        //revoking permission from inheritance
+        List<Sharing> temp = new ArrayList<>();
+        sharingRepository.getIndirectSharedChildren(entityId, permissionTypeId).stream().forEach(s->temp.add(s));
+        for(Sharing sharing : temp){
+            String childEntityId = sharing.entityId;
+            for(String groupId : groupOrUserList){
+                SharingEntityPK sharingEntityPK = new SharingEntityPK();
+                sharingEntityPK.setEntityId(childEntityId);
+                sharingEntityPK.setGroupId(groupId);
+                sharingEntityPK.setPermissionTypeId(permissionTypeId);
+                sharingEntityPK.setInheritedParentId(entityId);
+
+                sharingRepository.delete(sharingEntityPK);
+            }
+        }
+        return true;
+    }
+
+
+
+    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws SharingRegistryException {
+        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 SharingRegistryException(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/e36c145d/modules/sharing-registry/sharing-registry-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/META-INF/persistence.xml b/modules/sharing-registry/sharing-registry-server/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..7b08528
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-server/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-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>
+        <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.SharingUserEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.UserGroupEntity</class>
+    </persistence-unit>
+</persistence>