public String request(Link link, String acceptedMediaType, ServiceParameter... serviceParameters)
      throws MalformedURLException, HttpClientException, SocketTimeoutException, OpenShiftException,
          UnsupportedEncodingException {
    String save = client.getAcceptedMediaType();
    client.setAcceptedMediaType(acceptedMediaType);

    HttpMethod httpMethod = link.getHttpMethod();
    URL url = getUrl(link.getHref());
    Map<String, Object> parameters = toMap(serviceParameters);

    LOGGER.trace("Requesting {} on {}", httpMethod.name(), url);
    LOGGER.info("Requesting {} on {}", httpMethod.name(), url);

    String response = client.get(url);

    client.setAcceptedMediaType(save);

    return response;
  }
  private String request(URL url, HttpMethod httpMethod, Map<String, Object> parameters)
      throws HttpClientException, SocketTimeoutException, OpenShiftException,
          UnsupportedEncodingException {
    LOGGER.trace("Requesting {} on {}", httpMethod.name(), url);
    LOGGER.info("Requesting {} on {}", httpMethod.name(), url);

    switch (httpMethod) {
      case GET:
        return client.get(url);
      case POST:
        return client.post(parameters, url);
      case PUT:
        return client.put(parameters, url);
      case DELETE:
        return client.delete(parameters, url);
      default:
        throw new OpenShiftException("Unexpected HTTP method {0}", httpMethod.toString());
    }
  }
 public RestService(String baseUrl, String clientId, IHttpClient client) {
   this.baseUrl = UrlUtils.ensureStartsWithHttps(baseUrl);
   this.client = client;
   client.setUserAgent(new RestServiceProperties().getUseragent(clientId));
   client.setVersion(SERVICE_VERSION);
 }