List of usage examples for org.apache.http.client HttpResponseException getMessage
public String getMessage()
From source file:org.zenoss.metrics.reporter.HttpPoster.java
@Override public void post(MetricBatch batch) throws IOException { try {//from ww w . java 2 s. c om postImpl(batch); } catch (HttpResponseException e) { if (e.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { try { postImpl(batch); } catch (HttpResponseException ex) { LOG.warn("Error posting metrics {}", ex.getMessage()); throw ex; } } else { LOG.warn("Error posting metrics {}", e.getMessage()); } } }
From source file:org.opentestsystem.shared.permissions.rest.APIHandler.java
@SuppressWarnings("rawtypes") @ExceptionHandler(HttpResponseException.class) @ResponseBody//from w ww . java2s .c o m public ReturnStatus handleException(HttpResponseException e, HttpServletResponse response) { response.setStatus(e.getStatusCode()); return new ReturnStatus(StatusEnum.FAILURE, e.getMessage()); }
From source file:ch.cyberduck.core.dav.DAVExceptionMappingService.java
@Override public BackgroundException map(final HttpResponseException failure) { final StringBuilder buffer = new StringBuilder(); final int statusCode = failure.getStatusCode(); if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_MULTI_STATUS) { // HTTP method status this.append(buffer, failure.getMessage()); // Failure unmarshalling XML response return new InteroperabilityException(buffer.toString(), failure); }//from w w w .j a v a 2 s. c o m return super.map(failure); }
From source file:fr.lissi.belilif.om2m.oao.ApplicationManager.java
@Override public int delete(Application obj) { HttpGetSimpleResp resp;/*from w w w . ja va 2s . c om*/ int appResponse = -1; try { resp = WebServiceActions.doDelete(this.OM2MUrlBase + "applications/" + obj.getAppId(), headers); appResponse = resp.getStatusCode(); } catch (HttpResponseException e) { LOGGER.error("HttpResponseException - " + e.getStatusCode() + " / " + e.getMessage()); } catch (ClientProtocolException e) { e.printStackTrace(); LOGGER.error(e.getMessage()); } catch (ConnectException e) { LOGGER.error( e.getMessage() + ". \nThe server '" + this.OM2MUrlBase.substring(7, 21) + "' is unreachable."); } catch (IOException e) { LOGGER.error(e.getMessage()); } return appResponse; }
From source file:fr.lissi.belilif.om2m.oao.ApplicationManager.java
@Override public Application get(String id) { Application appResponse = null;//from w w w . ja v a 2 s . c o m HttpGetSimpleResp resp; try { resp = WebServiceActions.doGet(this.OM2MUrlBase + "applications/" + id, headers); if (resp.getStatusCode() == 200) appResponse = (Application) JAXBMapper.XMLStringToObject(resp.getResult(), Application.class); } catch (HttpResponseException e) { LOGGER.error("HttpResponseException - " + e.getStatusCode() + " / " + e.getMessage()); } catch (ClientProtocolException e) { e.printStackTrace(); LOGGER.error(e.getMessage()); } catch (ConnectException e) { LOGGER.error( e.getMessage() + ". \nThe server '" + this.OM2MUrlBase.substring(7, 21) + "' is unreachable."); } catch (IOException e) { LOGGER.error(e.getMessage()); } return appResponse; }
From source file:fr.lissi.belilif.om2m.oao.ApplicationManager.java
@Override public List<Application> getAll(Resource resource) { // TODO manage exceptions HttpGetSimpleResp resp = null;//w ww . jav a 2 s .com try { resp = WebServiceActions.doGet(this.OM2MUrlBase + "applications", headers); } catch (HttpResponseException e) { LOGGER.error("HttpResponseException - " + e.getStatusCode() + " / " + e.getMessage()); } catch (ClientProtocolException e) { LOGGER.error(e); } catch (ConnectException e) { LOGGER.error( e.getMessage() + ". \nThe server '" + this.OM2MUrlBase.substring(7, 21) + "' is unreachable."); } catch (IOException e) { LOGGER.error(e); } // xml to object Applications appsResp = (Applications) JAXBMapper.XMLStringToObject(resp.getResult(), Applications.class); List<Application> apps = new ArrayList<Application>(); LOGGER.info("MODEL APPS : " + appsResp); for (ReferenceToNamedResource refToNamedRes : appsResp.getApplicationCollection().getNamedReference()) { apps.add(new Application(refToNamedRes.getId())); } return apps; }
From source file:au.csiro.casda.sodalint.ValidateCapabilities.java
private String getCapabilities(final Reporter reporter, URL serviceUrl) { String baseUrl = serviceUrl.toString(); if (!baseUrl.endsWith("/")) { baseUrl += "/"; }/* www . ja va2 s . co m*/ String address = baseUrl + "capabilities"; try { reporter.report(SodaCode.I_VURL, "Validating URL: " + address); String content = getXmlContentFromUrl(address); if (content == null) { reporter.report(SodaCode.E_CPRS, "Capabilities response contains no content"); } return content; } catch (HttpResponseException e) { reporter.report(SodaCode.E_CPRS, "Unexpected http response: " + e.getStatusCode() + " Reason: " + e.getMessage()); } catch (UnsupportedEncodingException e) { reporter.report(SodaCode.E_CPRS, "Capabilities response has an unexpected content type:" + e.getMessage()); } catch (IOException e) { reporter.report(SodaCode.E_CPRS, "Unable to read capabilities response: " + e.getMessage()); } return null; }
From source file:fr.lissi.belilif.om2m.oao.ContentInstanceManager.java
@Override public int subscribe(ContentInstance obj, Subscription subscription) { LOGGER.info("Create : \n" + JAXBMapper.objectToXMLString(obj)); int resp = -1; try {//ww w .j a v a2 s. c o m resp = WebServiceActions.doPost( this.OM2MUrlBase + "applications/" + obj.getContainer().getApplication().getAppId() + "/containers/" + JAXBMapper.objectToXMLString(subscription) + "/contentInstances/subscriptions", "BODY-" + new String(obj.getContent().getValue()), this.headers); // ID pas content } catch (HttpResponseException e) { resp = e.getStatusCode(); LOGGER.info(e.getStatusCode() + " / " + e.getMessage()); } catch (ClientProtocolException e) { // TODO ClientProtocolException e.printStackTrace(); } catch (IOException e) { // TODO IOException e.printStackTrace(); } return resp; }
From source file:fr.lissi.belilif.om2m.oao.ApplicationManager.java
@Override public int create(Application obj) { String appInXML = JAXBMapper.objectToXMLString(obj); LOGGER.info("App to create : " + obj.getAppId()); LOGGER.info(obj.getAppId() + " in OM2M XML strcuture : \n" + appInXML); // appeler le client REST avec le code XML correspondant int resp = -1; try {// w ww. java 2s . c o m resp = WebServiceActions.doPost(this.OM2MUrlBase + "applications", appInXML, this.headers); LOGGER.info("Application '" + obj.getAppId() + "' creation status : " + resp); } catch (HttpResponseException e) { resp = e.getStatusCode(); LOGGER.error("HttpResponseException - " + e.getStatusCode() + " / " + e.getMessage() + "\n" + "Unable to create the application '" + obj.getAppId() + "' with " + this.OM2MUrlBase + "applications"); } catch (ClientProtocolException e) { e.printStackTrace(); LOGGER.error(e.getMessage()); } catch (ConnectException e) { LOGGER.error( e.getMessage() + ". \nThe server '" + this.OM2MUrlBase.substring(7, 21) + "' is unreachable."); } catch (IOException e) { LOGGER.error(e.getMessage()); } return resp; }