Search in sources :

Example 1 with Subject.forUser

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);
}
Also used : Subject(edu.stanford.bmir.protege.web.server.access.Subject) java.util(java.util) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) RoleId(edu.stanford.bmir.protege.web.shared.access.RoleId) Collections.emptySet(java.util.Collections.emptySet) Subject.forUser(edu.stanford.bmir.protege.web.server.access.Subject.forUser) LoggerFactory(org.slf4j.LoggerFactory) PersonId(edu.stanford.bmir.protege.web.shared.sharing.PersonId) SharingSetting(edu.stanford.bmir.protege.web.shared.sharing.SharingSetting) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) Collectors.toMap(java.util.stream.Collectors.toMap) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) Subject.forAnySignedInUser(edu.stanford.bmir.protege.web.server.access.Subject.forAnySignedInUser) SharingPermission(edu.stanford.bmir.protege.web.shared.sharing.SharingPermission) HasGetUserIdByUserIdOrEmail(edu.stanford.bmir.protege.web.server.user.HasGetUserIdByUserIdOrEmail) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) ProjectSharingSettings(edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings) SharingPermission(edu.stanford.bmir.protege.web.shared.sharing.SharingPermission) ProjectSharingSettings(edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings) SharingSetting(edu.stanford.bmir.protege.web.shared.sharing.SharingSetting) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) RoleId(edu.stanford.bmir.protege.web.shared.access.RoleId) Subject(edu.stanford.bmir.protege.web.server.access.Subject)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 ProjectResource (edu.stanford.bmir.protege.web.server.access.ProjectResource)1 Subject (edu.stanford.bmir.protege.web.server.access.Subject)1 Subject.forAnySignedInUser (edu.stanford.bmir.protege.web.server.access.Subject.forAnySignedInUser)1 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)1 HasGetUserIdByUserIdOrEmail (edu.stanford.bmir.protege.web.server.user.HasGetUserIdByUserIdOrEmail)1 RoleId (edu.stanford.bmir.protege.web.shared.access.RoleId)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 PersonId (edu.stanford.bmir.protege.web.shared.sharing.PersonId)1 ProjectSharingSettings (edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings)1 SharingPermission (edu.stanford.bmir.protege.web.shared.sharing.SharingPermission)1 SharingSetting (edu.stanford.bmir.protege.web.shared.sharing.SharingSetting)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 java.util (java.util)1 Collections.emptySet (java.util.Collections.emptySet)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Inject (javax.inject.Inject)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1