code: private <T> Optional<T> extractEntityFromResponse(Response response, GenericType<T> returnType)
      {
          if(response.hasEntity() && (response.getStatus() == 200 || response.getStatus() == 201))
              return Optional.of(response.readEntity(returnType));
          return Optional.absent();
      }
docs: Extract the entity from the HTTP response.
  @param <T> The type parameter used for the return object
  @param response The HTTP response to extract the entity from
  @param returnType The type to marshall the result back into
  @return The extracted entity