Repository: airavata Updated Branches: refs/heads/user-profile f113d160c -> 741531f0b
adding isShared field to entity Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/741531f0 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/741531f0 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/741531f0 Branch: refs/heads/user-profile Commit: 741531f0b78059af173032a09bfe58377ab507e6 Parents: f113d16 Author: scnakandala <[email protected]> Authored: Tue Mar 7 18:16:49 2017 -0500 Committer: scnakandala <[email protected]> Committed: Tue Mar 7 18:16:49 2017 -0500 ---------------------------------------------------------------------- .../registry/db/entities/EntityEntity.java | 11 ++ .../db/repositories/EntityRepository.java | 5 +- .../db/repositories/UserGroupRepository.java | 14 +++ .../server/SharingRegistryServerHandler.java | 47 ++++++-- .../main/resources/sharing-registry-derby.sql | 1 + .../main/resources/sharing-registry-mysql.sql | 1 + .../SharingRegistryServerHandlerTest.java | 6 + .../registry/SharingRegistryServiceTest.java | 8 ++ .../sharing/registry/models/Entity.java | 112 ++++++++++++++++++- .../service/cpi/SharingRegistryService.java | 1 - .../api-docs/sharing_models.html | 10 +- .../thrift_models/sharing_models.thrift | 3 +- 12 files changed, 202 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java index a6090e4..c9c1e19 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java @@ -41,6 +41,7 @@ public class EntityEntity { private ByteBuffer binaryData; private String fullText; private Long originalEntityCreationTime; + private boolean shared; private Long createdTime; private Long updatedTime; @@ -145,6 +146,16 @@ public class EntityEntity { } @Basic + @Column(name = "SHARED") + public boolean getShared() { + return shared; + } + + public void setShared(boolean shared) { + this.shared = shared; + } + + @Basic @Column(name = "CREATED_TIME") public Long getCreatedTime() { return createdTime; http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java index d713124..b616a21 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java @@ -146,8 +146,9 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, E entity.setBinaryData((byte[]) (rs[7])); entity.setFullText((String) (rs[8])); entity.setOriginalEntityCreationTime((long)(rs[9])); - entity.setCreatedTime((long)(rs[10])); - entity.setUpdatedTime((long)(rs[11])); + entity.setShared((boolean) rs[10]); + entity.setCreatedTime((long) (rs[11])); + entity.setUpdatedTime((long) (rs[12])); //Removing duplicates. Another option is to change the query to remove duplicates. if (!keys.containsKey(entity + domainId + "," + entity.entityId)) { http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java index c3a31c0..e786c60 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java @@ -52,4 +52,18 @@ public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroup query += " ORDER BY s.createdTime DESC"; return select(query, 0, -1); } + + + //checks whether is shared with any user or group with any permission + public boolean isShared(String domainId, String entityId) throws SharingRegistryException { + String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s"; + query += " WHERE "; + query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND "; + query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND "; + query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = '" + domainId + "' AND "; + query += "s." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND "; + query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> '" + (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId) + "'"; + query += " ORDER BY s.createdTime DESC"; + return select(query, 0, -1).size() != 0; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java index 5a222ce..2fc4acf 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java @@ -643,7 +643,9 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac @Override public boolean updateEntity(Entity entity) throws SharingRegistryException, TException { try{ - //TODO Check for permission changes + //checks whether the entity is shared with anyone + entity.setShared((new UserGroupRepository()).isShared(entity.domainId, entity.entityId)); + entity.setUpdatedTime(System.currentTimeMillis()); EntityPK entityPK = new EntityPK(); entityPK.setDomainId(entity.domainId); @@ -732,7 +734,14 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac @Override public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException { try{ - return shareEntity(domainId, entityId, userList, permissionTypeId, cascadePermission); + boolean result = shareEntity(domainId, entityId, userList, permissionTypeId, cascadePermission); + EntityPK entityPK = new EntityPK(); + entityPK.setEntityId(entityId); + entityPK.setDomainId(domainId); + Entity entity = (new EntityRepository()).get(entityPK); + entity.setShared(true); + (new EntityRepository()).update(entity); + return result; }catch (SharingRegistryException ex) { logger.error(ex.getMessage(), ex); throw ex; @@ -742,8 +751,16 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac @Override public boolean shareEntityWithGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException { try{ - return shareEntity(domainId, entityId, groupList, permissionTypeId, cascadePermission); + boolean result = shareEntity(domainId, entityId, groupList, permissionTypeId, cascadePermission); + EntityPK entityPK = new EntityPK(); + entityPK.setEntityId(entityId); + entityPK.setDomainId(domainId); + Entity entity = (new EntityRepository()).get(entityPK); + entity.setShared(true); + (new EntityRepository()).update(entity); + return result; }catch (SharingRegistryException ex) { + logger.error(ex.getMessage(), ex); throw ex; } @@ -813,7 +830,14 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){ throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed"); } - return revokeEntitySharing(domainId, entityId, userList, permissionTypeId); + boolean result = revokeEntitySharing(domainId, entityId, userList, permissionTypeId); + EntityPK entityPK = new EntityPK(); + entityPK.setEntityId(entityId); + entityPK.setDomainId(domainId); + Entity entity = (new EntityRepository()).get(entityPK); + entity.setShared((new UserGroupRepository()).isShared(domainId, entityId)); + (new EntityRepository()).update(entity); + return result; }catch (SharingRegistryException ex) { logger.error(ex.getMessage(), ex); throw ex; @@ -827,7 +851,14 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){ throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed"); } - return revokeEntitySharing(domainId, entityId, groupList, permissionTypeId); + boolean result = revokeEntitySharing(domainId, entityId, groupList, permissionTypeId); + EntityPK entityPK = new EntityPK(); + entityPK.setEntityId(entityId); + entityPK.setDomainId(domainId); + Entity entity = (new EntityRepository()).get(entityPK); + entity.setShared((new UserGroupRepository()).isShared(domainId, entityId)); + (new EntityRepository()).update(entity); + return result; }catch (SharingRegistryException ex) { logger.error(ex.getMessage(), ex); throw ex; @@ -856,6 +887,8 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be removed"); } + SharingRepository sharingRepository = new SharingRepository(); + //revoking permission for the entity for(String groupId : groupOrUserList){ SharingPK sharingPK = new SharingPK(); @@ -865,7 +898,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac sharingPK.setInheritedParentId(entityId); sharingPK.setDomainId(domainId); - (new SharingRepository()).delete(sharingPK); + sharingRepository.delete(sharingPK); } //revoking permission from inheritance @@ -881,7 +914,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac sharingPK.setInheritedParentId(entityId); sharingPK.setDomainId(domainId); - (new SharingRepository()).delete(sharingPK); + sharingRepository.delete(sharingPK); } } return true; http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql index 83ef3f3..4e6af79 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql +++ b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql @@ -102,6 +102,7 @@ CREATE TABLE ENTITY ( BINARY_DATA BLOB, FULL_TEXT VARCHAR(255), ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL, + SHARED BOOLEAN, CREATED_TIME BIGINT NOT NULL, UPDATED_TIME BIGINT NOT NULL, PRIMARY KEY (ENTITY_ID, DOMAIN_ID), http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql index d4ec07c..3fe9763 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql +++ b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql @@ -102,6 +102,7 @@ CREATE TABLE ENTITY ( BINARY_DATA BLOB, FULL_TEXT TEXT, ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL, + SHARED BOOL, CREATED_TIME BIGINT NOT NULL, UPDATED_TIME BIGINT NOT NULL, PRIMARY KEY (ENTITY_ID, DOMAIN_ID), http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java index 627d0e1..2ae29ac 100644 --- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java +++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java @@ -238,7 +238,13 @@ public class SharingRegistryServerHandlerTest { String entityId3 = sharingRegistryServerHandler.createEntity(entity3); Assert.assertNotNull(entityId3); + Assert.assertTrue(!sharingRegistryServerHandler.getEntity(domainId, entityId1).isShared()); sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId1, Arrays.asList(userId2), permissionTypeId1, true); + Assert.assertTrue(sharingRegistryServerHandler.getEntity(domainId, entityId1).isShared()); + sharingRegistryServerHandler.revokeEntitySharingFromUsers(domainId, entityId1, Arrays.asList(userId2), permissionTypeId1); + Assert.assertTrue(!sharingRegistryServerHandler.getEntity(domainId, entityId1).isShared()); + sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId1, Arrays.asList(userId2), permissionTypeId1, true); + sharingRegistryServerHandler.shareEntityWithGroups(domainId, entityId3, Arrays.asList(groupId2), permissionTypeId1, true); Entity entity4 = new Entity(); http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java index f678282..551a140 100644 --- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java +++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java @@ -272,7 +272,15 @@ public class SharingRegistryServiceTest { entity4.setFullText("test input file 1 for experiment 2"); sharingServiceClient.createEntity(entity4); + Assert.assertTrue(!sharingServiceClient.getEntity(domainId, "test-project-1").isShared()); sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true); + Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").isShared()); + sharingServiceClient.revokeEntitySharingFromUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE"); + Assert.assertTrue(!sharingServiceClient.getEntity(domainId, "test-project-1").isShared()); + + sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true); + + sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true); sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "CLONE", false); http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java index c7bc3e1..dc485fb 100644 --- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java +++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java @@ -67,6 +67,7 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, private static final org.apache.thrift.protocol.TField ORIGINAL_ENTITY_CREATION_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("originalEntityCreationTime", org.apache.thrift.protocol.TType.I64, (short)10); 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)11); 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)12); + private static final org.apache.thrift.protocol.TField SHARED_FIELD_DESC = new org.apache.thrift.protocol.TField("shared", org.apache.thrift.protocol.TType.BOOL, (short) 13); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -86,6 +87,7 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, public long originalEntityCreationTime; // optional public long createdTime; // optional public long updatedTime; // optional + public boolean shared; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -100,7 +102,8 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, FULL_TEXT((short)9, "fullText"), ORIGINAL_ENTITY_CREATION_TIME((short)10, "originalEntityCreationTime"), CREATED_TIME((short)11, "createdTime"), - UPDATED_TIME((short)12, "updatedTime"); + UPDATED_TIME((short) 12, "updatedTime"), + SHARED((short) 13, "shared"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -139,6 +142,8 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, return CREATED_TIME; case 12: // UPDATED_TIME return UPDATED_TIME; + case 13: // SHARED + return SHARED; default: return null; } @@ -182,8 +187,9 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, private static final int __ORIGINALENTITYCREATIONTIME_ISSET_ID = 0; private static final int __CREATEDTIME_ISSET_ID = 1; private static final int __UPDATEDTIME_ISSET_ID = 2; + private static final int __SHARED_ISSET_ID = 3; private byte __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.ENTITY_ID,_Fields.DOMAIN_ID,_Fields.ENTITY_TYPE_ID,_Fields.OWNER_ID,_Fields.PARENT_ENTITY_ID,_Fields.NAME,_Fields.DESCRIPTION,_Fields.BINARY_DATA,_Fields.FULL_TEXT,_Fields.ORIGINAL_ENTITY_CREATION_TIME,_Fields.CREATED_TIME,_Fields.UPDATED_TIME}; + private static final _Fields optionals[] = {_Fields.ENTITY_ID, _Fields.DOMAIN_ID, _Fields.ENTITY_TYPE_ID, _Fields.OWNER_ID, _Fields.PARENT_ENTITY_ID, _Fields.NAME, _Fields.DESCRIPTION, _Fields.BINARY_DATA, _Fields.FULL_TEXT, _Fields.ORIGINAL_ENTITY_CREATION_TIME, _Fields.CREATED_TIME, _Fields.UPDATED_TIME, _Fields.SHARED}; 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); @@ -211,11 +217,15 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.UPDATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("updatedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.SHARED, new org.apache.thrift.meta_data.FieldMetaData("shared", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Entity.class, metaDataMap); } public Entity() { + this.shared = false; + } /** @@ -253,6 +263,7 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, this.originalEntityCreationTime = other.originalEntityCreationTime; this.createdTime = other.createdTime; this.updatedTime = other.updatedTime; + this.shared = other.shared; } public Entity deepCopy() { @@ -276,6 +287,8 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, this.createdTime = 0; setUpdatedTimeIsSet(false); this.updatedTime = 0; + this.shared = false; + } public String getEntityId() { @@ -573,6 +586,31 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID, value); } + public boolean isShared() { + return this.shared; + } + + public Entity setShared(boolean shared) { + this.shared = shared; + setSharedIsSet(true); + return this; + } + + public void unsetShared() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SHARED_ISSET_ID); + } + + /** + * Returns true if field shared is set (has been assigned a value) and false otherwise + */ + public boolean isSetShared() { + return EncodingUtils.testBit(__isset_bitfield, __SHARED_ISSET_ID); + } + + public void setSharedIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SHARED_ISSET_ID, value); + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case ENTITY_ID: @@ -671,6 +709,14 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, } break; + case SHARED: + if (value == null) { + unsetShared(); + } else { + setShared((Boolean) value); + } + break; + } } @@ -712,6 +758,9 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, case UPDATED_TIME: return getUpdatedTime(); + case SHARED: + return isShared(); + } throw new IllegalStateException(); } @@ -747,6 +796,8 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, return isSetCreatedTime(); case UPDATED_TIME: return isSetUpdatedTime(); + case SHARED: + return isSetShared(); } throw new IllegalStateException(); } @@ -872,6 +923,15 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, return false; } + boolean this_present_shared = true && this.isSetShared(); + boolean that_present_shared = true && that.isSetShared(); + if (this_present_shared || that_present_shared) { + if (!(this_present_shared && that_present_shared)) + return false; + if (this.shared != that.shared) + return false; + } + return true; } @@ -939,6 +999,11 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, if (present_updatedTime) list.add(updatedTime); + boolean present_shared = true && (isSetShared()); + list.add(present_shared); + if (present_shared) + list.add(shared); + return list.hashCode(); } @@ -1070,6 +1135,16 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, return lastComparison; } } + lastComparison = Boolean.valueOf(isSetShared()).compareTo(other.isSetShared()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetShared()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.shared, other.shared); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -1197,6 +1272,12 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, sb.append(this.updatedTime); first = false; } + if (isSetShared()) { + if (!first) sb.append(", "); + sb.append("shared:"); + sb.append(this.shared); + first = false; + } sb.append(")"); return sb.toString(); } @@ -1338,6 +1419,14 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 13: // SHARED + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.shared = iprot.readBool(); + struct.setSharedIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1431,6 +1520,11 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, oprot.writeI64(struct.updatedTime); oprot.writeFieldEnd(); } + if (struct.isSetShared()) { + oprot.writeFieldBegin(SHARED_FIELD_DESC); + oprot.writeBool(struct.shared); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1485,7 +1579,10 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, if (struct.isSetUpdatedTime()) { optionals.set(11); } - oprot.writeBitSet(optionals, 12); + if (struct.isSetShared()) { + optionals.set(12); + } + oprot.writeBitSet(optionals, 13); if (struct.isSetEntityId()) { oprot.writeString(struct.entityId); } @@ -1522,12 +1619,15 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, if (struct.isSetUpdatedTime()) { oprot.writeI64(struct.updatedTime); } + if (struct.isSetShared()) { + oprot.writeBool(struct.shared); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, Entity struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(12); + BitSet incoming = iprot.readBitSet(13); if (incoming.get(0)) { struct.entityId = iprot.readString(); struct.setEntityIdIsSet(true); @@ -1576,6 +1676,10 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, struct.updatedTime = iprot.readI64(); struct.setUpdatedTimeIsSet(true); } + if (incoming.get(12)) { + struct.shared = iprot.readBool(); + struct.setSharedIsSet(true); + } } } http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/service/cpi/SharingRegistryService.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/service/cpi/SharingRegistryService.java b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/service/cpi/SharingRegistryService.java index 2fc5691..065619c 100644 --- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/service/cpi/SharingRegistryService.java +++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/service/cpi/SharingRegistryService.java @@ -2764,7 +2764,6 @@ public class SharingRegistryService { private List<org.apache.airavata.sharing.registry.models.SearchCriteria> filters; private int offset; private int limit; - public searchEntities_call(String domainId, String userId, List<org.apache.airavata.sharing.registry.models.SearchCriteria> filters, int offset, int limit, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.domainId = domainId; http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html b/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html index c21add8..8ce70b8 100644 --- a/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html +++ b/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html @@ -70,7 +70,6 @@ considered as a group in it's own right for implementation ease</p> <li>OWNER_ID : Owner of the entity</li> <li>CREATED_TIME : Created time of the entity</li> <li>UPDATED_TIME : Updated time of the entity</li> - <li>ENTITY_TYPE_ID : Entity type ID</li> <br/><br/><table class="table-bordered table-striped table-condensed"> <tr><td><code>NAME</code></td><td><code>0</code></td><td> @@ -103,7 +102,6 @@ considered as a group in it's own right for implementation ease</p> <li>FULL_TEXT : Does a full text search. Only applicable for the FULL_TEXT field.</li> <li>GTE : Greater than or equal. Only applicable for created time and updated time.</li> <li>LTE : Less than or equal. Only applicable for created time and updated time.</li> - <li>NOT : Not operator. Only applicable for name, permission type id, parent entity id and owner id.</li> <br/><br/><table class="table-bordered table-striped table-condensed"> <tr><td><code>EQUAL</code></td><td><code>0</code></td><td> @@ -246,6 +244,14 @@ regarding the user.</p> <tr><td>10</td><td>originalEntityCreationTime</td><td><code>i64</code></td><td></td><td>optional</td><td></td></tr> <tr><td>11</td><td>createdTime</td><td><code>i64</code></td><td></td><td>optional</td><td></td></tr> <tr><td>12</td><td>updatedTime</td><td><code>i64</code></td><td></td><td>optional</td><td></td></tr> + <tr> + <td>13</td> + <td>shared</td> + <td><code>bool</code></td> + <td></td> + <td>optional</td> + <td><code>false</code></td> + </tr> </table><br/><p>Entity object which is used to register an entity in the system.</p> <li><b>entityId</b> : Entity id provided by the client</li> <li><b>domainId</b> : Domain id</li> http://git-wip-us.apache.org/repos/asf/airavata/blob/741531f0/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 c646c85..5b32720 100644 --- a/modules/sharing-registry/thrift_models/sharing_models.thrift +++ b/modules/sharing-registry/thrift_models/sharing_models.thrift @@ -224,7 +224,8 @@ struct Entity { 9: optional string fullText, 10: optional i64 originalEntityCreationTime, 11: optional i64 createdTime, - 12: optional i64 updatedTime + 12: optional i64 updatedTime, + 13: optional bool shared = false } /**
