Search in sources :

Example 6 with PermissionDeniedException

use of edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException in project webprotege by protegeproject.

the class DispatchServiceManager method handleError.

private void handleError(final Throwable throwable, final Action<?> action, final DispatchServiceCallback<?> callback) {
    if (throwable instanceof PermissionDeniedException) {
        // Try to determine if the user is logged in.  The session might have expired.
        UserInSession userInSession = ((PermissionDeniedException) throwable).getUserInSession();
        if (userInSession.isGuest()) {
            // Set up next place
            Place continueTo = placeController.getWhere();
            loggedInUser.setLoggedInUser(userInSession);
            GWT.log("[Dispatch] Permission denied.  User is the guest user so redirecting to login.");
            signInRequiredHandler.handleSignInRequired(continueTo);
        }
    }
    // Skip handling for actions that do not care about errors
    if (action instanceof InvocationExceptionTolerantAction) {
        Optional<String> errorMessage = ((InvocationExceptionTolerantAction) action).handleInvocationException((InvocationException) throwable);
        errorMessage.ifPresent(this::displayAlert);
        return;
    }
    callback.onFailure(throwable);
}
Also used : PermissionDeniedException(edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException) UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession) Place(com.google.gwt.place.shared.Place)

Aggregations

PermissionDeniedException (edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException)6 UserInSession (edu.stanford.bmir.protege.web.shared.app.UserInSession)3 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 Test (org.junit.Test)2 Place (com.google.gwt.place.shared.Place)1 ProjectResource (edu.stanford.bmir.protege.web.server.access.ProjectResource)1 Subject (edu.stanford.bmir.protege.web.server.access.Subject)1 EventTranslatorManager (edu.stanford.bmir.protege.web.server.events.EventTranslatorManager)1 RenameMap (edu.stanford.bmir.protege.web.server.owlapi.RenameMap)1 Revision (edu.stanford.bmir.protege.web.server.revision.Revision)1 ProjectEvent (edu.stanford.bmir.protege.web.shared.event.ProjectEvent)1 CreateNewProjectResult (edu.stanford.bmir.protege.web.shared.project.CreateNewProjectResult)1 HasProjectId (edu.stanford.bmir.protege.web.shared.project.HasProjectId)1 NewProjectSettings (edu.stanford.bmir.protege.web.shared.project.NewProjectSettings)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)1 OWLOntologyStorageException (org.semanticweb.owlapi.model.OWLOntologyStorageException)1 OWLObjectDuplicator (org.semanticweb.owlapi.util.OWLObjectDuplicator)1