public R bindToRequest()

in openstack-poppy/src/main/java/org/jclouds/openstack/poppy/v1/mapbinders/JSONPatchUpdate.java [55:72]


   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
      String jsonPatch = null;
      Service service = (Service) postParams.get("service");

      //Json json = Guice.createInjector(new GsonModule()).getInstance(Json.class);

      String targetService = json.toJson(postParams.get("updateService"));
      String sourceService = json.toJson(service.toUpdatableService().build());

      ObjectMapper mapper = new ObjectMapper();
      try {
         jsonPatch = JsonDiff.asJson(mapper.readTree(sourceService), mapper.readTree(targetService)).toString();
      } catch (IOException e) {
         throw new RuntimeException("Could not create a JSONPatch", e);
      }

      return bindToRequest(request, (Object) jsonPatch);
   }