當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpResponseException.getStatusCode方法代碼示例

本文整理匯總了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 + ".");
    }
}
 
開發者ID:mixer,項目名稱:surgeon-sim,代碼行數:17,代碼來源:LoginController.java

示例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<>();
}
 
開發者ID:vertretungsplanme,項目名稱:substitution-schedule-parser,代碼行數:23,代碼來源:IndiwareMobileParser.java

示例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();
    }
}
 
開發者ID:vertretungsplanme,項目名稱:substitution-schedule-parser,代碼行數:19,代碼來源:IphisParser.java

示例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}));
}
 
開發者ID:maxep,項目名稱:NanoKit,代碼行數:19,代碼來源:XMLHttpResponseHandler.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:18,代碼來源:ProxyConnection.java

示例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();
}
 
開發者ID:horrorho,項目名稱:LiquidDonkey,代碼行數:27,代碼來源:Authenticator.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:18,代碼來源:ProxyConnection.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:18,代碼來源:ProxyConnection.java

示例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;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:22,代碼來源:ProxyConnection.java

示例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;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:20,代碼來源:ProxyConnection.java

示例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;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:20,代碼來源:ProxyConnection.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:18,代碼來源:ProxyConnection.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:18,代碼來源:ProxyConnection.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:20,代碼來源:ProxyConnection.java

示例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;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:19,代碼來源:ProxyConnection.java


注:本文中的org.apache.http.client.HttpResponseException.getStatusCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。