use of edu.stanford.bmir.protege.web.shared.sharing.PersonId in project webprotege by protegeproject.
the class GetPersonIdItemsActionHandler_TestCase method shouldOnlyMatchExact.
@Test
public void shouldOnlyMatchExact() {
when(action.getItemNames()).thenReturn(Arrays.asList("John Smith"));
GetPersonIdItemsResult result = actionHandler.execute(action, mock(ExecutionContext.class));
assertThat(result.getItems(), hasItems(new PersonId(johnSmith_UpperCase.getUserName())));
}
use of edu.stanford.bmir.protege.web.shared.sharing.PersonId in project webprotege by protegeproject.
the class ProjectSharingSettingsManagerImpl method setProjectSharingSettings.
@Override
public void setProjectSharingSettings(ProjectSharingSettings settings) {
ProjectId projectId = settings.getProjectId();
ProjectResource projectResource = new ProjectResource(projectId);
// Remove existing assignments
accessManager.getSubjectsWithAccessToResource(projectResource).forEach(subject -> accessManager.setAssignedRoles(subject, projectResource, Collections.emptySet()));
Map<PersonId, SharingSetting> map = settings.getSharingSettings().stream().collect(toMap(SharingSetting::getPersonId, s -> s, (s1, s2) -> s1));
Optional<SharingPermission> linkSharingPermission = settings.getLinkSharingPermission();
linkSharingPermission.ifPresent(permission -> {
Collection<RoleId> roleId = Roles.fromSharingPermission(permission);
accessManager.setAssignedRoles(forAnySignedInUser(), projectResource, roleId);
});
if (!linkSharingPermission.isPresent()) {
accessManager.setAssignedRoles(forAnySignedInUser(), projectResource, emptySet());
}
for (SharingSetting setting : map.values()) {
PersonId personId = setting.getPersonId();
Optional<UserId> userId = userLookup.getUserByUserIdOrEmail(personId.getId());
if (userId.isPresent()) {
ImmutableSet<RoleId> roles = Roles.fromSharingPermission(setting.getSharingPermission());
accessManager.setAssignedRoles(forUser(userId.get()), projectResource, roles);
} else {
logger.info("User in sharing setting not found. An email invitation needs to be sent");
// TODO
// We need to send the user an email invitation
}
}
}
Aggregations