use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.
the class UserInSessionEncoder method encode.
@Override
public JsonObject encode(UserInSession object) {
UserDetails userDetails = object.getUserDetails();
JsonArrayBuilder actionArray = Json.createArrayBuilder();
object.getAllowedApplicationActions().stream().map(a -> a.getId()).forEach(a -> actionArray.add(a));
return Json.createObjectBuilder().add(USER_NAME, userDetails.getUserId().getUserName()).add(DISPLAY_NAME, userDetails.getDisplayName()).add(USER_EMAIL, userDetails.getEmailAddress().orElse("")).add(APPLICATION_ACTIONS, actionArray).build();
}
use of edu.stanford.bmir.protege.web.shared.app.UserInSession 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);
}
use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.
the class GetCurrentUserInSessionActionHandler method execute.
@Nonnull
@Override
public GetCurrentUserInSessionResult execute(@Nonnull GetCurrentUserInSessionAction action, @Nonnull ExecutionContext executionContext) {
UserId userId = executionContext.getUserId();
UserInSession userInSession = userInSessionFactory.getUserInSession(userId);
return new GetCurrentUserInSessionResult(userInSession);
}
Aggregations