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:47 UTC
[4/6] airavata git commit: adding separate distribution
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