public static OORunResponse run(OORunRequest request) throws IOException, URISyntaxException {

    String urlString =
        StringUtils.slashify(request.getServer().getUrl())
            + REST_SERVICES_URL_PATH
            + RUN_OPERATION_URL_PATH
            + StringUtils.unslashifyPrefix(request.getFlow().getId());

    final URI uri = OOBuildStep.URI(urlString);
    final HttpPost httpPost = new HttpPost(uri);
    httpPost.setEntity(new JaxbEntity(request));
    httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "text/xml");
    //        if (OOBuildStep.getEncodedCredentials()!=null) {
    //            httpPost.addHeader("Authorization", "Basic " + new
    // String(OOBuildStep.getEncodedCredentials()));
    //        }

    HttpResponse response;

    response = client.execute(httpPost);
    final int statusCode = response.getStatusLine().getStatusCode();
    final HttpEntity entity = response.getEntity();

    try {
      if (statusCode == HttpStatus.SC_OK) {

        return JAXB.unmarshal(entity.getContent(), OORunResponse.class);

      } else {

        throw new RuntimeException(
            "unable to get run result from "
                + uri
                + ", response code: "
                + statusCode
                + "("
                + HttpStatus.getStatusText(statusCode)
                + ")");
      }
    } finally {
      EntityUtils.consume(entity);
    }
  }
  public static OOListResponse listFlows(OOServer s, String... folders) throws IOException {

    String foldersPath = "";

    for (String folder : folders) {
      foldersPath += folder + "/";
    }

    String url =
        StringUtils.slashify(s.getUrl())
            + REST_SERVICES_URL_PATH
            + LIST_OPERATION_URL_PATH
            + foldersPath;

    final HttpResponse response =
        OOBuildStep.getHttpClient().execute(new HttpGet(OOBuildStep.URI(url)));

    final int statusCode = response.getStatusLine().getStatusCode();

    final HttpEntity entity = response.getEntity();

    try {

      if (statusCode == HttpStatus.SC_OK) {

        return JAXB.unmarshal(entity.getContent(), OOListResponse.class);
      } else {

        throw new RuntimeException(
            "unable to get list of flows from "
                + url
                + ", response code: "
                + statusCode
                + "("
                + HttpStatus.getStatusText(statusCode)
                + ")");
      }
    } finally {
      EntityUtils.consume(entity);
    }
  }