List of usage examples for org.apache.http.client ClientProtocolException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.openhab.binding.rwesmarthome.internal.communicator.RWESmarthomeSession.java
/** * Executes a request with the given command. * Set login to true to execute a login request. * /* w w w . ja v a2s . c o m*/ * @param request * the login request * @param command * the s cmd * @return the string * @throws SmartHomeSessionExpiredException * the smart home session expired exception */ private String executeRequest(String request, String command, boolean login) throws RWESmarthomeSessionExpiredException { // If there is no sessionId and no login wanted, session is expired if (!login && "".equals(sessionId)) { throw new RWESmarthomeSessionExpiredException(); } String sReturn = ""; try { // execute the request sReturn = client.execute(hostname, clientId, request, command); // return may contain an IllegalSessionId -> session expired. if (sReturn.contains("IllegalSessionId")) { logger.info("Session expired!"); sessionId = ""; throw new RWESmarthomeSessionExpiredException(sReturn); } logger.trace("XMLResponse:" + sReturn); } catch (ClientProtocolException ex) { logger.error(ex.getClass().getSimpleName(), ex); } catch (IOException ex) { logger.error(ex.getClass().getSimpleName(), ex); } return sReturn; }
From source file:mixedserver.protocol.jsonrpc.client.HTTPSession.java
private String sendEntity(HttpEntity entity) throws RPCException { HttpPost request = new HttpPost(this.uri); request.setEntity(entity);/*from w w w . j ava2 s .com*/ HttpResponse response; String responseString = null; try { Date before = new Date(); response = http().execute(request, localContext); Date after = new Date(); logger.debug("" + (after.getTime() - before.getTime())); responseString = EntityUtils.toString(response.getEntity()); responseString = responseString.trim(); } catch (ClientProtocolException e) { throw new RPCException("???"); } catch (IOException e) { throw new RPCException("", RPCException.ERROR_CODE_NETWORK_ERROR); } catch (Exception e) { if (e.getClass().getName().equals("NetworkOnMainThreadException")) { throw new RPCException("????"); } throw new RPCException("http:" + e.getMessage()); } return responseString; }