use of edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsResult 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