- Client client = ClientBuilder.newClient(new ClientConfig());
- String content = GsonUtil.beanToJson(ruleCreateRequest);
- WebTarget webTarget = client.target(url);
- Response response = webTarget.request(MediaType.APPLICATION_JSON)
- .put(Entity.entity(content, MediaType.APPLICATION_JSON));
- suc = response.getStatus() == 200;
+ String content = "";
+ try {
+ content = GsonUtil.beanToJson(ruleCreateRequest);
+ } catch (Exception e) {
+ throw new CorrelationException("Failed to convert the message object to a json string.", e);
+ }
+ HashMap<String, String> headers = new HashMap<>();
+ headers.put("Content-Type", MediaType.APPLICATION_JSON);
+ headers.put("Accept", MediaType.APPLICATION_JSON);
+ HttpResponse httpResponse;
+ try {
+ httpResponse = HttpsUtils
+ .put(url, headers, new HashMap<>(), new StringEntity(content));
+ } catch (UnsupportedEncodingException e) {
+ throw new CorrelationException("Failed to create https entity.", e);
+ } catch (Exception e) {
+ throw new CorrelationException(e.getMessage());
+ }
+ if (httpResponse != null) {
+ suc = httpResponse.getStatusLine().getStatusCode() == 200;
+ }