public <T> void executeUpdateObject(final T newObject, final String path, final Map<String, String> parameters) throws CloudstackRESTException { s_logger.debug("Executing update object on " + path); client.closeResponse(createAndExecuteRequest(HttpMethods.PUT, path, parameters, Optional.fromNullable(gson.toJson(newObject)))); }
public void executeDeleteObject(final String path) throws CloudstackRESTException { s_logger.debug("Executing delete object on " + path); client.closeResponse(createAndExecuteRequest(HttpMethods.DELETE, path, new HashMap<String, String>(), ABSENT)); }
private <T> T readResponseBody(final CloseableHttpResponse response, final Type type) throws CloudstackRESTException { final HttpEntity entity = response.getEntity(); try { final String stringEntity = EntityUtils.toString(entity); //s_logger.debug("Response entity: " + stringEntity); EntityUtils.consumeQuietly(entity); return gson.fromJson(stringEntity, type); } catch (final IOException e) { throw new CloudstackRESTException("Could not deserialize response to JSON. Entity: " + entity, e); } finally { client.closeResponse(response); } }
public void executeDeleteObject(final String path) throws CosmicRESTException { s_logger.debug("Executing delete object on " + path); client.closeResponse(createAndExecuteRequest(HttpMethods.DELETE, path, new HashMap<>(), ABSENT)); }
public <T> void executeUpdateObject(final T newObject, final String path, final Map<String, String> parameters) throws CosmicRESTException { s_logger.debug("Executing update object on " + path); client.closeResponse(createAndExecuteRequest(HttpMethods.PUT, path, parameters, Optional.fromNullable(gson.toJson(newObject)))); }
private <T> T readResponseBody(final CloseableHttpResponse response, final Type type) throws CosmicRESTException { final HttpEntity entity = response.getEntity(); try { final String stringEntity = EntityUtils.toString(entity); s_logger.trace("Response entity: " + stringEntity); EntityUtils.consumeQuietly(entity); return gson.fromJson(stringEntity, type); } catch (final IOException e) { throw new CosmicRESTException("Could not deserialize response to JSON. Entity: " + entity, e); } finally { client.closeResponse(response); } }