當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。