Java Code Examples for io.vertx.core.Future#handle()

The following examples show how to use io.vertx.core.Future#handle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TenantLoading.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
private static String getId(LoadingEntry loadingEntry, URL url, String content,
  Future<Void> f) {

  switch (loadingEntry.strategy) {
    case BASENAME:
      return getIdBase(url.getPath(), f);
    case CONTENT:
      JsonObject jsonObject = new JsonObject(content);
      String id = jsonObject.getString(loadingEntry.idProperty);
      if (id == null) {
        log.warn("Missing property "
          + loadingEntry.idProperty + " for url=" + url.toString());
        f.handle(Future.failedFuture("Missing property "
          + loadingEntry.idProperty + " for url=" + url.toString()));
        return null;
      }
      return StringUtil.urlEncode(id);
    case RAW_PUT:
    case RAW_POST:
      break;
  }
  return null;
}
 
Example 2
Source File: TenantLoading.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
static String getIdBase(String path, Future<Void> f) {
  int base = path.lastIndexOf('/');
  int suf = path.lastIndexOf('.');
  if (base == -1) {
    f.handle(Future.failedFuture("No basename for " + path));
    return null;
  }
  if (suf > base) {
    return path.substring(base, suf);
  } else {
    return path.substring(base);
  }
}
 
Example 3
Source File: TenantLoading.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
private static void handleException(Throwable ex, String lead, Future<Void> f) {
  String diag = lead  + ": " + ex.getMessage();
  log.error(diag, ex);
  if (!f.isComplete()) {
    f.handle(Future.failedFuture(diag));
  }
}