Example usage for io.vertx.core Future succeededFuture

List of usage examples for io.vertx.core Future succeededFuture

Introduction

In this page you can find the example usage for io.vertx.core Future succeededFuture.

Prototype

static <T> Future<T> succeededFuture(T result) 

Source Link

Document

Created a succeeded future with the specified result.

Usage

From source file:de.braintags.netrelay.controller.authentication.PasswordLostController.java

License:Open Source License

private void createPasswordLostClaim(RoutingContext context, String email,
        Handler<AsyncResult<PasswordLostClaim>> handler) {
    deactivatePreviousClaims(context, email, previous -> {
        if (previous.failed()) {
            handler.handle(Future.failedFuture(previous.cause()));
        } else {//from   www  .  j a va  2  s.c om
            PasswordLostClaim rc = new PasswordLostClaim(email, context.request());
            IWrite<PasswordLostClaim> write = getNetRelay().getDatastore().createWrite(PasswordLostClaim.class);
            write.add(rc);
            write.save(sr -> {
                if (sr.failed()) {
                    LOGGER.error("", sr.cause());
                    handler.handle(Future.failedFuture(sr.cause()));
                } else {
                    context.put(PasswordLostClaim.class.getSimpleName(), rc);
                    context.put(MailController.TO_PARAMETER, email);
                    context.put(VALIDATION_ID_PARAM, rc.id);
                    handler.handle(Future.succeededFuture(rc));
                }
            });
        }
    });
}

From source file:de.braintags.netrelay.controller.authentication.PasswordLostController.java

License:Open Source License

private void getUser(String email, Handler<AsyncResult<IAuthenticatable>> handler) {
    if (email == null || email.hashCode() == 0) {
        handler.handle(Future.failedFuture(PasswordLostCode.EMAIL_REQUIRED.toString()));
    } else {// w  ww .  j av  a2 s .co  m
        IQuery<? extends IAuthenticatable> query = getNetRelay().getDatastore()
                .createQuery(this.authenticatableCLass);
        query.field("email").is(email);
        QueryHelper.executeToList(query, qr -> {
            if (qr.failed()) {
                LOGGER.error("", qr.cause());
                handler.handle(Future.failedFuture(qr.cause()));
            } else {
                if (qr.result().size() == 0) {
                    handler.handle(Future.failedFuture(PasswordLostCode.NO_ACCOUNT.toString()));
                } else {
                    handler.handle(Future.succeededFuture((IAuthenticatable) qr.result().get(0)));
                }
            }
        });
    }
}

From source file:de.braintags.netrelay.controller.authentication.RegisterController.java

License:Open Source License

private void createRegisterClaim(RoutingContext context, String email, String password,
        Handler<AsyncResult<RegisterClaim>> handler) {
    deactivatePreviousClaims(context, email, previous -> {
        if (previous.failed()) {
            handler.handle(Future.failedFuture(previous.cause()));
        } else {/*from   w  ww .  j a  v a  2 s  .c om*/
            RegisterClaim rc = new RegisterClaim(email, password, context.request());
            IWrite<RegisterClaim> write = getNetRelay().getDatastore().createWrite(RegisterClaim.class);
            write.add(rc);
            write.save(sr -> {
                if (sr.failed()) {
                    LOGGER.error("", sr.cause());
                    handler.handle(Future.failedFuture(sr.cause()));
                } else {
                    context.put(RegisterClaim.class.getSimpleName(), rc);
                    context.put(MailController.TO_PARAMETER, email);
                    context.put(VALIDATION_ID_PARAM, rc.id);
                    handler.handle(Future.succeededFuture(rc));
                }
            });
        }
    });
}

From source file:de.braintags.netrelay.controller.authentication.RegisterController.java

License:Open Source License

private void checkPassword(String password, Handler<AsyncResult<RegistrationCode>> handler) {
    if (password == null || password.hashCode() == 0) {
        handler.handle(Future.failedFuture(RegistrationCode.PASSWORD_REQUIRED.toString()));
    } else {//from w  w  w  .  ja v  a  2  s  .  c  o  m
        handler.handle(Future.succeededFuture(RegistrationCode.OK));
    }
}

From source file:de.braintags.netrelay.controller.authentication.RegisterController.java

License:Open Source License

private void checkEmail(String email, Handler<AsyncResult<RegistrationCode>> handler) {
    if (email == null || email.hashCode() == 0) {
        handler.handle(Future.failedFuture(RegistrationCode.EMAIL_REQUIRED.toString()));
    } else if (!allowDuplicateEmail) {
        IQuery<? extends IAuthenticatable> query = getNetRelay().getDatastore()
                .createQuery(this.authenticatableCLass);
        query.field("email").is(email);
        query.executeCount(qr -> {//from w  w w. j a v a2 s  .  co m
            if (qr.failed()) {
                LOGGER.error("", qr.cause());
                handler.handle(Future.failedFuture(qr.cause()));
            } else {
                if (qr.result().getCount() > 0) {
                    handler.handle(Future.failedFuture(RegistrationCode.EMAIL_EXISTS.toString()));
                } else {
                    handler.handle(Future.succeededFuture(RegistrationCode.OK));
                }
            }
        });
    } else {
        handler.handle(Future.succeededFuture(RegistrationCode.OK));
    }
}

From source file:de.braintags.netrelay.controller.filemanager.elfinder.command.impl.AbstractCommand.java

License:Open Source License

private void listenerBefore(ElFinderContext efContext, Handler<AsyncResult<Boolean>> handler) {
    if (listener != null) {
        listener.before(this, efContext, handler);
    } else {/*from w w w.ja va 2s.com*/
        handler.handle(Future.succeededFuture(true));
    }
}

From source file:de.braintags.netrelay.controller.filemanager.elfinder.command.impl.AbstractCommand.java

License:Open Source License

private void listenerAfter(ElFinderContext efContext, JsonObject json, T result,
        Handler<AsyncResult<JsonObject>> handler) {
    if (listener != null) {
        listener.after(this, efContext, result, json, lr -> {
            if (lr.failed()) {
                handler.handle(Future.failedFuture(lr.cause()));
            } else {
                handler.handle(Future.succeededFuture(json));
            }//from   w w  w.j a va2 s .co m
        });
    } else {
        handler.handle(Future.succeededFuture(json));
    }
}

From source file:de.braintags.netrelay.controller.filemanager.elfinder.command.impl.AbstractCommand.java

License:Open Source License

/**
 * Create a suceeded future with the given target
 * /*from  w w  w.java2 s.  c om*/
 * @param target
 * @return
 */
protected Future<ITarget> createFuture(ITarget target) {
    return Future.succeededFuture(target);
}

From source file:de.braintags.netrelay.controller.filemanager.elfinder.command.impl.AbstractCommand.java

License:Open Source License

/**
 * Create a suceeded future with the given targets
 * /*ww w.j a  v a2 s  . com*/
 * @param targets
 * @return
 */
protected Future<List<ITarget>> createFuture(List<ITarget> targets) {
    return Future.succeededFuture(targets);
}

From source file:de.braintags.netrelay.controller.filemanager.elfinder.command.impl.AbstractCommand.java

License:Open Source License

/**
 * Create a suceeded future with the given targets
 * //from ww  w .  ja va2s  .  c  o m
 * @param targets
 * @return
 */
protected Future<Map<String, ITarget>> createFuture(Map<String, ITarget> targets) {
    return Future.succeededFuture(targets);
}