use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class UserInSessionDecoder method decode.
@Override
public UserInSession decode(JSONValue json) {
JSONObject object = json.isObject();
if (object == null) {
throw new RuntimeException("Expected json object");
}
JSONValue userNameValue = object.get(USER_NAME);
if (userNameValue == null) {
throw new RuntimeException("Expected userName attribute");
}
JSONString userNameStringValue = userNameValue.isString();
if (userNameStringValue == null) {
throw new RuntimeException("Expected userName value to be string");
}
String displayName = object.get(DISPLAY_NAME).isString().stringValue();
String userEmail = object.get(USER_EMAIL).isString().stringValue();
JSONArray actionArray = object.get(APPLICATION_ACTIONS).isArray();
Set<ActionId> allowedActions = new HashSet<>();
if (actionArray != null) {
for (int i = 0; i < actionArray.size(); i++) {
ActionId actionId = new ActionId(actionArray.get(i).isString().stringValue());
allowedActions.add(actionId);
}
}
UserId userId = UserId.getUserId(userNameStringValue.stringValue());
UserDetails userDetails;
if (userId.isGuest()) {
userDetails = UserDetails.getGuestUserDetails();
} else {
userDetails = UserDetails.getUserDetails(userId, displayName, userEmail);
}
return new UserInSession(userDetails, allowedActions);
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class LoginPresenter method handleSignIn.
private void handleSignIn(SignInDetails signInDetails) {
final UserId userId = UserId.getUserId(signInDetails.getUserName());
loginExecutor.execute(userId, signInDetails.getClearTextPassword(), new PerformLoginActionFactory(), new AuthenticatedDispatchServiceCallback<PerformLoginResult>() {
@Override
public void handleAuthenticationResponse(@Nonnull AuthenticationResponse authenticationResponse) {
if (authenticationResponse == AuthenticationResponse.FAIL) {
view.showLoginFailedErrorMessage();
}
}
@Override
public void handleSuccess(@Nonnull PerformLoginResult result) {
handlePerformLoginResult(result);
}
@Override
public String getProgressDisplayTitle() {
return "Logging in";
}
@Override
public String getProgressDisplayMessage() {
return "Please wait.";
}
});
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class CommentAutoCompleter method handleAutocomplete.
public void handleAutocomplete(@Nonnull String query, @Nonnull EditorPosition caretPosition, int caretPos, @Nonnull AutoCompletionCallback callback) {
String upToCarent = query.substring(0, caretPos);
MatchResult result = nameRegExp.exec(upToCarent);
if (result == null) {
handleAttemptAtEntityCompletions(upToCarent, caretPosition, callback);
} else {
String matchedPartialName = result.getGroup(NAME_GROUP);
EditorPosition replaceTextFrom = new EditorPosition(caretPosition.getLineNumber(), caretPosition.getColumnNumber() - result.getGroup(0).length());
dispatchServiceManager.execute(new GetUserIdCompletionsAction(matchedPartialName), userIdsResult -> {
List<AutoCompletionChoice> suggestions = new ArrayList<>();
List<UserId> userIds = userIdsResult.getPossibleItemCompletions();
for (UserId userId : userIds) {
String userName = userId.getUserName();
String replacement = getReplacementStringFromUserName(userName);
EditorPosition replaceTextTo = new EditorPosition(caretPosition.getLineNumber(), caretPosition.getColumnNumber());
suggestions.add(new AutoCompletionChoice(replacement, userName, "", replaceTextFrom, replaceTextTo));
}
callback.completionsReady(new AutoCompletionResult(suggestions, replaceTextFrom));
});
}
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class LoadProjectInNewWindowRequestHandlerImpl method handleLoadProjectInNewWindow.
@Override
public void handleLoadProjectInNewWindow(final ProjectId projectId) {
UserId userId = loggedInUserProvider.getCurrentUserId();
dispatchServiceManager.execute(new GetPerspectivesAction(projectId, userId), new DispatchServiceCallback<GetPerspectivesResult>() {
@Override
public void handleSuccess(GetPerspectivesResult result) {
ImmutableList<PerspectiveId> perspectives = result.getPerspectives();
handleOpenInNewWindow(perspectives, projectId);
}
});
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class LoggedInUserPresenter method updateView.
private void updateView() {
UserId user = loggedInUserProvider.getCurrentUserId();
view.setLoggedInUserName(user.getUserName());
}
Aggregations