use of edu.stanford.bmir.protege.web.server.access.Subject.forUser in project webprotege by protegeproject.
the class ProjectSharingSettingsManagerImpl method getProjectSharingSettings.
@Override
public ProjectSharingSettings getProjectSharingSettings(ProjectId projectId) {
List<SharingSetting> sharingSettings = new ArrayList<>();
ProjectResource projectResource = new ProjectResource(projectId);
Collection<Subject> subjects = accessManager.getSubjectsWithAccessToResource(projectResource);
subjects.stream().filter(s -> !s.isGuest()).filter(s -> s.getUserName().isPresent()).map(s -> UserId.getUserId(s.getUserName().get())).forEach(u -> {
Collection<RoleId> roles = accessManager.getAssignedRoles(Subject.forUser(u), projectResource);
Roles.toSharingPermission(roles).ifPresent(p -> sharingSettings.add(new SharingSetting(PersonId.of(u), p)));
});
Collection<RoleId> signedInUserRoles = accessManager.getAssignedRoles(forAnySignedInUser(), projectResource);
Optional<SharingPermission> linkSharing = Roles.toSharingPermission(signedInUserRoles);
return new ProjectSharingSettings(projectId, linkSharing, sharingSettings);
}
Aggregations