use of edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsAction in project webprotege by protegeproject.
the class PermissionManager method firePermissionsChanged.
/**
* Fires a {@link PermissionsChangedEvent} for the
* current project on the event bus.
*/
public void firePermissionsChanged() {
GWT.log("[PermissionManager] Firing permissions changed");
permittedActionCache.clear();
final UserId userId = loggedInUserProvider.getCurrentUserId();
final Optional<ProjectId> projectId = activeProjectManager.getActiveProjectId();
if (!projectId.isPresent()) {
return;
}
final ProjectId theProjectId = projectId.get();
dispatchServiceManager.execute(new GetProjectPermissionsAction(projectId.get(), userId), result -> {
UserIdProjectIdKey key = new UserIdProjectIdKey(userId, theProjectId);
permittedActionCache.putAll(key, result.getAllowedActions());
GWT.log("[PermissionManager] Firing permissions changed for project: " + projectId);
eventBus.fireEventFromSource(new PermissionsChangedEvent(theProjectId).asGWTEvent(), theProjectId);
});
}
use of edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsAction in project webprotege by protegeproject.
the class PermissionManager method hasPermissionForProject.
/**
* Determines if the specified user has permission to execute the specified action on the
* specified project.
* @param userId The {@link UserId} to test for.
* @param actionId The {@link ActionId} to test for.
* @param projectId The {@link ProjectId} to test for.
* @param callback A callback for receiving the result.
*/
public void hasPermissionForProject(@Nonnull UserId userId, @Nonnull ActionId actionId, @Nonnull ProjectId projectId, @Nonnull DispatchServiceCallback<Boolean> callback) {
final UserIdProjectIdKey key = new UserIdProjectIdKey(userId, projectId);
if (permittedActionCache.containsKey(key)) {
callback.onSuccess(permittedActionCache.get(key).contains(actionId));
return;
}
dispatchServiceManager.execute(new GetProjectPermissionsAction(projectId, userId), new DispatchServiceCallback<GetProjectPermissionsResult>() {
@Override
public void handleSuccess(GetProjectPermissionsResult result) {
permittedActionCache.putAll(key, result.getAllowedActions());
callback.onSuccess(result.getAllowedActions().contains(actionId));
}
@Override
public void handleErrorFinally(Throwable throwable) {
callback.handleErrorFinally(throwable);
}
});
}
Aggregations