List of usage examples for io.vertx.core Future succeededFuture
static <T> Future<T> succeededFuture()
From source file:de.braintags.netrelay.controller.authentication.PasswordLostController.java
License:Open Source License
private void deactivatePreviousClaims(RoutingContext context, String email, Handler<AsyncResult<Void>> handler) { IQuery<PasswordLostClaim> query = getNetRelay().getDatastore().createQuery(PasswordLostClaim.class); query.field("email").is(email).field("active").is(true); QueryHelper.executeToList(query, qr -> { if (qr.failed()) { handler.handle(Future.failedFuture(qr.cause())); } else {/*from w w w. j av a 2s. c o m*/ List<PasswordLostClaim> cl = (List<PasswordLostClaim>) qr.result(); if (!cl.isEmpty()) { IWrite<PasswordLostClaim> write = getNetRelay().getDatastore() .createWrite(PasswordLostClaim.class); cl.forEach(rc -> rc.setActive(false)); write.addAll(cl); write.save(wr -> { if (wr.failed()) { handler.handle(Future.failedFuture(wr.cause())); } else { handler.handle(Future.succeededFuture()); } }); } else { handler.handle(Future.succeededFuture()); } } }); }
From source file:de.braintags.netrelay.controller.authentication.RegisterController.java
License:Open Source License
private void deactivatePreviousClaims(RoutingContext context, String email, Handler<AsyncResult<Void>> handler) { IQuery<RegisterClaim> query = getNetRelay().getDatastore().createQuery(RegisterClaim.class); query.field("email").is(email).field("active").is(true); QueryHelper.executeToList(query, qr -> { if (qr.failed()) { handler.handle(Future.failedFuture(qr.cause())); } else {//from ww w.j ava2 s .c o m List<RegisterClaim> cl = (List<RegisterClaim>) qr.result(); if (!cl.isEmpty()) { IWrite<RegisterClaim> write = getNetRelay().getDatastore().createWrite(RegisterClaim.class); cl.forEach(rc -> rc.setActive(false)); write.addAll(cl); write.save(wr -> { if (wr.failed()) { handler.handle(Future.failedFuture(wr.cause())); } else { handler.handle(Future.succeededFuture()); } }); } else { handler.handle(Future.succeededFuture()); } } }); }
From source file:de.braintags.netrelay.controller.authentication.RegisterController.java
License:Open Source License
private void doUserLogin(RoutingContext context, IAuthenticatable user, Handler<AsyncResult<Void>> handler) { AuthProvider auth = getAuthProvider(); if (auth == null) { handler.handle(Future.succeededFuture()); } else if (auth instanceof AuthProviderProxy) { try {//from w ww . j a va2 s .co m AuthProviderProxy mAuth = (AuthProviderProxy) auth; JsonObject authInfo = getAuthObject(user, mAuth); mAuth.authenticate(authInfo, res -> { if (res.failed()) { LOGGER.warn("Unsuccessfull login", res.cause()); handler.handle(Future.failedFuture(res.cause())); } else { LOGGER.info("direct login successfull, user: " + res.result()); MemberUtil.setContextUser(context, res.result()); handler.handle(Future.succeededFuture()); } }); } catch (Exception e) { handler.handle(Future.failedFuture(e)); } } else { handler.handle(Future.failedFuture(new UnsupportedOperationException( "unsupported AuthProvider for direct login: " + auth.getClass().getName()))); } }
From source file:de.braintags.netrelay.controller.CaptureTestController.java
License:Open Source License
@Override protected void handle(RoutingContext context, List<CaptureMap> resolvedCaptureCollections, Handler<AsyncResult<Void>> handler) { CaptureTestController.resolvedCaptureCollections = resolvedCaptureCollections; handler.handle(Future.succeededFuture()); ;/*from ww w . j av a 2 s. c o m*/ }
From source file:de.braintags.netrelay.controller.CurrentMemberController.java
License:Open Source License
/** * Extensions may load additional data for the current member * //from w w w . j av a 2s . co m * @param member * the member, if logged in or null * @param context * the context of the current request * @param handler * the handler to be informed */ protected void loadMemberData(IAuthenticatable member, RoutingContext context, Handler<AsyncResult<Void>> handler) { handler.handle(Future.succeededFuture()); }
From source file:de.braintags.netrelay.controller.persistence.AbstractAction.java
License:Open Source License
@SuppressWarnings({ "rawtypes", "unchecked" }) protected void saveObjectInDatastore(Object ob, String entityName, RoutingContext context, IMapper mapper, Handler<AsyncResult<Void>> handler) { IWrite write = getPersistenceController().getNetRelay().getDatastore().createWrite(mapper.getMapperClass()); write.add(ob);/* w ww. j a va 2 s. co m*/ write.save(res -> { AsyncResult<IWriteResult> result = (AsyncResult<IWriteResult>) res; if (result.failed()) { handler.handle(Future.failedFuture(result.cause())); } else { LOGGER.info("adding new entity to context with key " + entityName); addToContext(context, entityName, ob); handler.handle(Future.succeededFuture()); } }); }
From source file:de.braintags.netrelay.controller.persistence.DeleteAction.java
License:Open Source License
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from w w w . j a v a 2s . c o m void handle(String entityName, RoutingContext context, CaptureMap captureMap, Handler<AsyncResult<Void>> handler) { IMapper mapper = getMapper(entityName); String id = captureMap.get(PersistenceController.ID_CAPTURE_KEY); IDataStore datastore = getPersistenceController().getNetRelay().getDatastore(); IDelete<?> delete = datastore.createDelete(mapper.getMapperClass()); IQuery query = getPersistenceController().getNetRelay().getDatastore().createQuery(mapper.getMapperClass()); query.field(mapper.getIdField().getName()).is(id); delete.setQuery(query); delete.delete(result -> { if (result.failed()) { handler.handle(Future.failedFuture(result.cause())); } else { handler.handle(Future.succeededFuture()); } }); }
From source file:de.braintags.netrelay.controller.persistence.DisplayAction.java
License:Open Source License
protected void handleList(String entityName, RoutingContext context, CaptureMap map, IMapper mapper, String id, Handler<AsyncResult<Void>> handler) { IQuery<?> query = getPersistenceController().getNetRelay().getDatastore() .createQuery(mapper.getMapperClass()); try {// w w w .j a v a 2s . c o m if (map.containsKey(PersistenceController.SELECTION_SIZE_CAPTURE_KEY)) { query.setLimit(Integer.parseInt(map.get(PersistenceController.SELECTION_SIZE_CAPTURE_KEY))); } if (map.containsKey(PersistenceController.SELECTION_START_CAPTURE_KEY)) { query.setStart(Integer.parseInt(map.get(PersistenceController.SELECTION_START_CAPTURE_KEY))); } if (map.containsKey(PersistenceController.ORDERBY_CAPTURE_KEY)) { addSortDefintions(query, map); } query.execute(result -> { if (result.failed()) { handler.handle(Future.failedFuture(result.cause())); } else { IQueryResult<?> qr = result.result(); qr.toArray(arr -> { if (arr.failed()) { handler.handle(Future.failedFuture(arr.cause())); } else { addToContext(context, entityName, Arrays.asList(arr.result())); handler.handle(Future.succeededFuture()); } }); } }); } catch (Exception e) { handler.handle(Future.failedFuture(e)); } }
From source file:de.braintags.netrelay.controller.persistence.DisplayAction.java
License:Open Source License
protected void handleSingleRecord(String entityName, RoutingContext context, IMapper mapper, String id, Handler<AsyncResult<Void>> handler) { IQuery<?> query = getPersistenceController().getNetRelay().getDatastore() .createQuery(mapper.getMapperClass()); query.field(mapper.getIdField().getName()).is(id); query.execute(result -> {//from w ww . j a v a2 s . co m if (result.failed()) { handler.handle(Future.failedFuture(result.cause())); } else { IQueryResult<?> qr = result.result(); if (qr.isEmpty()) { handler.handle(Future .failedFuture(new NoSuchRecordException(String.format(ERRORMESSAGE_RECNOTFOUND, id)))); } else { qr.iterator().next(ir -> { if (ir.failed()) { handler.handle(Future.failedFuture(ir.cause())); } else { addToContext(context, entityName, ir.result()); handler.handle(Future.succeededFuture()); } }); } } }); }
From source file:de.braintags.netrelay.controller.persistence.NoneAction.java
License:Open Source License
@Override void handle(String entityName, RoutingContext context, CaptureMap map, Handler<AsyncResult<Void>> handler) { handler.handle(Future.succeededFuture()); }