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/05 20:27:18 UTC
[1/2] airavata git commit: WIP
Repository: airavata
Updated Branches:
refs/heads/airavata-gov-registry ea28a402c -> 4ddfa10de
WIP
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/986f00f2
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/986f00f2
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/986f00f2
Branch: refs/heads/airavata-gov-registry
Commit: 986f00f27d0952677394e7e5f8e3210d6a551282
Parents: ea28a40
Author: scnakandala <su...@gmail.com>
Authored: Wed Oct 5 15:50:05 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Wed Oct 5 15:50:05 2016 -0400
----------------------------------------------------------------------
.../registry/db/entities/SharingEntity.java | 11 -
.../registry/db/entities/SharingEntityPK.java | 25 +-
.../server/SharingRegistryServerHandler.java | 25 +-
.../main/resources/sharing-registry-derby.sql | 3 +-
.../main/resources/sharing-registry-mysql.sql | 3 +-
.../registry/GovRegistryServerHandlerTest.java | 272 -------------------
.../SharingRegistryServerHandlerTest.java | 272 +++++++++++++++++++
.../sharing/registry/models/Sharing.java | 187 +++----------
.../thrift_models/sharing_models.thrift | 10 +-
pom.xml | 2 +-
10 files changed, 331 insertions(+), 479 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/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
index 077d7cf..bbb9614 100644
--- 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
@@ -33,7 +33,6 @@ public class SharingEntity {
private String permissionTypeId;
private String entityId;
private String groupId;
- private String groupType;
private String sharingType;
private String inheritedParentId;
private Long createdTime;
@@ -70,16 +69,6 @@ public class SharingEntity {
}
@Basic
- @Column(name = "GROUP_TYPE")
- public String getGroupType() {
- return groupType;
- }
-
- public void setGroupType(String groupType) {
- this.groupType = groupType;
- }
-
- @Basic
@Column(name = "SHARING_TYPE")
public String getSharingType() {
return sharingType;
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/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
index fe6ebaf..59de199 100644
--- 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
@@ -33,8 +33,7 @@ public class SharingEntityPK implements Serializable {
private String permissionTypeId;
private String entityId;
private String groupId;
- private Long createdTime;
- private Long updatedTime;
+ private String inheritedParentId;
@Column(name = "PERMISSION_TYPE_ID")
@Id
@@ -67,23 +66,13 @@ public class SharingEntityPK implements Serializable {
}
@Basic
- @Column(name = "CREATED_TIME")
- public Long getCreatedTime() {
- return createdTime;
+ @Column(name = "INHERITED_PARENT_ID")
+ public String getInheritedParentId() {
+ return inheritedParentId;
}
- 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;
+ public void setInheritedParentId(String inheritedParentId) {
+ this.inheritedParentId = inheritedParentId;
}
@Override
@@ -97,8 +86,6 @@ public class SharingEntityPK implements Serializable {
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;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
index 01ae934..b99a6df 100644
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -371,8 +371,8 @@ public class SharingRegistryServerHandler implements GovRegistryService.Iface{
newSharing.setPermissionTypeId(permissionTypeRepository.getGlobalPermissionTypeIdForDomain(entity.domainId));
newSharing.setEntityId(entity.entityId);
newSharing.setGroupId(entity.ownerId);
- newSharing.setGroupType(GroupType.SINGLE_USER);
newSharing.setSharingType(SharingType.DIRECT_CASCADING);
+ newSharing.setInheritedParentId(entity.entityId);
newSharing.setCreatedTime(System.currentTimeMillis());
newSharing.setUpdatedTime(System.currentTimeMillis());
@@ -386,7 +386,11 @@ public class SharingRegistryServerHandler implements GovRegistryService.Iface{
newSharing.setPermissionTypeId(sharing.permissionTypeId);
newSharing.setEntityId(entity.entityId);
newSharing.setGroupId(sharing.groupId);
- newSharing.setGroupType(sharing.groupType);
+ if(sharing.sharingType.equals(SharingType.DIRECT_CASCADING))
+ newSharing.setInheritedParentId(sharing.entityId);
+
+ else
+ newSharing.setInheritedParentId(sharing.inheritedParentId);
newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
newSharing.setCreatedTime(System.currentTimeMillis());
newSharing.setUpdatedTime(System.currentTimeMillis());
@@ -456,7 +460,7 @@ public class SharingRegistryServerHandler implements GovRegistryService.Iface{
sharing.setPermissionTypeId(permissionTypeId);
sharing.setEntityId(entityId);
sharing.setGroupId(userId);
- sharing.setGroupType(groupType);
+ sharing.setInheritedParentId(entityId);
if(cascadePermission) {
sharing.setSharingType(SharingType.DIRECT_CASCADING);
sharing.setCascadePermission(true);
@@ -476,15 +480,14 @@ public class SharingRegistryServerHandler implements GovRegistryService.Iface{
while(temp.size() > 0){
Entity entity = temp.pop();
String childEntityId = entity.entityId;
- String parentEntityId = entity.parentEntityId;
for(String userId : groupOrUserList){
Sharing sharing = new Sharing();
sharing.setPermissionTypeId(permissionTypeId);
sharing.setEntityId(childEntityId);
sharing.setGroupId(userId);
- sharing.setGroupType(groupType);
+ sharing.setInheritedParentId(entityId);
sharing.setSharingType(SharingType.INDIRECT_CASCADING);
- sharing.setInheritedParentId(parentEntityId);
+ sharing.setInheritedParentId(entityId);
sharing.setCascadePermission(true);
sharing.setCreatedTime(System.currentTimeMillis());
sharing.setUpdatedTime(System.currentTimeMillis());
@@ -520,27 +523,27 @@ public class SharingRegistryServerHandler implements GovRegistryService.Iface{
public boolean revokeEntitySharing(String entityId, List<String> groupOrUserList, String permissionTypeId) throws GovRegistryException {
//revoking permission for the entity
- LinkedList<Sharing> temp = new LinkedList<>();
- sharingRepository.getIndirectSharedChildren(entityId, permissionTypeId).stream().forEach(s->temp.addLast(s));
for(String groupId : groupOrUserList){
SharingEntityPK sharingEntityPK = new SharingEntityPK();
sharingEntityPK.setEntityId(entityId);
sharingEntityPK.setGroupId(groupId);
sharingEntityPK.setPermissionTypeId(permissionTypeId);
+ sharingEntityPK.setInheritedParentId(entityId);
sharingRepository.delete(sharingEntityPK);
}
//revoking permission from inheritance
- while(temp.size() > 0){
- Sharing sharing = temp.pop();
+ List<Sharing> temp = new ArrayList<>();
+ sharingRepository.getIndirectSharedChildren(entityId, permissionTypeId).stream().forEach(s->temp.add(s));
+ for(Sharing sharing : temp){
String childEntityId = sharing.entityId;
- sharingRepository.getIndirectSharedChildren(sharing.entityId, permissionTypeId).stream().forEach(s->temp.addLast(s));
for(String groupId : groupOrUserList){
SharingEntityPK sharingEntityPK = new SharingEntityPK();
sharingEntityPK.setEntityId(childEntityId);
sharingEntityPK.setGroupId(groupId);
sharingEntityPK.setPermissionTypeId(permissionTypeId);
+ sharingEntityPK.setInheritedParentId(entityId);
sharingRepository.delete(sharingEntityPK);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/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
index 4b046ce..a7bb905 100644
--- 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
@@ -118,12 +118,11 @@ CREATE TABLE SHARING (
PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
ENTITY_ID VARCHAR(255) NOT NULL,
GROUP_ID VARCHAR(255) NOT NULL,
- GROUP_TYPE VARCHAR(255) NOT NULL,
SHARING_TYPE VARCHAR(255) NOT NULL,
INHERITED_PARENT_ID VARCHAR(255),
CREATED_TIME BIGINT NOT NULL,
UPDATED_TIME BIGINT NOT NULL,
- PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID),
+ 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
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/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
index 4b046ce..a7bb905 100644
--- 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
@@ -118,12 +118,11 @@ CREATE TABLE SHARING (
PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
ENTITY_ID VARCHAR(255) NOT NULL,
GROUP_ID VARCHAR(255) NOT NULL,
- GROUP_TYPE VARCHAR(255) NOT NULL,
SHARING_TYPE VARCHAR(255) NOT NULL,
INHERITED_PARENT_ID VARCHAR(255),
CREATED_TIME BIGINT NOT NULL,
UPDATED_TIME BIGINT NOT NULL,
- PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID),
+ 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
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java b/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
deleted file mode 100644
index afef6b8..0000000
--- a/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/GovRegistryServerHandlerTest.java
+++ /dev/null
@@ -1,272 +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.sharing.registry.models.*;
-import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
-import org.apache.thrift.TException;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-public class GovRegistryServerHandlerTest {
- private final static Logger logger = LoggerFactory.getLogger(GovRegistryServerHandlerTest.class);
-
- @Test
- public void test() throws TException {
- SharingRegistryServerHandler govRegistryServerHandler = 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(govRegistryServerHandler.createDomain(domain));
- Assert.assertTrue(govRegistryServerHandler.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(govRegistryServerHandler.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(govRegistryServerHandler.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(govRegistryServerHandler.createUser(user3));
-
- Assert.assertTrue(govRegistryServerHandler.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(govRegistryServerHandler.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(govRegistryServerHandler.createGroup(userGroup2));
-
- govRegistryServerHandler.addUsersToGroup(Arrays.asList(userId1), groupId1);
- govRegistryServerHandler.addUsersToGroup(Arrays.asList(userId2, userId3), groupId2);
- govRegistryServerHandler.addChildGroupToParentGroup(groupId2, groupId1);
-
- Assert.assertTrue(govRegistryServerHandler.getGroupMembers(groupId1, 0, 10).size() == 2);
- Assert.assertTrue(govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.createEntity(entity3);
- Assert.assertNotNull(entityId3);
-
- govRegistryServerHandler.shareEntityWithUsers(entityId1, Arrays.asList(userId2), permissionTypeId1, true);
- govRegistryServerHandler.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 = govRegistryServerHandler.createEntity(entity4);
- Assert.assertNotNull(entityId4);
-
- Assert.assertTrue(govRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
- Assert.assertTrue(govRegistryServerHandler.userHasAccess(domainId, userId2, entityId4, permissionTypeId1));
- Assert.assertTrue(govRegistryServerHandler.userHasAccess(domainId, userId1, entityId4, permissionTypeId1));
- Assert.assertFalse(govRegistryServerHandler.userHasAccess(domainId, userId3, entityId1, permissionTypeId1));
-
- HashMap<EntitySearchFields, String> filters = new HashMap<>();
- filters.put(EntitySearchFields.NAME, "Input");
- Assert.assertTrue(govRegistryServerHandler.searchEntities(userId1, entityTypeId3, filters, 0, -1).size() > 0);
-
-// govRegistryServerHandler.revokeEntitySharingFromUsers(entityId1, Arrays.asList(userId2), permissionTypeId1);
-// govRegistryServerHandler.revokeEntitySharingFromGroups(entityId3, Arrays.asList(groupId2), permissionTypeId1);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/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
new file mode 100644
index 0000000..a25d151
--- /dev/null
+++ b/modules/sharing-registry/sharing-registry-core/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
@@ -0,0 +1,272 @@
+/*
+ *
+ * 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.sharing.registry.models.*;
+import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
+import org.apache.thrift.TException;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SharingRegistryServerHandlerTest {
+ private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandlerTest.class);
+
+ @Test
+ public void test() throws TException {
+ SharingRegistryServerHandler govRegistryServerHandler = 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(govRegistryServerHandler.createDomain(domain));
+ Assert.assertTrue(govRegistryServerHandler.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(govRegistryServerHandler.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(govRegistryServerHandler.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(govRegistryServerHandler.createUser(user3));
+
+ Assert.assertTrue(govRegistryServerHandler.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(govRegistryServerHandler.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(govRegistryServerHandler.createGroup(userGroup2));
+
+ govRegistryServerHandler.addUsersToGroup(Arrays.asList(userId1), groupId1);
+ govRegistryServerHandler.addUsersToGroup(Arrays.asList(userId2, userId3), groupId2);
+ govRegistryServerHandler.addChildGroupToParentGroup(groupId2, groupId1);
+
+ Assert.assertTrue(govRegistryServerHandler.getGroupMembers(groupId1, 0, 10).size() == 2);
+ Assert.assertTrue(govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.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 = govRegistryServerHandler.createEntity(entity3);
+ Assert.assertNotNull(entityId3);
+
+ govRegistryServerHandler.shareEntityWithUsers(entityId1, Arrays.asList(userId2), permissionTypeId1, true);
+ govRegistryServerHandler.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 = govRegistryServerHandler.createEntity(entity4);
+ Assert.assertNotNull(entityId4);
+
+ Assert.assertTrue(govRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
+ Assert.assertTrue(govRegistryServerHandler.userHasAccess(domainId, userId2, entityId4, permissionTypeId1));
+ Assert.assertTrue(govRegistryServerHandler.userHasAccess(domainId, userId1, entityId4, permissionTypeId1));
+ Assert.assertFalse(govRegistryServerHandler.userHasAccess(domainId, userId3, entityId1, permissionTypeId1));
+
+ HashMap<EntitySearchFields, String> filters = new HashMap<>();
+ filters.put(EntitySearchFields.NAME, "Input");
+ Assert.assertTrue(govRegistryServerHandler.searchEntities(userId1, entityTypeId3, filters, 0, -1).size() > 0);
+
+// govRegistryServerHandler.revokeEntitySharingFromUsers(entityId1, Arrays.asList(userId2), permissionTypeId1);
+// govRegistryServerHandler.revokeEntitySharingFromGroups(entityId3, Arrays.asList(groupId2), permissionTypeId1);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Sharing.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Sharing.java b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Sharing.java
index 3b3a709..4cfdc82 100644
--- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Sharing.java
+++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Sharing.java
@@ -41,12 +41,11 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
private static final org.apache.thrift.protocol.TField PERMISSION_TYPE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("permissionTypeId", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField ENTITY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("entityId", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField GROUP_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("groupId", org.apache.thrift.protocol.TType.STRING, (short)3);
- private static final org.apache.thrift.protocol.TField GROUP_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("groupType", org.apache.thrift.protocol.TType.I32, (short)4);
- private static final org.apache.thrift.protocol.TField SHARING_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("sharingType", org.apache.thrift.protocol.TType.I32, (short)5);
- private static final org.apache.thrift.protocol.TField INHERITED_PARENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("inheritedParentId", org.apache.thrift.protocol.TType.STRING, (short)6);
- private static final org.apache.thrift.protocol.TField CASCADE_PERMISSION_FIELD_DESC = new org.apache.thrift.protocol.TField("cascadePermission", org.apache.thrift.protocol.TType.BOOL, (short)7);
- private static final org.apache.thrift.protocol.TField CREATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createdTime", org.apache.thrift.protocol.TType.I64, (short)8);
- private static final org.apache.thrift.protocol.TField UPDATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedTime", org.apache.thrift.protocol.TType.I64, (short)9);
+ private static final org.apache.thrift.protocol.TField SHARING_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("sharingType", org.apache.thrift.protocol.TType.I32, (short)4);
+ private static final org.apache.thrift.protocol.TField INHERITED_PARENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("inheritedParentId", org.apache.thrift.protocol.TType.STRING, (short)5);
+ private static final org.apache.thrift.protocol.TField CASCADE_PERMISSION_FIELD_DESC = new org.apache.thrift.protocol.TField("cascadePermission", org.apache.thrift.protocol.TType.BOOL, (short)6);
+ private static final org.apache.thrift.protocol.TField CREATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createdTime", org.apache.thrift.protocol.TType.I64, (short)7);
+ private static final org.apache.thrift.protocol.TField UPDATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedTime", org.apache.thrift.protocol.TType.I64, (short)8);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -59,11 +58,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
public String groupId; // optional
/**
*
- * @see GroupType
- */
- public GroupType groupType; // optional
- /**
- *
* @see SharingType
*/
public SharingType sharingType; // optional
@@ -79,18 +73,13 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
GROUP_ID((short)3, "groupId"),
/**
*
- * @see GroupType
- */
- GROUP_TYPE((short)4, "groupType"),
- /**
- *
* @see SharingType
*/
- SHARING_TYPE((short)5, "sharingType"),
- INHERITED_PARENT_ID((short)6, "inheritedParentId"),
- CASCADE_PERMISSION((short)7, "cascadePermission"),
- CREATED_TIME((short)8, "createdTime"),
- UPDATED_TIME((short)9, "updatedTime");
+ SHARING_TYPE((short)4, "sharingType"),
+ INHERITED_PARENT_ID((short)5, "inheritedParentId"),
+ CASCADE_PERMISSION((short)6, "cascadePermission"),
+ CREATED_TIME((short)7, "createdTime"),
+ UPDATED_TIME((short)8, "updatedTime");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -111,17 +100,15 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
return ENTITY_ID;
case 3: // GROUP_ID
return GROUP_ID;
- case 4: // GROUP_TYPE
- return GROUP_TYPE;
- case 5: // SHARING_TYPE
+ case 4: // SHARING_TYPE
return SHARING_TYPE;
- case 6: // INHERITED_PARENT_ID
+ case 5: // INHERITED_PARENT_ID
return INHERITED_PARENT_ID;
- case 7: // CASCADE_PERMISSION
+ case 6: // CASCADE_PERMISSION
return CASCADE_PERMISSION;
- case 8: // CREATED_TIME
+ case 7: // CREATED_TIME
return CREATED_TIME;
- case 9: // UPDATED_TIME
+ case 8: // UPDATED_TIME
return UPDATED_TIME;
default:
return null;
@@ -167,7 +154,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
private static final int __CREATEDTIME_ISSET_ID = 1;
private static final int __UPDATEDTIME_ISSET_ID = 2;
private byte __isset_bitfield = 0;
- private static final _Fields optionals[] = {_Fields.PERMISSION_TYPE_ID,_Fields.ENTITY_ID,_Fields.GROUP_ID,_Fields.GROUP_TYPE,_Fields.SHARING_TYPE,_Fields.INHERITED_PARENT_ID,_Fields.CASCADE_PERMISSION,_Fields.CREATED_TIME,_Fields.UPDATED_TIME};
+ private static final _Fields optionals[] = {_Fields.PERMISSION_TYPE_ID,_Fields.ENTITY_ID,_Fields.GROUP_ID,_Fields.SHARING_TYPE,_Fields.INHERITED_PARENT_ID,_Fields.CASCADE_PERMISSION,_Fields.CREATED_TIME,_Fields.UPDATED_TIME};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -177,8 +164,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.GROUP_ID, new org.apache.thrift.meta_data.FieldMetaData("groupId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
- tmpMap.put(_Fields.GROUP_TYPE, new org.apache.thrift.meta_data.FieldMetaData("groupType", org.apache.thrift.TFieldRequirementType.OPTIONAL,
- new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, GroupType.class)));
tmpMap.put(_Fields.SHARING_TYPE, new org.apache.thrift.meta_data.FieldMetaData("sharingType", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, SharingType.class)));
tmpMap.put(_Fields.INHERITED_PARENT_ID, new org.apache.thrift.meta_data.FieldMetaData("inheritedParentId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
@@ -210,9 +195,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
if (other.isSetGroupId()) {
this.groupId = other.groupId;
}
- if (other.isSetGroupType()) {
- this.groupType = other.groupType;
- }
if (other.isSetSharingType()) {
this.sharingType = other.sharingType;
}
@@ -233,7 +215,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
this.permissionTypeId = null;
this.entityId = null;
this.groupId = null;
- this.groupType = null;
this.sharingType = null;
this.inheritedParentId = null;
setCascadePermissionIsSet(false);
@@ -318,38 +299,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
/**
*
- * @see GroupType
- */
- public GroupType getGroupType() {
- return this.groupType;
- }
-
- /**
- *
- * @see GroupType
- */
- public Sharing setGroupType(GroupType groupType) {
- this.groupType = groupType;
- return this;
- }
-
- public void unsetGroupType() {
- this.groupType = null;
- }
-
- /** Returns true if field groupType is set (has been assigned a value) and false otherwise */
- public boolean isSetGroupType() {
- return this.groupType != null;
- }
-
- public void setGroupTypeIsSet(boolean value) {
- if (!value) {
- this.groupType = null;
- }
- }
-
- /**
- *
* @see SharingType
*/
public SharingType getSharingType() {
@@ -499,14 +448,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
}
break;
- case GROUP_TYPE:
- if (value == null) {
- unsetGroupType();
- } else {
- setGroupType((GroupType)value);
- }
- break;
-
case SHARING_TYPE:
if (value == null) {
unsetSharingType();
@@ -561,9 +502,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
case GROUP_ID:
return getGroupId();
- case GROUP_TYPE:
- return getGroupType();
-
case SHARING_TYPE:
return getSharingType();
@@ -596,8 +534,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
return isSetEntityId();
case GROUP_ID:
return isSetGroupId();
- case GROUP_TYPE:
- return isSetGroupType();
case SHARING_TYPE:
return isSetSharingType();
case INHERITED_PARENT_ID:
@@ -652,15 +588,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
return false;
}
- boolean this_present_groupType = true && this.isSetGroupType();
- boolean that_present_groupType = true && that.isSetGroupType();
- if (this_present_groupType || that_present_groupType) {
- if (!(this_present_groupType && that_present_groupType))
- return false;
- if (!this.groupType.equals(that.groupType))
- return false;
- }
-
boolean this_present_sharingType = true && this.isSetSharingType();
boolean that_present_sharingType = true && that.isSetSharingType();
if (this_present_sharingType || that_present_sharingType) {
@@ -728,11 +655,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
if (present_groupId)
list.add(groupId);
- boolean present_groupType = true && (isSetGroupType());
- list.add(present_groupType);
- if (present_groupType)
- list.add(groupType.getValue());
-
boolean present_sharingType = true && (isSetSharingType());
list.add(present_sharingType);
if (present_sharingType)
@@ -799,16 +721,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
return lastComparison;
}
}
- lastComparison = Boolean.valueOf(isSetGroupType()).compareTo(other.isSetGroupType());
- if (lastComparison != 0) {
- return lastComparison;
- }
- if (isSetGroupType()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groupType, other.groupType);
- if (lastComparison != 0) {
- return lastComparison;
- }
- }
lastComparison = Boolean.valueOf(isSetSharingType()).compareTo(other.isSetSharingType());
if (lastComparison != 0) {
return lastComparison;
@@ -908,16 +820,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
}
first = false;
}
- if (isSetGroupType()) {
- if (!first) sb.append(", ");
- sb.append("groupType:");
- if (this.groupType == null) {
- sb.append("null");
- } else {
- sb.append(this.groupType);
- }
- first = false;
- }
if (isSetSharingType()) {
if (!first) sb.append(", ");
sb.append("sharingType:");
@@ -1025,15 +927,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
- case 4: // GROUP_TYPE
- if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
- struct.groupType = org.apache.airavata.sharing.registry.models.GroupType.findByValue(iprot.readI32());
- struct.setGroupTypeIsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
- }
- break;
- case 5: // SHARING_TYPE
+ case 4: // SHARING_TYPE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.sharingType = org.apache.airavata.sharing.registry.models.SharingType.findByValue(iprot.readI32());
struct.setSharingTypeIsSet(true);
@@ -1041,7 +935,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
- case 6: // INHERITED_PARENT_ID
+ case 5: // INHERITED_PARENT_ID
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.inheritedParentId = iprot.readString();
struct.setInheritedParentIdIsSet(true);
@@ -1049,7 +943,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
- case 7: // CASCADE_PERMISSION
+ case 6: // CASCADE_PERMISSION
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.cascadePermission = iprot.readBool();
struct.setCascadePermissionIsSet(true);
@@ -1057,7 +951,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
- case 8: // CREATED_TIME
+ case 7: // CREATED_TIME
if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
struct.createdTime = iprot.readI64();
struct.setCreatedTimeIsSet(true);
@@ -1065,7 +959,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
- case 9: // UPDATED_TIME
+ case 8: // UPDATED_TIME
if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
struct.updatedTime = iprot.readI64();
struct.setUpdatedTimeIsSet(true);
@@ -1109,13 +1003,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
oprot.writeFieldEnd();
}
}
- if (struct.groupType != null) {
- if (struct.isSetGroupType()) {
- oprot.writeFieldBegin(GROUP_TYPE_FIELD_DESC);
- oprot.writeI32(struct.groupType.getValue());
- oprot.writeFieldEnd();
- }
- }
if (struct.sharingType != null) {
if (struct.isSetSharingType()) {
oprot.writeFieldBegin(SHARING_TYPE_FIELD_DESC);
@@ -1172,25 +1059,22 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
if (struct.isSetGroupId()) {
optionals.set(2);
}
- if (struct.isSetGroupType()) {
- optionals.set(3);
- }
if (struct.isSetSharingType()) {
- optionals.set(4);
+ optionals.set(3);
}
if (struct.isSetInheritedParentId()) {
- optionals.set(5);
+ optionals.set(4);
}
if (struct.isSetCascadePermission()) {
- optionals.set(6);
+ optionals.set(5);
}
if (struct.isSetCreatedTime()) {
- optionals.set(7);
+ optionals.set(6);
}
if (struct.isSetUpdatedTime()) {
- optionals.set(8);
+ optionals.set(7);
}
- oprot.writeBitSet(optionals, 9);
+ oprot.writeBitSet(optionals, 8);
if (struct.isSetPermissionTypeId()) {
oprot.writeString(struct.permissionTypeId);
}
@@ -1200,9 +1084,6 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
if (struct.isSetGroupId()) {
oprot.writeString(struct.groupId);
}
- if (struct.isSetGroupType()) {
- oprot.writeI32(struct.groupType.getValue());
- }
if (struct.isSetSharingType()) {
oprot.writeI32(struct.sharingType.getValue());
}
@@ -1223,7 +1104,7 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, Sharing struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
- BitSet incoming = iprot.readBitSet(9);
+ BitSet incoming = iprot.readBitSet(8);
if (incoming.get(0)) {
struct.permissionTypeId = iprot.readString();
struct.setPermissionTypeIdIsSet(true);
@@ -1237,26 +1118,22 @@ public class Sharing implements org.apache.thrift.TBase<Sharing, Sharing._Fields
struct.setGroupIdIsSet(true);
}
if (incoming.get(3)) {
- struct.groupType = org.apache.airavata.sharing.registry.models.GroupType.findByValue(iprot.readI32());
- struct.setGroupTypeIsSet(true);
- }
- if (incoming.get(4)) {
struct.sharingType = org.apache.airavata.sharing.registry.models.SharingType.findByValue(iprot.readI32());
struct.setSharingTypeIsSet(true);
}
- if (incoming.get(5)) {
+ if (incoming.get(4)) {
struct.inheritedParentId = iprot.readString();
struct.setInheritedParentIdIsSet(true);
}
- if (incoming.get(6)) {
+ if (incoming.get(5)) {
struct.cascadePermission = iprot.readBool();
struct.setCascadePermissionIsSet(true);
}
- if (incoming.get(7)) {
+ if (incoming.get(6)) {
struct.createdTime = iprot.readI64();
struct.setCreatedTimeIsSet(true);
}
- if (incoming.get(8)) {
+ if (incoming.get(7)) {
struct.updatedTime = iprot.readI64();
struct.setUpdatedTimeIsSet(true);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/modules/sharing-registry/thrift_models/sharing_models.thrift
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/thrift_models/sharing_models.thrift b/modules/sharing-registry/thrift_models/sharing_models.thrift
index 6dd3983..0994cb9 100644
--- a/modules/sharing-registry/thrift_models/sharing_models.thrift
+++ b/modules/sharing-registry/thrift_models/sharing_models.thrift
@@ -118,12 +118,10 @@ struct Sharing {
1: optional string permissionTypeId,
2: optional string entityId,
3: optional string groupId,
- 4: optional GroupType groupType,
- 5: optional SharingType sharingType,
- 6: optional string inheritedParentId,
- 7: optional bool cascadePermission,
- 8: optional i64 createdTime,
- 9: optional i64 updatedTime
+ 4: optional SharingType sharingType,
+ 5: optional string inheritedParentId,
+ 6: optional i64 createdTime,
+ 7: optional i64 updatedTime
}
exception GovRegistryException {
http://git-wip-us.apache.org/repos/asf/airavata/blob/986f00f2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f925004..e0400e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -564,7 +564,7 @@
<module>modules/workflow</module>
<module>modules/test-suite</module>
<module>modules/group-manager</module>
- <module>modules/airavata-sharing-registry</module>
+ <module>modules/sharing-registry</module>
<!-- Deprecated Modules-->
<!--<module>modules/integration-tests</module>-->
<!--<module>modules/workflow-model</module>-->
[2/2] airavata git commit: WIP
Posted by sc...@apache.org.
WIP
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4ddfa10d
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4ddfa10d
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4ddfa10d
Branch: refs/heads/airavata-gov-registry
Commit: 4ddfa10de79c708b726d8983bf0a7f2004926b02
Parents: 986f00f
Author: scnakandala <su...@gmail.com>
Authored: Wed Oct 5 16:27:13 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Wed Oct 5 16:27:13 2016 -0400
----------------------------------------------------------------------
.../sharing/registry/ConnectionFactory.java | 2 +-
.../registry/db/entities/SharingEntity.java | 21 ++++++++++----------
.../registry/db/entities/SharingEntityPK.java | 3 +--
.../server/SharingRegistryServerHandler.java | 6 +-----
4 files changed, 14 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/4ddfa10d/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/ConnectionFactory.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/ConnectionFactory.java b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/ConnectionFactory.java
index d501b96..40c0e18 100644
--- a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/ConnectionFactory.java
+++ b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/ConnectionFactory.java
@@ -38,7 +38,7 @@ public class ConnectionFactory {
public static final String EXPCAT_PASSWORD = "";
public static final String DRIVER_CLASS = "com.mysql.jdbc.Driver";
- private static Connection expCatConnection, sharingCatConnection;
+ private static Connection expCatConnection;
//private constructor
private ConnectionFactory() throws ClassNotFoundException, SQLException {
http://git-wip-us.apache.org/repos/asf/airavata/blob/4ddfa10d/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
index bbb9614..b4b74b0 100644
--- 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
@@ -68,17 +68,8 @@ public class SharingEntity {
this.groupId = groupId;
}
- @Basic
- @Column(name = "SHARING_TYPE")
- public String getSharingType() {
- return sharingType;
- }
- public void setSharingType(String sharingType) {
- this.sharingType = sharingType;
- }
-
- @Basic
+ @Id
@Column(name = "INHERITED_PARENT_ID")
public String getInheritedParentId() {
return inheritedParentId;
@@ -89,6 +80,16 @@ public class SharingEntity {
}
@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;
http://git-wip-us.apache.org/repos/asf/airavata/blob/4ddfa10d/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
index 59de199..da77a87 100644
--- 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
@@ -23,7 +23,6 @@ package org.apache.airavata.sharing.registry.db.entities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
@@ -65,8 +64,8 @@ public class SharingEntityPK implements Serializable {
this.groupId = groupId;
}
- @Basic
@Column(name = "INHERITED_PARENT_ID")
+ @Id
public String getInheritedParentId() {
return inheritedParentId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4ddfa10d/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
index b99a6df..247cbfe 100644
--- a/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ b/modules/sharing-registry/sharing-registry-core/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -386,11 +386,7 @@ public class SharingRegistryServerHandler implements GovRegistryService.Iface{
newSharing.setPermissionTypeId(sharing.permissionTypeId);
newSharing.setEntityId(entity.entityId);
newSharing.setGroupId(sharing.groupId);
- if(sharing.sharingType.equals(SharingType.DIRECT_CASCADING))
- newSharing.setInheritedParentId(sharing.entityId);
-
- else
- newSharing.setInheritedParentId(sharing.inheritedParentId);
+ newSharing.setInheritedParentId(sharing.inheritedParentId);
newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
newSharing.setCreatedTime(System.currentTimeMillis());
newSharing.setUpdatedTime(System.currentTimeMillis());