List of usage examples for org.apache.commons.httpclient HttpMethodBase getPath
@Override
public String getPath()
From source file:org.review_board.ereviewboard.core.client.ReviewboardHttpClient.java
private String executeMethod(HttpMethodBase request, IProgressMonitor monitor) throws ReviewboardException { monitor = Policy.monitorFor(monitor); ensureIsLoggedIn(monitor);//from ww w . j av a 2 s .com try { monitor.beginTask("Executing request", IProgressMonitor.UNKNOWN); int statusCode = executeRequest(request, monitor); if (statusCode == HttpStatus.SC_NOT_FOUND) throw new ReviewboardResourceNotFoundException(request.getPath()); return getResponseBodyAsString(request, monitor); } finally { request.releaseConnection(); monitor.done(); } }
From source file:org.review_board.ereviewboard.core.client.ReviewboardHttpClient.java
private static String constructUri(HttpMethodBase request) { try {/*www . j a v a2 s. c o m*/ return request.getURI().toString(); } catch (URIException e) { return request.getPath(); } }
From source file:org.svenk.redmine.core.client.AbstractRedmineClient.java
protected <T extends Object> T executeMethod(HttpMethodBase method, IRedmineResponseParser<T> parser, IProgressMonitor monitor, int... expectedSC) throws RedmineException { monitor = Policy.monitorFor(monitor); method.setFollowRedirects(false);// w w w . j ava 2 s.com HostConfiguration hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); T response = null; try { int sc = executeMethod(method, hostConfiguration, monitor); if (parser != null && expectedSC != null) { boolean found = false; for (int i : expectedSC) { if (i == sc) { InputStream input = WebUtil.getResponseBodyAsStream(method, monitor); try { found = true; response = parser.parseResponse(input, sc); } finally { input.close(); } break; } } if (!found) { String msg = Messages.AbstractRedmineClient_UNEXPECTED_RESPONSE_CODE; msg = String.format(msg, sc, method.getPath(), method.getName()); IStatus status = new Status(IStatus.ERROR, RedmineCorePlugin.PLUGIN_ID, msg); StatusHandler.fail(status); throw new RedmineStatusException(status); } } } catch (RedmineErrorException e) { IStatus status = RedmineCorePlugin.toStatus(e, null); StatusHandler.fail(status); throw new RedmineStatusException(status); } catch (IOException e) { IStatus status = RedmineCorePlugin.toStatus(e, null); StatusHandler.log(status); throw new RedmineStatusException(status); } finally { method.releaseConnection(); } return response; }