use of edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings in project webprotege by protegeproject.
the class SharingSettingsPresenter method applyChangesAndGoToNextPlace.
private void applyChangesAndGoToNextPlace() {
nextPlace.ifPresent(placeController::goTo);
ProjectSharingSettings settings = new ProjectSharingSettings(projectId, view.getLinkSharingPermission(), view.getSharingSettings());
dispatchServiceManager.execute(new SetProjectSharingSettingsAction(settings), new DispatchServiceCallbackWithProgressDisplay<SetProjectSharingSettingsResult>() {
@Override
public void handleSuccess(SetProjectSharingSettingsResult result) {
permissionManager.firePermissionsChanged();
}
@Override
public String getProgressDisplayTitle() {
return "Updating sharing settings";
}
@Override
public String getProgressDisplayMessage() {
return "Please wait";
}
});
}
use of edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings 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);
}
use of edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings in project webprotege by protegeproject.
the class SharingSettingsPresenter method displaySharingSettings.
private void displaySharingSettings(AcceptsOneWidget container) {
dispatchServiceManager.execute(new GetProjectSharingSettingsAction(projectId), result -> {
ProjectSharingSettings settings = result.getProjectSharingSettings();
view.setApplyChangesHandler(this::applyChangesAndGoToNextPlace);
view.setCancelHandler(this::cancelChangesAndGoToNextPlace);
view.setLinkSharingPermission(settings.getLinkSharingPermission());
view.setSharingSettings(settings.getSharingSettings());
container.setWidget(view);
});
activeProjectManager.getActiveProjectDetails(projectDetails -> {
String displayName = projectDetails.map(ProjectDetails::getDisplayName).orElse("");
view.setProjectTitle(displayName);
});
}
use of edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings 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