io.vertx.reactivex.ext.web.client.WebClient.getAbs()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中io.vertx.reactivex.ext.web.client.WebClient.getAbs()方法的一些代码示例,展示了WebClient.getAbs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getAbs()方法的具体详情如下:
包路径:io.vertx.reactivex.ext.web.client.WebClient
类名称:WebClient
方法名:getAbs

WebClient.getAbs介绍

暂无

代码示例

代码示例来源:origin: nemtech/nem2-sdk-java

public Observable<NetworkType> getNetworkType() {
    return this.client
        .getAbs(this.url.toString())
        .as(BodyCodec.jsonObject())
        .rxSend()
        .toObservable()
        .map(Http::mapJsonObjectOrError)
        .map(json -> json.getString("name"))
        .map(name -> {
          if (name.equalsIgnoreCase("mijinTest"))
            return NetworkType.MIJIN_TEST;
          else {
            throw new IllegalArgumentException("network " + name + " is not supported yet by the sdk");
          }
        });
  }
}

代码示例来源:origin: nemtech/nem2-sdk-java

public Observable<BigInteger> getBlockchainScore() {
  return this.client
      .getAbs(this.url + "/chain/score")
      .as(BodyCodec.jsonObject())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonObjectOrError)
      .map(json -> objectMapper.readValue(json.toString(), BlockchainScoreDTO.class))
      .map(blockchainScoreDTO -> blockchainScoreDTO.extractIntArray());
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<Transaction> getTransaction(String transactionHash) {
  return this.client
      .getAbs(this.url + transactionHash)
      .as(BodyCodec.jsonObject())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonObjectOrError)
      .map(json -> new JsonObject(json.toString()))
      .map(new TransactionMapping());
}

代码示例来源:origin: nemtech/nem2-sdk-java

private Observable<List<Transaction>> getBlockTransactions(BigInteger height, Optional<QueryParams> queryParams) {
  return this.client
      .getAbs(this.url + "/block/" + height + "/transactions" + (queryParams.isPresent() ? queryParams.get().toUrl() : ""))
      .as(BodyCodec.jsonArray())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonArrayOrError)
      .map(json -> new JsonArray(json.toString()).stream().map(s -> (JsonObject) s).collect(Collectors.toList()))
      .flatMapIterable(item -> item)
      .map(new TransactionMapping())
      .toList()
      .toObservable();
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<BigInteger> getBlockchainHeight() {
  return this.client
      .getAbs(this.url + "/chain/height")
      .as(BodyCodec.jsonObject())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonObjectOrError)
      .map(json -> objectMapper.readValue(json.toString(), HeightDTO.class))
      .map(blockchainHeight -> blockchainHeight.getHeight().extractIntArray());
}

代码示例来源:origin: nemtech/nem2-sdk-java

private Observable<List<Transaction>> findTransactions(PublicAccount publicAccount, Optional<QueryParams> queryParams, String path) {
  return this.client
      .getAbs(this.url + publicAccount.getPublicKey() + path + (queryParams.isPresent() ? queryParams.get().toUrl() : ""))
      .as(BodyCodec.jsonArray())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonArrayOrError)
      .map(json -> new JsonArray(json.toString()).stream().map(s -> (JsonObject) s).collect(Collectors.toList()))
      .flatMapIterable(item -> item)
      .map(new TransactionMapping())
      .toList()
      .toObservable();
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<MultisigAccountInfo> getMultisigAccountInfo(Address address) {
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .getAbs(this.url + address.plain() + "/multisig")
          .as(BodyCodec.jsonObject())
          .rxSend()
          .toObservable()
          .map(Http::mapJsonObjectOrError)
          .map(json -> objectMapper.readValue(json.toString(), MultisigAccountInfoDTO.class))
          .map(MultisigAccountInfoDTO::getMultisig)
          .map(transfromMultisigAccountInfoDTO(networkType)));
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
  public Observable<BlockchainStorageInfo> getBlockchainStorage() {
    return this.client
        .getAbs(this.url + "/diagnostic/storage")
        .as(BodyCodec.jsonObject())
        .rxSend()
        .toObservable()
        .map(Http::mapJsonObjectOrError)
        .map(json -> objectMapper.readValue(json.toString(), BlockchainStorageInfoDTO.class))
        .map(blockchainStorageInfoDTO -> new BlockchainStorageInfo(blockchainStorageInfoDTO.getNumAccounts(),
            blockchainStorageInfoDTO.getNumBlocks(),
            blockchainStorageInfoDTO.getNumBlocks()));
  }
}

代码示例来源:origin: tsegismont/vertx-musicstore

private Single<Buffer> sendGetRequest(String mbAlbumId) {
 return webClient
  .getAbs("http://coverartarchive.org")
  .uri("/release/" + mbAlbumId + "/front")
  .as(BodyCodec.buffer())
  .rxSend()
  .map(HttpResponse::body);
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<TransactionStatus> getTransactionStatus(String transactionHash) {
  return this.client
      .getAbs(this.url + transactionHash + "/status")
      .as(BodyCodec.jsonObject())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonObjectOrError)
      .map(json -> objectMapper.readValue(json.toString(), TransactionStatusDTO.class))
      .map(transactionStatusDTO -> new TransactionStatus(transactionStatusDTO.getGroup(),
          transactionStatusDTO.getStatus(),
          transactionStatusDTO.getHash(),
          new Deadline(transactionStatusDTO.getDeadline().extractIntArray()),
          transactionStatusDTO.getHeight().extractIntArray()));
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<AccountInfo> getAccountInfo(Address address) {
  return this.client
      .getAbs(this.url + address.plain())
      .as(BodyCodec.jsonObject())
      .rxSend()
      .toObservable()
      .map(Http::mapJsonObjectOrError)
      .map(json -> objectMapper.readValue(json.toString(), AccountInfoDTO.class))
      .map(AccountInfoDTO::getAccount)
      .map(accountDTO -> new AccountInfo(Address.createFromRawAddress(accountDTO.getAddressEncoded()),
          accountDTO.getAddressHeight().extractIntArray(),
          accountDTO.getPublicKey(),
          accountDTO.getPublicKeyHeight().extractIntArray(),
          accountDTO.getImportance().extractIntArray(),
          accountDTO.getImportanceHeight().extractIntArray(),
          accountDTO.getMosaics().stream().map(mosaicDTO -> new Mosaic(
              new MosaicId(mosaicDTO.getId().extractIntArray()),
              mosaicDTO.getAmount().extractIntArray()
          )).collect(Collectors.toList())));
}

代码示例来源:origin: io.gravitee.am.gateway.handlers/gravitee-am-gateway-handler

@Override
public Maybe<JWKSet> getKeys(String jwksUri) {
  try{
    return client.getAbs(UriBuilder.fromHttpUrl(jwksUri).build().toString())
        .rxSend()
        .map(HttpResponse::bodyAsString)
        .map(new JWKSetDeserializer()::convert)
        .flatMapMaybe(jwkSet -> {
          if(jwkSet!=null && jwkSet.isPresent()) {
            return Maybe.just(jwkSet.get());
          }
          return Maybe.empty();
        })
        .onErrorResumeNext(Maybe.error(new InvalidClientMetadataException("Unable to parse jwks from : " + jwksUri)));
  }
  catch(IllegalArgumentException | URISyntaxException ex) {
    return Maybe.error(new InvalidClientMetadataException(jwksUri+" is not valid."));
  }
  catch(InvalidClientMetadataException ex) {
    return Maybe.error(ex);
  }
}

代码示例来源:origin: gravitee-io/graviteeio-access-management

@Override
public Maybe<JWKSet> getKeys(String jwksUri) {
  try{
    return client.getAbs(UriBuilder.fromHttpUrl(jwksUri).build().toString())
        .rxSend()
        .map(HttpResponse::bodyAsString)
        .map(new JWKSetDeserializer()::convert)
        .flatMapMaybe(jwkSet -> {
          if(jwkSet!=null && jwkSet.isPresent()) {
            return Maybe.just(jwkSet.get());
          }
          return Maybe.empty();
        })
        .onErrorResumeNext(Maybe.error(new InvalidClientMetadataException("Unable to parse jwks from : " + jwksUri)));
  }
  catch(IllegalArgumentException | URISyntaxException ex) {
    return Maybe.error(new InvalidClientMetadataException(jwksUri+" is not valid."));
  }
  catch(InvalidClientMetadataException ex) {
    return Maybe.error(ex);
  }
}

代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-github

private Maybe<User> profile(String accessToken) {
  return client.getAbs(configuration.getUserProfileUri())
      .putHeader(HttpHeaders.AUTHORIZATION, "token " + accessToken)
      .rxSend()
      .toMaybe()
      .map(httpClientResponse -> {
        if (httpClientResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpClientResponse.statusMessage());
        }
        return createUser(httpClientResponse.bodyAsJsonObject());
      });
}

代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-oauth2-generic

private Maybe<User> profile(String accessToken) {
  return client.getAbs(configuration.getUserProfileUri())
      .putHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)
      .rxSend()
      .toMaybe()
      .map(httpClientResponse -> {
        if (httpClientResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpClientResponse.statusMessage());
        }
        return createUser(httpClientResponse.bodyAsJsonObject());
      });
}

代码示例来源:origin: gravitee-io/graviteeio-access-management

private Maybe<User> profile(String accessToken) {
  return client.getAbs(configuration.getUserProfileUri())
      .putHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)
      .rxSend()
      .toMaybe()
      .map(httpClientResponse -> {
        if (httpClientResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpClientResponse.statusMessage());
        }
        return createUser(httpClientResponse.bodyAsJsonObject());
      });
}

代码示例来源:origin: gravitee-io/graviteeio-access-management

private Maybe<User> profile(String accessToken) {
  return client.getAbs(configuration.getUserProfileUri())
      .putHeader(HttpHeaders.AUTHORIZATION, "token " + accessToken)
      .rxSend()
      .toMaybe()
      .map(httpClientResponse -> {
        if (httpClientResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpClientResponse.statusMessage());
        }
        return createUser(httpClientResponse.bodyAsJsonObject());
      });
}

代码示例来源:origin: nemtech/nem2-sdk-java

private Observable<List<MosaicInfo>> getMosaicsFromNamespace(NamespaceId namespaceId, Optional<QueryParams> queryParams) {
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .getAbs(this.url + "/namespace/" + UInt64.bigIntegerToHex(namespaceId.getId()) + "/mosaics" + (queryParams.isPresent() ? queryParams.get().toUrl() : ""))
          .as(BodyCodec.jsonArray())
          .rxSend()
          .toObservable()
          .map(Http::mapJsonArrayOrError)
          .map(json -> objectMapper.<List<MosaicInfoDTO>>readValue(json.toString(), new TypeReference<List<MosaicInfoDTO>>() {
          }))
          .flatMapIterable(item -> item)
          .map(mosaicInfoDTO -> new MosaicInfo(mosaicInfoDTO.getMeta().isActive(),
              mosaicInfoDTO.getMeta().getIndex(),
              mosaicInfoDTO.getMeta().getId(),
              new NamespaceId(mosaicInfoDTO.getMosaic().getNamespaceId().extractIntArray()),
              new MosaicId(mosaicInfoDTO.getMosaic().getMosaicId().extractIntArray()),
              mosaicInfoDTO.getMosaic().getSupply().extractIntArray(),
              mosaicInfoDTO.getMosaic().getHeight().extractIntArray(),
              new PublicAccount(mosaicInfoDTO.getMosaic().getOwner(), networkType),
              extractMosaicProperties(mosaicInfoDTO.getMosaic().getProperties())
          ))
          .toList()
          .toObservable());
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<NamespaceInfo> getNamespace(NamespaceId namespaceId) {
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .getAbs(this.url + "/namespace/" + UInt64.bigIntegerToHex(namespaceId.getId()))
          .as(BodyCodec.jsonObject())
          .rxSend()
          .toObservable()
          .map(Http::mapJsonObjectOrError)
          .map(json -> objectMapper.readValue(json.toString(), NamespaceInfoDTO.class))
          .map(namespaceInfoDTO -> new NamespaceInfo(namespaceInfoDTO.getMeta().isActive(),
              namespaceInfoDTO.getMeta().getIndex(),
              namespaceInfoDTO.getMeta().getId(),
              NamespaceType.rawValueOf(namespaceInfoDTO.getNamespace().getType()),
              namespaceInfoDTO.getNamespace().getDepth(),
              extractLevels(namespaceInfoDTO),
              new NamespaceId(namespaceInfoDTO.getNamespace().getParentId().extractIntArray()),
              new PublicAccount(namespaceInfoDTO.getNamespace().getOwner(), networkType),
              namespaceInfoDTO.getNamespace().getStartHeight().extractIntArray(),
              namespaceInfoDTO.getNamespace().getEndHeight().extractIntArray()
          )));
}

代码示例来源:origin: nemtech/nem2-sdk-java

@Override
public Observable<MosaicInfo> getMosaic(MosaicId mosaicId) {
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .getAbs(this.url + "/mosaic/" + UInt64.bigIntegerToHex(mosaicId.getId()))
          .as(BodyCodec.jsonObject())
          .rxSend()
          .toObservable()
          .map(Http::mapJsonObjectOrError)
          .map(json -> objectMapper.readValue(json.toString(), MosaicInfoDTO.class))
          .map(mosaicInfoDTO -> new MosaicInfo(mosaicInfoDTO.getMeta().isActive(),
              mosaicInfoDTO.getMeta().getIndex(),
              mosaicInfoDTO.getMeta().getId(),
              new NamespaceId(mosaicInfoDTO.getMosaic().getNamespaceId().extractIntArray()),
              new MosaicId(mosaicInfoDTO.getMosaic().getMosaicId().extractIntArray()),
              mosaicInfoDTO.getMosaic().getSupply().extractIntArray(),
              mosaicInfoDTO.getMosaic().getHeight().extractIntArray(),
              new PublicAccount(mosaicInfoDTO.getMosaic().getOwner(), networkType),
              extractMosaicProperties(mosaicInfoDTO.getMosaic().getProperties())
          )));
}

相关文章