private void checkWithServerIfSessionIdIsStillLegal(final String sessionId) { AsyncCallback<String> acSessionValid = new AsyncCallback<String>() { public void onFailure(Throwable caught) { Window.alert("Error: session could not be loaded."); } public void onSuccess(String userRole) { String username = Cookies.getCookie(CookieManager.LOGGED_USERNAME); String role = Cookies.getCookie(CookieManager.LOGGED_USER_ROLE); String language = Cookies.getCookie(CookieManager.REPOX_LANGUAGE); if (language == null || language.isEmpty()) language = "en"; if (!UTIL_MANAGER.isDefaultLanguage(language) && !UtilManager.getUrlLocaleLanguage().equals(language)) Window.Location.assign(UtilManager.getServerUrl() + "?locale=" + language); else { Dispatcher.get().addController(new HistoryController()); HarvesterUI.UTIL_MANAGER.setLoggedUser(username, role); UtilManager.sendUserActivityData(); Dispatcher.forwardEvent(AppEvents.Init); Dispatcher.forwardEvent(AppEvents.ViewAccordingToRole); Window.addWindowClosingHandler( new Window.ClosingHandler() { public void onWindowClosing(Window.ClosingEvent closingEvent) { closingEvent.setMessage("Do you really want to leave the page?"); } }); } } }; userManagementService.validateSessionId(sessionId, acSessionValid); }
private void checkFirstTimeRepoxUsed() { // Check if its a first time use AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { new ServerExceptionDialog("Failed to get response from server", caught.getMessage()) .show(); } public void onSuccess(Boolean isFirst) { if (isFirst) { GXT.hideLoadingPanel("loading"); FirstTimeRepoxUsedDialog firstTimeRepoxUsedDialog = new FirstTimeRepoxUsedDialog(); firstTimeRepoxUsedDialog.show(); firstTimeRepoxUsedDialog.center(); } else { startRepoxData(); } } }; UserManagementServiceAsync userMangService = (UserManagementServiceAsync) Registry.get(USER_MANAGEMENT_SERVICE); userMangService.isFirstTimeRepoxUsed(callback); }