private <T> T makePostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType) { WebTarget clientRequest = httpClient.target(uri); Response response; try { Entity<String> requestEntity = Entity.entity(serialize(bodyObject), getMediaType(format)); response = clientRequest.request(getMediaType(format)).post(requestEntity); } catch (Exception e) { throw createExceptionForUnexpectedFailure(clientRequest, e); } try { if (response.getStatus() == Response.Status.CREATED.getStatusCode() || response.getStatus() == Response.Status.OK.getStatusCode()) { return deserialize(response, resultType); } else { throw createExceptionForUnexpectedResponseCode(clientRequest, response); } } finally { response.close(); } }
private <T> T makePutRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType) { WebTarget clientRequest = httpClient.target(uri); Response response; try { Entity<String> requestEntity = Entity.entity(serialize(bodyObject), getMediaType(format)); response = clientRequest.request(getMediaType(format)).put(requestEntity); } catch (Exception e) { throw createExceptionForUnexpectedFailure(clientRequest, e); } try { if (response.getStatus() == Response.Status.CREATED.getStatusCode()) { return deserialize(response, resultType); } else { throw createExceptionForUnexpectedResponseCode(clientRequest, response); } } finally { response.close(); } }
spec.addConfig(Capability.RULE, ruleConfig); final String specContent = client.serialize(spec); LOGGER.info("{} content\n{}", marshallingFormat.getType(), specContent); final ContainerSpec specResult = client.deserialize(specContent,