+ private void requestAccountCreation() throws MalformedURLException, MailException, AddressException, AccountSelfManagementException, ExecutionException {
+ String emailAddress = getView().getLoginDialog().getEmail().getValue();
+ URL servletBaseUrl = VaadinServletUtilities.getServletBaseUrl();
+
+ logger.debug("UserAccountAction.REGISTER_ACCOUNT for " + servletBaseUrl + ", emailAddress:" + emailAddress);
+
+ CountDownLatch finshedSignal = new CountDownLatch(1);
+ List<Throwable> asyncException = new ArrayList<>(1);
+ ListenableFuture<Boolean> futureResult = repo.getAccountRegistrationService().emailAccountRegistrationRequest(emailAddress,
+ servletBaseUrl.toString() + "/app/" + UserAccountSelfManagementUI.PATH + "#!" + AccountRegistrationViewBean.NAME + "/%s");
+ futureResult.addCallback(
+ successFuture -> {
+ finshedSignal.countDown();
+ },
+ exception -> {
+ // possible MailException
+ asyncException.add(exception);
+ finshedSignal.countDown();
+ }
+ );
+ boolean asyncTimeout = false;
+ Boolean result = false;
+ try {
+ finshedSignal.await(2, TimeUnit.SECONDS);
+ result = futureResult.get();
+ } catch (InterruptedException e) {
+ asyncTimeout = true;
+ }
+ if(!asyncException.isEmpty()) {
+ getView().getLoginDialog().getRegisterMessageLabel()
+ .setValue("Sending the account resitration email to you has failed. Please try again later or contect the support in case this error persists.");
+ getView().getLoginDialog().getRegisterMessageLabel().setStyleName(ValoTheme.LABEL_FAILURE);
+ } else {
+ if(!asyncTimeout && result) {
+ getView().getLoginDialog().getRegisterMessageLabel().setValue("An email with with further instructions has been sent to you.");
+ getView().getLoginDialog().getRegisterMessageLabel().setStyleName(ValoTheme.LABEL_SUCCESS);
+ getView().getLoginDialog().getEmail().setEnabled(false);
+ getView().getLoginDialog().getRegisterButton().setEnabled(false);
+
+ } else {
+ getView().getLoginDialog().getRegisterMessageLabel().setValue("A timeout has occured, please try again.");
+ getView().getLoginDialog().getRegisterMessageLabel().setStyleName(ValoTheme.LABEL_FAILURE);
+ }
+ }
+ }
+