当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponse.isSuccessStatusCode方法代码示例

本文整理汇总了Java中com.google.api.client.http.HttpResponse.isSuccessStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse.isSuccessStatusCode方法的具体用法?Java HttpResponse.isSuccessStatusCode怎么用?Java HttpResponse.isSuccessStatusCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.isSuccessStatusCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
public boolean execute() throws IOException {
  try {
    HttpResponse response = request.execute();

    isSuccess = response.isSuccessStatusCode();

    if (isSuccess) {
      Map<String, String> oauthKeys = getQueryMap(response.parseAsString());

      this.token = oauthKeys.get("oauth_token");
      this.tokenSecret = oauthKeys.get("oauth_token_secret");
      this.sessionHandle = oauthKeys.get("oauth_session_handle");
      this.tokenTimestamp = System.currentTimeMillis() / 1000l;
      isSuccess = true;
    } else {

    }
  } catch (HttpResponseException e) {

    Map<String, String> oauthError = getQueryMap(e.getMessage());
    this.problem = oauthError.get("oauth_problem");
    this.advice = oauthError.get("oauth_problem_advice");
    isSuccess = false;
  }
  return isSuccess;
}
 
开发者ID:XeroAPI,项目名称:Xero-Java,代码行数:27,代码来源:OAuthAccessToken.java

示例2: getClientEmail

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
public static String getClientEmail(String accessToken) throws IOException {
  /*
   * Get loggined user info as described in
   * https://developers.google.com/accounts/docs/OAuth2Login#userinfocall
   */
  GenericUrl url = new GenericUrl("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + accessToken);
  HttpRequest request = HTTP_REQUEST_FACTORY.buildGetRequest(url);
  HttpResponse response = request.execute();
  if (!response.isSuccessStatusCode()) {
    throw new IOException(response.getStatusMessage());
  }
  JsonElement jsonElement = new JsonParser().parse(new InputStreamReader(response.getContent(), "utf-8"));
  JsonObject jsonObj = jsonElement.getAsJsonObject();
  return jsonObj.get("email").getAsString();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:16,代码来源:GoogleAuthentication.java

示例3: handleResponse

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
@Override
public boolean handleResponse(
    HttpRequest httpRequest,
    HttpResponse httpResponse, boolean supportsRetry) throws IOException {
  if (!httpResponse.isSuccessStatusCode() && httpResponse.getStatusCode() == ACCESS_DENIED) {
    throwNullCredentialException();
  }
  return supportsRetry;
}
 
开发者ID:apache,项目名称:beam,代码行数:10,代码来源:NullCredentialInitializer.java

示例4: executeAndParse

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
<T> T executeAndParse(HttpRequest request, Class<T> cls) throws IOException {
  if (log.isDebugEnabled()) {
    log.debug("Calling {} on {}", request.getRequestMethod(), request.getUrl());
  }
  HttpResponse response = request.execute();

  if (response.isSuccessStatusCode()) {
    return response.parseAs(cls);
  } else {
    SalesforceException exception = response.parseAs(SalesforceException.class);
    throw exception;
  }
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-salesforce,代码行数:14,代码来源:SalesforceRestClientImpl.java


注:本文中的com.google.api.client.http.HttpResponse.isSuccessStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。