本文整理汇总了Java中org.apache.http.client.HttpResponseException.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseException.getStatusCode方法的具体用法?Java HttpResponseException.getStatusCode怎么用?Java HttpResponseException.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.HttpResponseException
的用法示例。
在下文中一共展示了HttpResponseException.getStatusCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleLoginError
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
private void handleLoginError(Throwable e) {
System.out.println("Login failed: " + e);
if (e instanceof WrongPasswordException) {
error.setText("Error logging in, wrong password.");
} else if (e instanceof HttpResponseException) {
HttpResponseException responseException = (HttpResponseException) e;
if (responseException.getStatusCode() == 404) {
error.setText("Error logging in, user doesn't exist.");
} else {
error.setText("Error logging in, " + responseException.getStatusCode() + " " + responseException.getMessage());
}
} else {
error.setText("Error logging in, " + e + ".");
}
}
示例2: getAllClasses
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override public List<String> getAllClasses() throws IOException, JSONException, CredentialInvalidException {
String baseurl = data.getString(PARAM_BASEURL) + "/";
for (int i = -4; i < MAX_DAYS; i++) {
LocalDate date = LocalDate.now().plusDays(i);
String dateStr = DateTimeFormat.forPattern("yyyyMMdd").print(date);
String url = baseurl + "mobdaten/PlanKl" + dateStr + ".xml?_=" + System.currentTimeMillis();
try {
String xml = httpGet(url, "UTF-8");
Document doc = Jsoup.parse(xml, url, Parser.xmlParser());
List<String> classes = new ArrayList<>();
for (Element klasse:doc.select("Klassen > Kl")) {
classes.add(klasse.select("Kurz").first().text());
}
return classes;
} catch (HttpResponseException e) {
if (e.getStatusCode() != 404 && e.getStatusCode() != 300) throw e;
}
}
return new ArrayList<>();
}
示例3: getJSONArray
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
private JSONArray getJSONArray(String url) throws IOException, CredentialInvalidException {
try {
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + authToken);
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
final String httpResponse = httpGet(url, "UTF-8", headers);
return new JSONArray(httpResponse);
} catch (HttpResponseException httpResponseException) {
if (httpResponseException.getStatusCode() == 404) {
return null;
}
throw httpResponseException;
} catch (JSONException e) {
return new JSONArray();
}
}
示例4: sendFailureMessage
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
protected void sendFailureMessage(Throwable e, String errorMessage, String responseBody) {
if (e instanceof HttpResponseException) {
HttpResponseException httpResponseException = (HttpResponseException)e;
if (httpResponseException.getStatusCode() >= 300 && responseBody != null) {// may be still a successful response
try {
Object responseObject = this.convertXMLToObject(responseBody);
if (responseObject != null) {
sendMessage(obtainMessage(SUCCESS_RESPONSE_HANDLING_MESSAGE, new Object[]{responseObject}));
return;
}
} catch (UnmarshallException e1) {
// ignore
}
}
}
sendMessage(obtainMessage(FAILURE_MESSAGE, new Object[]{e, errorMessage}));
}
示例5: importMetaData
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public StateDto importMetaData(ImportOptions options, IProgressMonitor monitor) throws Exception {
try {
return c.importMetaData(options, monitor);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.importMetaData(options, monitor);
}
}
error401 = false;
throw e;
}
}
示例6: authenticate
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@GuardedBy("lock")
void authenticate(HttpClient client) throws IOException {
if (id == null || id.isEmpty() || password == null || password.isEmpty()) {
invalid = "Unable to re-authenticate expired token: missing appleId/ password.";
} else {
try {
Auth auth = Auth.from(client, id, password);
if (auth.dsPrsID().equals(token.auth().dsPrsID())) {
token = Token.from(auth);
} else {
logger.error("-- reauthentication() > mismatched dsPrsID: {} > {}",
token.auth().dsPrsID(), auth.dsPrsID());
invalid = "Unable to re-authenticate expired token: account mismatch.";
}
} catch (HttpResponseException ex) {
if (ex.getStatusCode() == 401) {
invalid = "Unable to re-authenticate expired token: invalid appleId/ password.";
}
}
}
testIsInvalid();
}
示例7: exportMetaData
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public StateDto exportMetaData(ExportOptions options, IProgressMonitor monitor) throws Exception {
try {
return c.exportMetaData(options, monitor);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.exportMetaData(options, monitor);
}
}
error401 = false;
throw e;
}
}
示例8: getUser
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public ClientUser getUser(IProgressMonitor monitor) throws Exception {
try {
return c.getUser(monitor);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.getUser(monitor);
}
}
error401 = false;
throw e;
}
}
示例9: copy
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public ResourceDescriptor copy(IProgressMonitor monitor, ResourceDescriptor rd, String destFolderURI) throws Exception {
try {
rd = c.copy(monitor, rd, destFolderURI);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
if (!error401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.copy(monitor, rd, destFolderURI);
}
}
}
error401 = false;
throw e;
}
rd.setChildrenDirty(false);
return rd;
}
示例10: addOrModifyResource
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public ResourceDescriptor addOrModifyResource(IProgressMonitor monitor, ResourceDescriptor rd, File inputFile) throws Exception {
try {
rd = c.addOrModifyResource(monitor, rd, inputFile);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.addOrModifyResource(monitor, rd, inputFile);
}
}
error401 = false;
throw e;
}
rd.setChildrenDirty(false);
return rd;
}
示例11: modifyReportUnitResource
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public ResourceDescriptor modifyReportUnitResource(IProgressMonitor monitor, ResourceDescriptor runit, ResourceDescriptor rd, File inFile) throws Exception {
try {
rd = c.modifyReportUnitResource(monitor, runit, rd, inFile);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.modifyReportUnitResource(monitor, runit, rd, inFile);
}
}
error401 = false;
throw e;
}
rd.setChildrenDirty(false);
return rd;
}
示例12: setPermissions
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public List<RepositoryPermission> setPermissions(ResourceDescriptor rd, List<RepositoryPermission> perms, PermissionOptions options, IProgressMonitor monitor) throws Exception {
try {
return c.setPermissions(rd, perms, options, monitor);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.setPermissions(rd, perms, options, monitor);
}
}
error401 = false;
throw e;
}
}
示例13: getPermissions
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public List<RepositoryPermission> getPermissions(ResourceDescriptor rd, IProgressMonitor monitor, PermissionOptions options) throws Exception {
try {
return c.getPermissions(rd, monitor, options);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.getPermissions(rd, monitor, options);
}
}
error401 = false;
throw e;
}
}
示例14: runReport
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public ReportExecution runReport(IProgressMonitor monitor, ReportExecution repExec) throws Exception {
try {
return c.runReport(monitor, repExec);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
return c.runReport(monitor, repExec);
}
repExec.setStatus("failed");
return repExec;
}
error401 = false;
throw e;
}
}
示例15: findResources
import org.apache.http.client.HttpResponseException; //导入方法依赖的package包/类
@Override
public void findResources(IProgressMonitor monitor, AFinderUI callback) throws Exception {
try {
c.findResources(monitor, callback);
} catch (Exception e) {
if (e instanceof HttpResponseException) {
HttpResponseException he = (HttpResponseException) e;
if (he.getStatusCode() == 401) {
c.connect(monitor, getServerProfile());
error401 = true;
c.findResources(monitor, callback);
return;
}
}
error401 = false;
throw e;
}
}