List of usage examples for javax.xml.ws.http HTTPException getStatusCode
public int getStatusCode()
From source file:io.mindmaps.engine.loader.DistributedLoader.java
private String executePost(HttpURLConnection connection, String body) { try {// w w w. j av a 2s .c o m // create post connection.setRequestMethod(REST.HttpConn.POST_METHOD); connection.addRequestProperty(REST.HttpConn.CONTENT_TYPE, REST.HttpConn.APPLICATION_POST_TYPE); // add body and execute connection.setRequestProperty(REST.HttpConn.CONTENT_LENGTH, Integer.toString(body.length())); connection.getOutputStream().write(body.getBytes(REST.HttpConn.UTF8)); // get response return connection.getResponseMessage(); } catch (HTTPException e) { LOG.error(ErrorMessage.ERROR_IN_DISTRIBUTED_TRANSACTION.getMessage(connection.getURL().toString(), e.getStatusCode(), getResponseMessage(connection), body)); } catch (IOException e) { LOG.error(ErrorMessage.ERROR_COMMUNICATING_TO_HOST.getMessage(connection.getURL().toString())); } return null; }
From source file:io.mindmaps.loader.DistributedLoader.java
private String executePost(HttpURLConnection connection, String body) { try {// ww w. j a v a2 s .co m // create post connection.setRequestMethod(RESTUtil.HttpConn.POST_METHOD); connection.addRequestProperty(RESTUtil.HttpConn.CONTENT_TYPE, RESTUtil.HttpConn.APPLICATION_POST_TYPE); // add body and execute connection.setRequestProperty(RESTUtil.HttpConn.CONTENT_LENGTH, Integer.toString(body.length())); connection.getOutputStream().write(body.getBytes(RESTUtil.HttpConn.UTF8)); // get response return connection.getResponseMessage(); } catch (HTTPException e) { LOG.error(ErrorMessage.ERROR_IN_DISTRIBUTED_TRANSACTION.getMessage(connection.getURL().toString(), e.getStatusCode(), getResponseMessage(connection), body)); } catch (IOException e) { LOG.error(ErrorMessage.ERROR_COMMUNICATING_TO_HOST.getMessage(connection.getURL().toString())); } return null; }
From source file:ai.grakn.engine.loader.client.LoaderClient.java
/** * Send an insert query to one host//from w ww . j a v a 2s . c om */ private String executePost(HttpURLConnection connection, String body) { try { // create post connection.setRequestMethod(REST.HttpConn.POST_METHOD); connection.addRequestProperty(REST.HttpConn.CONTENT_TYPE, REST.HttpConn.APPLICATION_POST_TYPE); // add body and execute connection.setRequestProperty(REST.HttpConn.CONTENT_LENGTH, Integer.toString(body.length())); connection.getOutputStream().write(body.getBytes(REST.HttpConn.UTF8)); connection.getOutputStream().flush(); // get response return IOUtils.toString(connection.getInputStream()); } catch (HTTPException e) { LOG.error(ErrorMessage.ERROR_IN_DISTRIBUTED_TRANSACTION.getMessage(connection.getURL().toString(), e.getStatusCode(), getResponseMessage(connection))); } catch (IOException e) { LOG.error(ErrorMessage.ERROR_COMMUNICATING_TO_HOST.getMessage(connection.getURL().toString())); } finally { connection.disconnect(); } return null; }