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

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

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

WebClient.postAbs介绍

暂无

代码示例

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

@Override
public Observable<List<Transaction>> getTransactions(List<String> transactionHashes) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("transactionIds", transactionHashes);
  return this.client
      .postAbs(this.url.toString())
      .as(BodyCodec.jsonArray())
      .rxSendJson(requestBody)
      .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<List<MosaicName>> getMosaicNames(List<MosaicId> mosaicIds) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("mosaicIds", mosaicIds.stream().map(id -> UInt64.bigIntegerToHex(id.getId())).collect(Collectors.toList()));
  return this.client
      .postAbs(this.url + "/mosaic/names")
      .as(BodyCodec.jsonArray())
      .rxSendJson(requestBody)
      .toObservable()
      .map(Http::mapJsonArrayOrError)
      .map(json -> objectMapper.<List<MosaicNameDTO>>readValue(json.toString(), new TypeReference<List<MosaicNameDTO>>() {
      }))
      .flatMapIterable(item -> item)
      .map(mosaicNameDTO -> new MosaicName(new MosaicId(mosaicNameDTO.getMosaicId().extractIntArray()),
          mosaicNameDTO.getName(),
          new NamespaceId(mosaicNameDTO.getParentId().extractIntArray())))
      .toList()
      .toObservable();
}

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

private Maybe<String> authenticate(Authentication authentication) {
  // prepare body request parameters
  List<NameValuePair> urlParameters = new ArrayList<>();
  urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
  urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
  urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
  urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
  urlParameters.add(new BasicNameValuePair(GRANT_TYPE, "authorization_code"));
  String bodyRequest = URLEncodedUtils.format(urlParameters);
  return client.postAbs(configuration.getAccessTokenUri())
      .putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
      .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
      .rxSendBuffer(Buffer.buffer(bodyRequest))
      .toMaybe()
      .map(httpResponse -> {
        if (httpResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpResponse.statusMessage());
        }
        return httpResponse.bodyAsJsonObject().getString("access_token");
      });
}

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

private Maybe<String> authenticate(Authentication authentication) {
  // prepare body request parameters
  List<NameValuePair> urlParameters = new ArrayList<>();
  urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
  urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
  urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
  urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
  urlParameters.add(new BasicNameValuePair(GRANT_TYPE, "authorization_code"));
  String bodyRequest = URLEncodedUtils.format(urlParameters);
  return client.postAbs(configuration.getAccessTokenUri())
      .putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
      .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
      .rxSendBuffer(Buffer.buffer(bodyRequest))
      .toMaybe()
      .map(httpResponse -> {
        if (httpResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpResponse.statusMessage());
        }
        return httpResponse.bodyAsJsonObject().getString("access_token");
      });
}

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

private Maybe<String> authenticate(Authentication authentication) {
  // prepare body request parameters
  List<NameValuePair> urlParameters = new ArrayList<>();
  urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
  urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
  urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
  urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
  String bodyRequest = URLEncodedUtils.format(urlParameters);
  return client.postAbs(configuration.getAccessTokenUri())
      .putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
      .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
      .rxSendBuffer(Buffer.buffer(bodyRequest))
      .toMaybe()
      .map(httpResponse -> {
        if (httpResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpResponse.statusMessage());
        }
        Map<String, String> bodyResponse = URLEncodedUtils.format(httpResponse.bodyAsString());
        return bodyResponse.get("access_token");
      });
}

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

private Maybe<String> authenticate(Authentication authentication) {
  // prepare body request parameters
  List<NameValuePair> urlParameters = new ArrayList<>();
  urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
  urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
  urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
  urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
  String bodyRequest = URLEncodedUtils.format(urlParameters);
  return client.postAbs(configuration.getAccessTokenUri())
      .putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
      .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
      .rxSendBuffer(Buffer.buffer(bodyRequest))
      .toMaybe()
      .map(httpResponse -> {
        if (httpResponse.statusCode() != 200) {
          throw new BadCredentialsException(httpResponse.statusMessage());
        }
        Map<String, String> bodyResponse = URLEncodedUtils.format(httpResponse.bodyAsString());
        return bodyResponse.get("access_token");
      });
}

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

@Override
public Observable<List<AccountInfo>> getAccountsInfo(List<Address> addresses) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("addresses", addresses.stream().map(address -> address.plain()).collect(Collectors.toList()));
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .postAbs(this.url.toString())
          .as(BodyCodec.jsonArray())
          .rxSendJson(requestBody)
          .toObservable()
          .map(Http::mapJsonArrayOrError)
          .map(json -> objectMapper.<List<AccountInfoDTO>>readValue(json.toString(), new TypeReference<List<AccountInfoDTO>>() {
          }))
          .flatMapIterable(item -> item)
          .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())))
          .toList()
          .toObservable());
}

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

@Override
public Observable<List<TransactionStatus>> getTransactionStatuses(List<String> transactionHashes) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("hashes", transactionHashes);
  return this.client
      .postAbs(this.url + "/statuses")
      .as(BodyCodec.jsonArray())
      .rxSendJson(requestBody)
      .toObservable()
      .map(Http::mapJsonArrayOrError)
      .map(json -> objectMapper.<List<TransactionStatusDTO>>readValue(json.toString(), new TypeReference<List<TransactionStatusDTO>>() {
      }))
      .flatMapIterable(item -> item)
      .map(transactionStatusDTO -> new TransactionStatus(transactionStatusDTO.getGroup(),
          transactionStatusDTO.getStatus(),
          transactionStatusDTO.getHash(),
          new Deadline(transactionStatusDTO.getDeadline().extractIntArray()),
          transactionStatusDTO.getHeight().extractIntArray()))
      .toList()
      .toObservable();
}

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

@Override
public Observable<List<NamespaceName>> getNamespaceNames(List<NamespaceId> namespaceIds) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("namespaceIds", namespaceIds.stream().map(id -> UInt64.bigIntegerToHex(id.getId())).collect(Collectors.toList()));
  return this.client
      .postAbs(this.url + "/namespace/names")
      .as(BodyCodec.jsonArray())
      .rxSendJson(requestBody)
      .toObservable()
      .map(Http::mapJsonArrayOrError)
      .map(json -> objectMapper.<List<NamespaceNameDTO>>readValue(json.toString(), new TypeReference<List<NamespaceNameDTO>>() {
      }))
      .flatMapIterable(item -> item)
      .map(namespaceNameDTO -> {
        if (namespaceNameDTO.getParentId() != null) {
          return new NamespaceName(
              new NamespaceId(namespaceNameDTO.getNamespaceId().extractIntArray()),
              namespaceNameDTO.getName(),
              new NamespaceId(namespaceNameDTO.getParentId().extractIntArray()));
        } else {
          return new NamespaceName(
              new NamespaceId(namespaceNameDTO.getNamespaceId().extractIntArray()),
              namespaceNameDTO.getName());
        }
      })
      .toList()
      .toObservable();
}

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

private Observable<List<NamespaceInfo>> getNamespacesFromAccounts(List<Address> addresses, Optional<QueryParams> queryParams) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("addresses", addresses.stream().map((address -> address.plain())).collect(Collectors.toList()));
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .postAbs(this.url + "/account/namespaces" + (queryParams.isPresent() ? queryParams.get().toUrl() : ""))
          .as(BodyCodec.jsonArray())
          .rxSendJson(requestBody)
          .toObservable()
          .map(Http::mapJsonArrayOrError)
          .map(json -> objectMapper.<List<NamespaceInfoDTO>>readValue(json.toString(), new TypeReference<List<NamespaceInfoDTO>>() {
          }))
          .flatMapIterable(item -> item)
          .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()
          ))
          .toList()
          .toObservable());
}

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

@Override
public Observable<List<MosaicInfo>> getMosaics(List<MosaicId> mosaicIds) {
  JsonObject requestBody = new JsonObject();
  requestBody.put("mosaicIds", mosaicIds.stream().map(id -> UInt64.bigIntegerToHex(id.getId())).collect(Collectors.toList()));
  Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
  return networkTypeResolve
      .flatMap(networkType -> this.client
          .postAbs(this.url + "/mosaic")
          .as(BodyCodec.jsonArray())
          .rxSendJson(requestBody)
          .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: com.cv4j.netdiscovery/netdiscovery-core

httpRequest = webClient.postAbs(request.getUrl());

相关文章