Search in sources :

Example 1 with PermissionsChangedEvent

use of edu.stanford.bmir.protege.web.shared.permissions.PermissionsChangedEvent 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);
    });
}
Also used : PermissionsChangedEvent(edu.stanford.bmir.protege.web.shared.permissions.PermissionsChangedEvent) GetProjectPermissionsAction(edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsAction) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) UserIdProjectIdKey(edu.stanford.bmir.protege.web.shared.user.UserIdProjectIdKey)

Aggregations

GetProjectPermissionsAction (edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsAction)1 PermissionsChangedEvent (edu.stanford.bmir.protege.web.shared.permissions.PermissionsChangedEvent)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 UserIdProjectIdKey (edu.stanford.bmir.protege.web.shared.user.UserIdProjectIdKey)1