private void successHandler(UpdateServiceResponse response) { // remember the time of the last update check long currentTime = new Date().getTime(); propertyManager.setProperty( LAST_UPDATE_CHECK, String.valueOf(currentTime), PropertyScope.APPLICATION); if (response.getUpdate()) { eventBus.fireEventDeferred( new ErrorNotificationEvent( Level.WARNING, messages.versionUpdateMessage(response.getUpdateVersion()))); } }
private void checkForUpdate() { UrlBuilder urlBuilder; try { urlBuilder = new UrlBuilder(updateCheckUrl); } catch (IllegalArgumentException e) { eventBus.fireEventDeferred(new ErrorNotificationEvent(Level.WARNING, e.getMessage())); return; } String data = "version=" + version + "&hostSystem=" + hostSystem + "&serverVersion=" + serverVersion; data = MimeBase64.encode(data); urlBuilder.setParameter("data", URL.encodeQueryString(data)); JsonpRequestBuilder requestBuilder = new JsonpRequestBuilder(); try { requestBuilder.requestObject( urlBuilder.buildString(), new AsyncCallback<UpdateServiceResponse>() { @Override public void onFailure(Throwable caught) { errorHandler(caught.getMessage()); } @Override public void onSuccess(UpdateServiceResponse response) { successHandler(response); } }); } catch (Throwable exception) { errorHandler(exception.getMessage()); } }