本文整理匯總了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;
}
示例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();
}
示例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;
}
示例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;
}
}