use of io.hops.hopsworks.common.dao.kafka.AclUser in project hopsworks by logicalclocks.
the class KafkaController method getTopicAclUsers.
public List<AclUser> getTopicAclUsers(Project project, String topicName) {
if (project == null || Strings.isNullOrEmpty(topicName)) {
throw new IllegalArgumentException("ProjectId must be non-null, topic must be provided");
}
List<AclUser> aclUsers = new ArrayList<>();
List<String> teamMembers = new ArrayList<>();
for (ProjectTeam pt : project.getProjectTeamCollection()) {
teamMembers.add(pt.getUser().getEmail());
}
// wildcard used for rolebased acl
teamMembers.add("*");
// contains project and its members
Map<String, List<String>> projectMemberCollections = new HashMap<>();
projectMemberCollections.put(project.getName(), teamMembers);
// get all the projects this topic is shared with
List<SharedTopics> sharedTopicsList = sharedTopicsFacade.findSharedTopicsByTopicName(topicName);
List<String> sharedMembers;
for (SharedTopics st : sharedTopicsList) {
sharedMembers = new ArrayList<>();
Project p = projectFacade.find(st.getSharedTopicsPK().getProjectId());
for (ProjectTeam pt : p.getProjectTeamCollection()) {
sharedMembers.add(pt.getUser().getEmail());
}
sharedMembers.add("*");
projectMemberCollections.put(p.getName(), sharedMembers);
}
for (Map.Entry<String, List<String>> user : projectMemberCollections.entrySet()) {
aclUsers.add(new AclUser(user.getKey(), new HashSet<>(user.getValue())));
}
return aclUsers;
}
use of io.hops.hopsworks.common.dao.kafka.AclUser in project hopsworks by logicalclocks.
the class AclBuilder method buildAclUser.
public AclUserDTO buildAclUser(UriInfo uriInfo, Project project, String topicName) {
AclUserDTO dto = new AclUserDTO();
URI uri = getAclUserUri(uriInfo, project, topicName).build();
dto.setHref(uri);
List<AclUser> list = kafkaController.getTopicAclUsers(project, topicName);
dto.setCount(Integer.toUnsignedLong(list.size()));
list.forEach((aclUser) -> dto.addItem(build((AclUser) aclUser)));
return dto;
}
Aggregations