fixing id issues
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/b6e07d7b Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/b6e07d7b Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/b6e07d7b Branch: refs/heads/airavata-gov-registry Commit: b6e07d7ba9e0e8d0612f5233e7dbe212d762d608 Parents: 61a0fc9 Author: scnakandala <supun.nakand...@gmail.com> Authored: Sun Oct 16 18:23:19 2016 -0400 Committer: scnakandala <supun.nakand...@gmail.com> Committed: Sun Oct 16 18:23:19 2016 -0400 ---------------------------------------------------------------------- .../server/handler/AiravataServerHandler.java | 15 +- .../registry/db/entities/EntityEntity.java | 28 +- .../sharing/registry/db/entities/EntityPK.java | 76 + .../registry/db/entities/EntityTypeEntity.java | 3 +- .../registry/db/entities/EntityTypePK.java | 76 + .../db/entities/GroupMembershipEntity.java | 13 +- .../db/entities/GroupMembershipEntityPK.java | 74 - .../registry/db/entities/GroupMembershipPK.java | 88 + .../db/entities/PermissionTypeEntity.java | 3 +- .../registry/db/entities/PermissionTypePK.java | 76 + .../registry/db/entities/SharingEntity.java | 13 +- .../registry/db/entities/SharingEntityPK.java | 99 - .../sharing/registry/db/entities/SharingPK.java | 114 + .../registry/db/entities/SharingUserEntity.java | 157 - .../registry/db/entities/UserEntity.java | 158 + .../registry/db/entities/UserGroupEntity.java | 3 +- .../registry/db/entities/UserGroupPK.java | 75 + .../sharing/registry/db/entities/UserPK.java | 75 + .../db/repositories/EntityRepository.java | 7 +- .../db/repositories/EntityTypeRepository.java | 3 +- .../repositories/GroupMembershipRepository.java | 46 +- .../repositories/PermissionTypeRepository.java | 3 +- .../db/repositories/SharingRepository.java | 15 +- .../db/repositories/UserGroupRepository.java | 7 +- .../db/repositories/UserRepository.java | 13 +- .../sharing/registry/db/utils/DBConstants.java | 65 +- .../server/SharingRegistryServerHandler.java | 234 +- .../src/main/resources/META-INF/persistence.xml | 2 +- .../main/resources/sharing-registry-derby.sql | 45 +- .../main/resources/sharing-registry-mysql.sql | 51 +- .../SharingRegistryServerHandlerTest.java | 30 +- .../sharing/registry/models/Domain.java | 2 +- .../sharing/registry/models/Entity.java | 176 +- .../sharing/registry/models/EntityType.java | 9 +- .../registry/models/GroupMembership.java | 149 +- .../sharing/registry/models/PermissionType.java | 9 +- .../sharing/registry/models/SearchCriteria.java | 2 +- .../sharing/registry/models/Sharing.java | 149 +- .../models/SharingRegistryException.java | 2 +- .../airavata/sharing/registry/models/User.java | 4 +- .../sharing/registry/models/UserGroup.java | 9 +- .../service/cpi/SharingRegistryService.java | 2779 +++++++++++++++--- .../api-docs/sharing_cpi.html | 57 +- .../api-docs/sharing_models.html | 34 +- .../sharing-service-docs/index.html | 3 +- .../thrift_models/sharing_cpi.thrift | 38 +- .../thrift_models/sharing_models.thrift | 38 +- 47 files changed, 3909 insertions(+), 1218 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index 7690ca2..36770ea 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -814,7 +814,8 @@ public class AiravataServerHandler implements Airavata.Iface { if (ServerSettings.isEnableSharing()){ // user projects + user accessible projects List<String> accessibleProjectIds = new ArrayList<>(); - sharingRegistryServerHandler.searchEntities(userName+"@"+gatewayId , gatewayId+":PROJECT", + sharingRegistryServerHandler.searchEntities(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), + userName+"@"+gatewayId , gatewayId+":PROJECT", new ArrayList<>(), offset, limit).stream().forEach(p->accessibleProjectIds.add(p.entityId)); return getRegistryServiceClient().searchProjects(gatewayId, userName, accessibleProjectIds, new HashMap<>(), limit, offset); }else{ @@ -859,7 +860,8 @@ public class AiravataServerHandler implements Airavata.Iface { List<String> accessibleProjIds = new ArrayList<>(); if(ServerSettings.isEnableSharing()) - sharingRegistryServerHandler.searchEntities(userName+"@"+gatewayId, gatewayId+":PROJECT", + sharingRegistryServerHandler.searchEntities(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), + userName+"@"+gatewayId, gatewayId+":PROJECT", new ArrayList<>(), 0, -1).stream().forEach(e->accessibleProjIds.add(e.entityId)); return getRegistryServiceClient().searchProjects(gatewayId, userName, accessibleProjIds, filters, limit, offset); @@ -896,7 +898,8 @@ public class AiravataServerHandler implements Airavata.Iface { try { List<String> accessibleExpIds = new ArrayList<>(); if(ServerSettings.isEnableSharing()) - sharingRegistryServerHandler.searchEntities(userName+"@"+gatewayId, gatewayId+":EXPERIMENT", + sharingRegistryServerHandler.searchEntities(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), + userName+"@"+gatewayId, gatewayId+":EXPERIMENT", new ArrayList<>(), 0, -1).forEach(e->accessibleExpIds.add(e.entityId)); return getRegistryServiceClient().searchExperiments(gatewayId, userName, accessibleExpIds, filters, limit, offset); }catch (Exception e) { @@ -3873,10 +3876,12 @@ public class AiravataServerHandler implements Airavata.Iface { try { List<String> accessibleUsers = new ArrayList<>(); if(permissionType.equals(ResourcePermissionType.WRITE)) - sharingRegistryServerHandler.getListOfSharedUsers(resourceId, authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + sharingRegistryServerHandler.getListOfSharedUsers(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), + resourceId, authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":WRITE").stream().forEach(u->accessibleUsers.add(u.userId)); else if(permissionType.equals(ResourcePermissionType.READ)) - sharingRegistryServerHandler.getListOfSharedUsers(resourceId, authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + sharingRegistryServerHandler.getListOfSharedUsers(authzToken.getClaimsMap().get(Constants.GATEWAY_ID), + resourceId, authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + ":READ").stream().forEach(u->accessibleUsers.add(u.userId)); return accessibleUsers; } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/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 de8abf4..7ee8225 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 @@ -24,10 +24,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.persistence.*; -import java.util.Map; +import java.nio.ByteBuffer; @Entity @Table(name = "ENTITY", schema = "") +@IdClass(EntityPK.class) public class EntityEntity { private final static Logger logger = LoggerFactory.getLogger(EntityEntity.class); private String entityId; @@ -37,7 +38,7 @@ public class EntityEntity { private String parentEntityId; private String name; private String description; - private Map<String, String> metadata; + private ByteBuffer binaryData; private String fullText; private Long createdTime; private Long updatedTime; @@ -52,7 +53,7 @@ public class EntityEntity { this.entityId = entityId; } - @Basic + @Id @Column(name = "DOMAIN_ID") public String getDomainId() { return domainId; @@ -112,19 +113,14 @@ public class EntityEntity { this.description = description; } - @ElementCollection - @CollectionTable( - name="ENTITY_METADATA", - joinColumns=@JoinColumn(name="ENTITY_ID") - ) - @MapKeyColumn(name="META_KEY") - @Column(name="META_VALUE") - public Map<String, String> getMetadata() { - return metadata; + @Lob + @Column(name="BINARY_DATA") + public ByteBuffer getBinaryData() { + return binaryData; } - public void setMetadata(Map<String, String> metadata) { - this.metadata = metadata; + public void setBinaryData(ByteBuffer binaryData) { + this.binaryData = binaryData; } @Lob @@ -169,7 +165,7 @@ public class EntityEntity { if (parentEntityId != null ? !parentEntityId.equals(that.parentEntityId) : that.parentEntityId != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; - if (metadata.equals(that.metadata)) return false; + if (binaryData.equals(that.binaryData)) return false; if (fullText != null ? !fullText.equals(that.fullText) : that.fullText != null) return false; if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false; if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false; @@ -183,7 +179,7 @@ public class EntityEntity { int result = entityId != null ? entityId.hashCode() : 0; result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (metadata != null ? metadata.hashCode() : 0); + result = 31 * result + (binaryData != null ? binaryData.hashCode() : 0); result = 31 * result + (fullText != null ? fullText.hashCode() : 0); result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0); result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0); http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityPK.java new file mode 100644 index 0000000..44bd33c --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityPK.java @@ -0,0 +1,76 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class EntityPK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(EntityPK.class); + private String entityId; + private String domainId; + + + @Column(name = "ENTITY_ID") + @Id + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + EntityPK that = (EntityPK) o; + + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) + return false; + if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = domainId != null ? domainId.hashCode() : 0; + result = 31 * result + (entityId != null ? entityId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java index 0b789ed..1b531cc 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypeEntity.java @@ -27,6 +27,7 @@ import javax.persistence.*; @Entity @Table(name = "ENTITY_TYPE", schema = "") +@IdClass(EntityTypePK.class) public class EntityTypeEntity { private final static Logger logger = LoggerFactory.getLogger(EntityTypeEntity.class); private String entityTypeId; @@ -46,7 +47,7 @@ public class EntityTypeEntity { this.entityTypeId = entityTypeId; } - @Basic + @Id @Column(name = "DOMAIN_ID") public String getDomainId() { return domainId; http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypePK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypePK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypePK.java new file mode 100644 index 0000000..03f5ba2 --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityTypePK.java @@ -0,0 +1,76 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class EntityTypePK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(EntityTypePK.class); + private String entityTypeId; + private String domainId; + + + @Column(name = "ENTITY_TYPE_ID") + @Id + public String getEntityTypeId() { + return entityTypeId; + } + + public void setEntityTypeId(String entityTypeId) { + this.entityTypeId = entityTypeId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + EntityTypePK that = (EntityTypePK) o; + + if (entityTypeId != null ? !entityTypeId.equals(that.entityTypeId) : that.entityTypeId != null) + return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = entityTypeId != null ? entityTypeId.hashCode() : 0; + result = 31 * result + (domainId != null ? domainId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java index c62a52d..1e7710b 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntity.java @@ -27,12 +27,13 @@ import javax.persistence.*; @Entity @Table(name = "GROUP_MEMBERSHIP", schema = "") -@IdClass(GroupMembershipEntityPK.class) +@IdClass(GroupMembershipPK.class) public class GroupMembershipEntity { private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntity.class); private String parentId; private String childId; private String childType; + private String domainId; private Long createdTime; private Long updatedTime; @@ -56,6 +57,16 @@ public class GroupMembershipEntity { this.childId = childId; } + @Id + @Column(name = "DOMAIN_ID") + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + @Basic @Column(name = "CHILD_TYPE") public String getChildType() { http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java deleted file mode 100644 index be3b1f9..0000000 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipEntityPK.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.sharing.registry.db.entities; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.Column; -import javax.persistence.Id; -import java.io.Serializable; - -public class GroupMembershipEntityPK implements Serializable { - private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntityPK.class); - private String parentId; - private String childId; - - @Column(name = "PARENT_ID") - @Id - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - @Column(name = "CHILD_ID") - @Id - public String getChildId() { - return childId; - } - - public void setChildId(String childId) { - this.childId = childId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - GroupMembershipEntityPK that = (GroupMembershipEntityPK) o; - - if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false; - if (childId != null ? !childId.equals(that.childId) : that.childId != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = parentId != null ? parentId.hashCode() : 0; - result = 31 * result + (childId != null ? childId.hashCode() : 0); - return result; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipPK.java new file mode 100644 index 0000000..d123021 --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/GroupMembershipPK.java @@ -0,0 +1,88 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class GroupMembershipPK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(GroupMembershipPK.class); + private String parentId; + private String childId; + private String domainId; + + @Column(name = "PARENT_ID") + @Id + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + @Column(name = "CHILD_ID") + @Id + public String getChildId() { + return childId; + } + + public void setChildId(String childId) { + this.childId = childId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GroupMembershipPK that = (GroupMembershipPK) o; + + if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) + return false; + if (childId != null ? !childId.equals(that.childId) : that.childId != null) return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = parentId != null ? parentId.hashCode() : 0; + result = 31 * result + (childId != null ? childId.hashCode() : 0); + result = 31 * result + (domainId != null ? domainId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java index c145cbe..a5eddae 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypeEntity.java @@ -27,6 +27,7 @@ import javax.persistence.*; @Entity @Table(name = "PERMISSION_TYPE", schema = "") +@IdClass(PermissionTypePK.class) public class PermissionTypeEntity { private final static Logger logger = LoggerFactory.getLogger(PermissionTypeEntity.class); private String permissionTypeId; @@ -46,7 +47,7 @@ public class PermissionTypeEntity { this.permissionTypeId = permissionTypeId; } - @Basic + @Id @Column(name = "DOMAIN_ID") public String getDomainId() { return domainId; http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypePK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypePK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypePK.java new file mode 100644 index 0000000..4a5bec2 --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/PermissionTypePK.java @@ -0,0 +1,76 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class PermissionTypePK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(PermissionTypePK.class); + private String permissionTypeId; + private String domainId; + + + @Column(name = "PERMISSION_TYPE_ID") + @Id + public String getPermissionTypeId() { + return permissionTypeId; + } + + public void setPermissionTypeId(String permissionTypeId) { + this.permissionTypeId = permissionTypeId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PermissionTypePK that = (PermissionTypePK) o; + + if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null) + return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0; + result = 31 * result + (domainId != null ? domainId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java index b4b74b0..50dadab 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntity.java @@ -27,12 +27,13 @@ import javax.persistence.*; @Entity @Table(name = "SHARING", schema = "") -@IdClass(SharingEntityPK.class) +@IdClass(SharingPK.class) public class SharingEntity { private final static Logger logger = LoggerFactory.getLogger(SharingEntity.class); private String permissionTypeId; private String entityId; private String groupId; + private String domainId; private String sharingType; private String inheritedParentId; private Long createdTime; @@ -79,6 +80,16 @@ public class SharingEntity { this.inheritedParentId = inheritedParentId; } + @Id + @Column(name = "DOMAIN_ID") + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + @Basic @Column(name = "SHARING_TYPE") public String getSharingType() { http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java deleted file mode 100644 index da77a87..0000000 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingEntityPK.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.sharing.registry.db.entities; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.Column; -import javax.persistence.Id; -import java.io.Serializable; - -public class SharingEntityPK implements Serializable { - private final static Logger logger = LoggerFactory.getLogger(SharingEntityPK.class); - private String permissionTypeId; - private String entityId; - private String groupId; - private String inheritedParentId; - - @Column(name = "PERMISSION_TYPE_ID") - @Id - public String getPermissionTypeId() { - return permissionTypeId; - } - - public void setPermissionTypeId(String permissionTypeId) { - this.permissionTypeId = permissionTypeId; - } - - @Column(name = "ENTITY_ID") - @Id - public String getEntityId() { - return entityId; - } - - public void setEntityId(String entityId) { - this.entityId = entityId; - } - - @Column(name = "GROUP_ID") - @Id - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - @Column(name = "INHERITED_PARENT_ID") - @Id - public String getInheritedParentId() { - return inheritedParentId; - } - - public void setInheritedParentId(String inheritedParentId) { - this.inheritedParentId = inheritedParentId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SharingEntityPK that = (SharingEntityPK) o; - - if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null) - return false; - if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false; - if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0; - result = 31 * result + (entityId != null ? entityId.hashCode() : 0); - result = 31 * result + (groupId != null ? groupId.hashCode() : 0); - return result; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingPK.java new file mode 100644 index 0000000..c046fb1 --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingPK.java @@ -0,0 +1,114 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class SharingPK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(SharingPK.class); + private String permissionTypeId; + private String entityId; + private String groupId; + private String inheritedParentId; + private String domainId; + + @Column(name = "PERMISSION_TYPE_ID") + @Id + public String getPermissionTypeId() { + return permissionTypeId; + } + + public void setPermissionTypeId(String permissionTypeId) { + this.permissionTypeId = permissionTypeId; + } + + @Column(name = "ENTITY_ID") + @Id + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + @Column(name = "GROUP_ID") + @Id + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + @Column(name = "INHERITED_PARENT_ID") + @Id + public String getInheritedParentId() { + return inheritedParentId; + } + + public void setInheritedParentId(String inheritedParentId) { + this.inheritedParentId = inheritedParentId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SharingPK that = (SharingPK) o; + + if (permissionTypeId != null ? !permissionTypeId.equals(that.permissionTypeId) : that.permissionTypeId != null) + return false; + if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false; + if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) return false; + if (inheritedParentId != null ? !inheritedParentId.equals(that.inheritedParentId) : that.inheritedParentId != null) return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = permissionTypeId != null ? permissionTypeId.hashCode() : 0; + result = 31 * result + (entityId != null ? entityId.hashCode() : 0); + result = 31 * result + (groupId != null ? groupId.hashCode() : 0); + result = 31 * result + (inheritedParentId != null ? inheritedParentId.hashCode() : 0); + result = 31 * result + (domainId != null ? domainId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java deleted file mode 100644 index 1482ce9..0000000 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/SharingUserEntity.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.sharing.registry.db.entities; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; -import java.nio.ByteBuffer; - -@Entity -@Table(name = "SHARING_USER", schema = "") -public class SharingUserEntity { - private final static Logger logger = LoggerFactory.getLogger(SharingUserEntity.class); - private String userId; - private String domainId; - private String userName; - private String firstName; - private String lastName; - private String email; - private ByteBuffer icon; - private Long createdTime; - private Long updatedTime; - - @Id - @Column(name = "USER_ID") - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - @Basic - @Column(name = "DOMAIN_ID") - public String getDomainId() { - return domainId; - } - - public void setDomainId(String domainId) { - this.domainId = domainId; - } - - @Basic - @Column(name = "USER_NAME") - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - @Basic - @Column(name = "FIRST_NAME") - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - @Basic - @Column(name = "LAST_NAME") - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - @Basic - @Column(name = "EMAIL") - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Lob - @Column(name = "ICON") - public ByteBuffer getIcon() { - return icon; - } - - public void setIcon(ByteBuffer icon) { - this.icon = icon; - } - - @Basic - @Column(name = "CREATED_TIME") - public Long getCreatedTime() { - return createdTime; - } - - public void setCreatedTime(Long createdTime) { - this.createdTime = createdTime; - } - - @Basic - @Column(name = "UPDATED_TIME") - public Long getUpdatedTime() { - return updatedTime; - } - - public void setUpdatedTime(Long updatedTime) { - this.updatedTime = updatedTime; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SharingUserEntity that = (SharingUserEntity) o; - - if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false; - if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; - if (userName != null ? !userName.equals(that.userName) : that.userName != null) return false; - if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false; - if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (userName != null ? userName.hashCode() : 0); - result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0); - result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0); - return result; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserEntity.java new file mode 100644 index 0000000..05cbd19 --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserEntity.java @@ -0,0 +1,158 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.*; +import java.nio.ByteBuffer; + +@Entity +@Table(name = "SHARING_USER", schema = "") // USER is a reserved term in derby +@IdClass(UserPK.class) +public class UserEntity { + private final static Logger logger = LoggerFactory.getLogger(UserEntity.class); + private String userId; + private String domainId; + private String userName; + private String firstName; + private String lastName; + private String email; + private ByteBuffer icon; + private Long createdTime; + private Long updatedTime; + + @Id + @Column(name = "USER_ID") + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + @Id + @Column(name = "DOMAIN_ID") + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Basic + @Column(name = "USER_NAME") + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + @Basic + @Column(name = "FIRST_NAME") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @Basic + @Column(name = "LAST_NAME") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Basic + @Column(name = "EMAIL") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Lob + @Column(name = "ICON") + public ByteBuffer getIcon() { + return icon; + } + + public void setIcon(ByteBuffer icon) { + this.icon = icon; + } + + @Basic + @Column(name = "CREATED_TIME") + public Long getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Long createdTime) { + this.createdTime = createdTime; + } + + @Basic + @Column(name = "UPDATED_TIME") + public Long getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(Long updatedTime) { + this.updatedTime = updatedTime; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + UserEntity that = (UserEntity) o; + + if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + if (userName != null ? !userName.equals(that.userName) : that.userName != null) return false; + if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false; + if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = userId != null ? userId.hashCode() : 0; + result = 31 * result + (userName != null ? userName.hashCode() : 0); + result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0); + result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java index 09fd8d8..d212d8d 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupEntity.java @@ -27,6 +27,7 @@ import javax.persistence.*; @Entity @Table(name = "USER_GROUP", schema = "") +@IdClass(UserGroupPK.class) public class UserGroupEntity { private final static Logger logger = LoggerFactory.getLogger(UserGroupEntity.class); private String groupId; @@ -49,7 +50,7 @@ public class UserGroupEntity { this.groupId = groupId; } - @Basic + @Id @Column(name = "DOMAIN_ID") public String getDomainId() { return domainId; http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupPK.java new file mode 100644 index 0000000..42ae5da --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserGroupPK.java @@ -0,0 +1,75 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class UserGroupPK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(UserGroupPK.class); + private String groupId; + private String domainId; + + @Column(name = "GROUP_ID") + @Id + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + UserGroupPK that = (UserGroupPK) o; + + if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) + return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = groupId != null ? groupId.hashCode() : 0; + result = 31 * result + (domainId != null ? domainId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserPK.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserPK.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserPK.java new file mode 100644 index 0000000..eb39f69 --- /dev/null +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/UserPK.java @@ -0,0 +1,75 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.sharing.registry.db.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.Column; +import javax.persistence.Id; +import java.io.Serializable; + +public class UserPK implements Serializable { + private final static Logger logger = LoggerFactory.getLogger(UserPK.class); + private String userId; + private String domainId; + + @Column(name = "USER_ID") + @Id + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + @Column(name = "DOMAIN_ID") + @Id + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + UserPK that = (UserPK) o; + + if (userId != null ? !userId.equals(that.userId) : that.userId != null) + return false; + if (domainId != null ? !domainId.equals(that.domainId) : that.domainId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = userId != null ? userId.hashCode() : 0; + result = 31 * result + (domainId != null ? domainId.hashCode() : 0); + return result; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/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 b7137d2..a762f00 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 @@ -21,6 +21,7 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.EntityEntity; +import org.apache.airavata.sharing.registry.db.entities.EntityPK; import org.apache.airavata.sharing.registry.db.entities.SharingEntity; import org.apache.airavata.sharing.registry.db.utils.DBConstants; import org.apache.airavata.sharing.registry.models.*; @@ -30,7 +31,7 @@ import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.List; -public class EntityRepository extends AbstractRepository<Entity, EntityEntity, String> { +public class EntityRepository extends AbstractRepository<Entity, EntityEntity, EntityPK> { private final static Logger logger = LoggerFactory.getLogger(EntityRepository.class); public EntityRepository() { @@ -43,7 +44,7 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, S return select(filters, 0, -1); } - public List<Entity> searchEntities(List<String> groupIds, String entityTypeId, List<SearchCriteria> filters, + public List<Entity> searchEntities(String domainId, List<String> groupIds, String entityTypeId, List<SearchCriteria> filters, int offset, int limit) throws SharingRegistryException { String groupIdString = "'"; for(String groupId : groupIds) @@ -52,6 +53,8 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, S String query = "SELECT E FROM " + EntityEntity.class.getSimpleName() + " E, " + SharingEntity.class.getSimpleName() + " S WHERE " + "E." + DBConstants.EntityTable.ENTITY_ID + " = S." + DBConstants.SharingTable.ENTITY_ID + " AND " + + "E." + DBConstants.EntityTable.DOMAIN_ID + " = S." + DBConstants.SharingTable.DOMAIN_ID + " AND " + + "E." + DBConstants.EntityTable.DOMAIN_ID + " = '" + domainId + "' AND " + "S." + DBConstants.SharingTable.GROUP_ID + " IN(" + groupIdString + ") AND E." + DBConstants.EntityTable.ENTITY_TYPE_ID + "='" + entityTypeId + "' AND "; http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java index ed2a7e9..df22e36 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityTypeRepository.java @@ -21,11 +21,12 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.EntityTypeEntity; +import org.apache.airavata.sharing.registry.db.entities.EntityTypePK; import org.apache.airavata.sharing.registry.models.EntityType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class EntityTypeRepository extends AbstractRepository<EntityType, EntityTypeEntity, String> { +public class EntityTypeRepository extends AbstractRepository<EntityType, EntityTypeEntity, EntityTypePK> { private final static Logger logger = LoggerFactory.getLogger(EntityTypeRepository.class); public EntityTypeRepository() { http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java index 87d5d4c..ccf27cb 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java @@ -21,39 +21,37 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntity; -import org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntityPK; -import org.apache.airavata.sharing.registry.db.entities.SharingUserEntity; +import org.apache.airavata.sharing.registry.db.entities.GroupMembershipPK; +import org.apache.airavata.sharing.registry.db.entities.UserEntity; import org.apache.airavata.sharing.registry.db.entities.UserGroupEntity; import org.apache.airavata.sharing.registry.db.utils.DBConstants; import org.apache.airavata.sharing.registry.models.*; import java.util.*; -public class GroupMembershipRepository extends AbstractRepository<GroupMembership, GroupMembershipEntity, GroupMembershipEntityPK> { +public class GroupMembershipRepository extends AbstractRepository<GroupMembership, GroupMembershipEntity, GroupMembershipPK> { public GroupMembershipRepository() { super(GroupMembership.class, GroupMembershipEntity.class); } - public List<GroupMembership> getChildMembershipsOfGroup(String parentId) throws SharingRegistryException { - Map<String, String> filters = new HashMap<>(); - filters.put(DBConstants.GroupMembershipTable.PARENT_ID, parentId); - return select(filters, 0, -1); - } - - public List<User> getAllChildUsers(String groupId) throws SharingRegistryException { - String queryString = "SELECT U FROM " + SharingUserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName() + public List<User> getAllChildUsers(String domainId, String groupId) throws SharingRegistryException { + String queryString = "SELECT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName() + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = U." + DBConstants.UserTable.USER_ID + " AND " + - "gm." + DBConstants.GroupMembershipTable.PARENT_ID+"='"+groupId + "' AND gm." + DBConstants.GroupMembershipTable.CHILD_TYPE + "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = U." + DBConstants.UserTable.DOMAIN_ID + " AND " + + "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + "='" + domainId + "' AND "+ + "GM." + DBConstants.GroupMembershipTable.PARENT_ID + "='" + groupId + "' AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE + "='" + GroupChildType.USER.toString() + "'"; UserRepository userRepository = new UserRepository(); List<User> users = userRepository.select(queryString, 0, -1); return users; } - public List<UserGroup> getAllChildGroups(String groupId) throws SharingRegistryException { + public List<UserGroup> getAllChildGroups(String domainId, String groupId) throws SharingRegistryException { String queryString = "SELECT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName() + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " + + "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " + + "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"='"+domainId + "' AND "+ "GM." + DBConstants.GroupMembershipTable.PARENT_ID+"='"+groupId + "' AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE + "='" + GroupChildType.GROUP.toString() + "'"; UserGroupRepository userGroupRepository = new UserGroupRepository(); @@ -61,10 +59,11 @@ public class GroupMembershipRepository extends AbstractRepository<GroupMembershi return groups; } - public List<GroupMembership> getAllParentMembershipsForChild(String childId) throws SharingRegistryException { + public List<GroupMembership> getAllParentMembershipsForChild(String domainId, String childId) throws SharingRegistryException { List<GroupMembership> finalParentGroups = new ArrayList<>(); Map<String, String> filters = new HashMap<>(); filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId); + filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId); LinkedList<GroupMembership> temp = new LinkedList<>(); select(filters, 0, -1).stream().forEach(m -> temp.addLast(m)); while (temp.size() > 0){ @@ -76,23 +75,4 @@ public class GroupMembershipRepository extends AbstractRepository<GroupMembershi } return finalParentGroups; } - - public List<UserGroup> getAllParentGroupsForChild(String childId) throws SharingRegistryException { - List<UserGroup> finalParentGroups = new ArrayList<>(); - Map<String, String> filters = new HashMap<>(); - filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId); - LinkedList<GroupMembership> temp = new LinkedList<>(); - select(filters, 0, -1).stream().forEach(m -> temp.addLast(m)); - UserGroupRepository userGroupRepository = new UserGroupRepository(); - while (temp.size() > 0){ - GroupMembership gm = temp.pop(); - filters = new HashMap<>(); - filters.put(DBConstants.GroupMembershipTable.CHILD_ID, gm.parentId); - select(filters, 0, -1).stream().forEach(m -> temp.addLast(m)); - finalParentGroups.add(userGroupRepository.get(gm.parentId)); - } - return finalParentGroups; - } - - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java index ac092f1..62a725e 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/PermissionTypeRepository.java @@ -21,6 +21,7 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.PermissionTypeEntity; +import org.apache.airavata.sharing.registry.db.entities.PermissionTypePK; import org.apache.airavata.sharing.registry.db.utils.DBConstants; import org.apache.airavata.sharing.registry.models.SharingRegistryException; import org.apache.airavata.sharing.registry.models.PermissionType; @@ -31,7 +32,7 @@ import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.List; -public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, String> { +public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, PermissionTypePK> { private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class); public PermissionTypeRepository() { http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java index 9c30fa4..1237808 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java @@ -21,7 +21,7 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.SharingEntity; -import org.apache.airavata.sharing.registry.db.entities.SharingEntityPK; +import org.apache.airavata.sharing.registry.db.entities.SharingPK; import org.apache.airavata.sharing.registry.db.utils.DBConstants; import org.apache.airavata.sharing.registry.models.Sharing; import org.apache.airavata.sharing.registry.models.SharingRegistryException; @@ -32,15 +32,16 @@ import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.List; -public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingEntityPK> { +public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingPK> { private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class); public SharingRepository() { super(Sharing.class, SharingEntity.class); } - public List<Sharing> getIndirectSharedChildren(String parentId, String permissionTypeId) throws SharingRegistryException { + public List<Sharing> getIndirectSharedChildren(String domainId, String parentId, String permissionTypeId) throws SharingRegistryException { HashMap<String, String> filters = new HashMap<>(); + filters.put(DBConstants.SharingTable.DOMAIN_ID, domainId); filters.put(DBConstants.SharingTable.INHERITED_PARENT_ID, parentId); filters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString()); filters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId); @@ -48,11 +49,10 @@ public class SharingRepository extends AbstractRepository<Sharing, SharingEntity return select(filters, 0, -1); } - public List<Sharing> getCascadingPermissionsForEntity(String entityId) throws SharingRegistryException { - HashMap<String, String> filters = new HashMap<>(); - filters.put(DBConstants.SharingTable.ENTITY_ID, entityId); + public List<Sharing> getCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException { String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p"; query += " WHERE "; + query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = '" + domainId + "' AND "; query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND "; query += "p." + DBConstants.SharingTable.SHARING_TYPE + " IN('" + SharingType.DIRECT_CASCADING.toString() + "', '" + SharingType.INDIRECT_CASCADING + "') "; @@ -60,9 +60,10 @@ public class SharingRepository extends AbstractRepository<Sharing, SharingEntity return select(query, 0, -1); } - public boolean hasAccess(String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException { + public boolean hasAccess(String domainId, String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException { String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p"; query += " WHERE "; + query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = '" + domainId + "' AND "; query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND "; String permissionTypeIdString = "'"; for(String permissionId : permissionTypeIds) http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/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 1ed1f06..c86bb22 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 @@ -22,6 +22,7 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.SharingEntity; import org.apache.airavata.sharing.registry.db.entities.UserGroupEntity; +import org.apache.airavata.sharing.registry.db.entities.UserGroupPK; import org.apache.airavata.sharing.registry.db.utils.DBConstants; import org.apache.airavata.sharing.registry.models.GroupCardinality; import org.apache.airavata.sharing.registry.models.SharingRegistryException; @@ -31,17 +32,19 @@ import org.slf4j.LoggerFactory; import java.util.List; -public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, String> { +public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, UserGroupPK> { private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class); public UserGroupRepository() { super(UserGroup.class, UserGroupEntity.class); } - public List<UserGroup> getAccessibleGroups(String entityId, String permissionTypeId) throws SharingRegistryException { + public List<UserGroup> getAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException { String query = "SELECT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s"; query += " WHERE "; query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND "; + query += "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 + " = '" + permissionTypeId + "' AND "; query += "g." + DBConstants.UserGroupTable.GROUP_CARDINALITY + " = '" + GroupCardinality.MULTI_USER.toString() + "'"; http://git-wip-us.apache.org/repos/asf/airavata/blob/b6e07d7b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java ---------------------------------------------------------------------- diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java index 845c0b9..6df5d70 100644 --- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java +++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java @@ -22,7 +22,8 @@ package org.apache.airavata.sharing.registry.db.repositories; import org.apache.airavata.sharing.registry.db.entities.SharingEntity; -import org.apache.airavata.sharing.registry.db.entities.SharingUserEntity; +import org.apache.airavata.sharing.registry.db.entities.UserEntity; +import org.apache.airavata.sharing.registry.db.entities.UserPK; import org.apache.airavata.sharing.registry.db.utils.DBConstants; import org.apache.airavata.sharing.registry.models.SharingRegistryException; import org.apache.airavata.sharing.registry.models.User; @@ -31,18 +32,20 @@ import org.slf4j.LoggerFactory; import java.util.List; -public class UserRepository extends AbstractRepository<User, SharingUserEntity, String> { +public class UserRepository extends AbstractRepository<User, UserEntity, UserPK> { private final static Logger logger = LoggerFactory.getLogger(UserRepository.class); public UserRepository() { - super(User.class, SharingUserEntity.class); + super(User.class, UserEntity.class); } - public List<User> getAccessibleUsers(String entityId, String permissionTypeId) throws SharingRegistryException { - String query = "SELECT u from " + SharingUserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s"; + public List<User> getAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException { + String query = "SELECT u from " + UserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s"; query += " WHERE "; query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND "; + query += "u." + DBConstants.UserTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND "; + query += "u." + DBConstants.UserTable.DOMAIN_ID + " = '" + domainId + "' AND "; query += "s." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND "; query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = '" + permissionTypeId + "'"; query += " ORDER BY s.createdTime DESC";