Java Code Examples for org.apache.commons.httpclient.HttpMethod#getStatusText()
The following examples show how to use
org.apache.commons.httpclient.HttpMethod#getStatusText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RESTMetadataProvider.java From vind with Apache License 2.0 | 5 votes |
@Override public Document getDocument(Document document, DocumentFactory factory) throws IOException { HttpMethod request = new GetMethod(baseURL); request.addRequestHeader("Authorization", String.format("Bearer %s", bearerToken)); //TODO request.setPath(path + document.getId()); int status = client.executeMethod(request); if(status == 200) { JsonNode json = mapper.readValue(request.getResponseBody(), JsonNode.class); for(FieldDescriptor descriptor : factory.listFields()) { try { Object value = getValue(json, descriptor); if(value != null) { document.setValue(descriptor, value); } else LOG.warn("No data found for id {}", document.getId()); } catch (IOException e) { LOG.warn("Cannot use data for id {}: {}", document.getId(), e.getMessage()); } } return document; } else throw new IOException(request.getStatusText()); }
Example 2
Source File: HttpClientConnection.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
public String getResponseMessage() throws IOException { HttpMethod res = getResult(true); return res.getStatusText(); }