public WaitExecutionResult waitExecutionComplete(
      TriggeredExecutionDetailsVO triggeredExecutionDetailsVO,
      String timeout,
      BuildListener listener,
      String urlString)
      throws InterruptedException, IOException {
    feedURL = triggeredExecutionDetailsVO.getFeedUrl();

    // close connection
    //        is.close();

    // Read run details
    long defaultTimeout = 600000;
    Long timeoutLong = timeout.isEmpty() ? defaultTimeout : Long.parseLong(timeout);
    listener.getLogger().println("Flow execution timeout : " + timeoutLong + " ms");

    // Wait the run will completed
    List<ExecutionSummaryVO> executionSummary;
    ExecutionStatusState executionStatusState;
    int prevStepCount = 0;
    Boolean newLine = false;
    do {
      Long sleepIntervalInMs = timeoutLong > 5000 ? 5000 : timeoutLong;
      timeoutLong -= (sleepIntervalInMs);
      Thread.sleep(sleepIntervalInMs);

      // Get run details
      HttpGet httpGet = new HttpGet(urlString + EXECUTIONS_API + runId + EXECUTE_SUMMARY_POSTFIX);

      // Handle CSRF tokens cookies
      client.setCookieStore(handleCsrfCookies(client.getCookieStore()));

      // Authenticate
      if (OOBuildStep.getEncodedCredentials() != null) {
        httpGet.addHeader(
            "Authorization", "Basic " + new String(OOBuildStep.getEncodedCredentials()));
      }

      // Execute the request
      HttpResponse response = client.execute(httpGet);

      // Verify the response is OK
      Assert.isTrue(
          response.getStatusLine().getStatusCode() == 200,
          "Invalid response code [" + response.getStatusLine().getStatusCode() + "]");

      String responseBody = EntityUtils.toString(response.getEntity());

      executionSummary =
          gson.fromJson(responseBody, new TypeToken<List<ExecutionSummaryVO>>() {}.getType());
      executionStatusState = executionSummary.get(0).getStatus();

      // get steps details for steps progress
      httpGet = new HttpGet(urlString + EXECUTIONS_API + runId + EXECUTION_STEPS_COUNT_POSTFIX);

      // Handle CSRF tokens cookies
      client.setCookieStore(handleCsrfCookies(client.getCookieStore()));

      // Authenticate
      if (OOBuildStep.getEncodedCredentials() != null) {
        httpGet.addHeader(
            "Authorization", "Basic " + new String(OOBuildStep.getEncodedCredentials()));
      }

      // Execute the request
      response = client.execute(httpGet);

      // Verify the response is OK
      Assert.isTrue(
          response.getStatusLine().getStatusCode() == 200,
          "Invalid response code [" + response.getStatusLine().getStatusCode() + "]");

      responseBody = EntityUtils.toString(response.getEntity());

      // printing steps progress
      int currentStepCount = gson.fromJson(responseBody, new TypeToken<Integer>() {}.getType());

      if (currentStepCount > prevStepCount) {
        if (newLine) {
          listener.getLogger().println();
        }
        listener.getLogger().println(currentStepCount + " steps were completed");
        newLine = false;
      } else {
        listener.getLogger().print(".");
        newLine = true;
      }

      prevStepCount = currentStepCount;

    } while (timeoutLong > 0
        && (executionStatusState.equals(ExecutionStatusState.RUNNING)
            || executionStatusState.equals(ExecutionStatusState.PENDING_PAUSE)));

    // get full status name
    String runResult;
    if (executionStatusState.equals(ExecutionStatusState.COMPLETED)) {
      runResult = executionStatusState + " - " + executionSummary.get(0).getResultStatusType();
    } else {
      // TODO handle also paused runs
      runResult = executionStatusState.name();
    }

    WaitExecutionResult waitExecutionResult = new WaitExecutionResult();
    waitExecutionResult.setLastExecutionResult(executionSummary.get(0).getResultStatusType());
    waitExecutionResult.setLastExecutionStatus(executionStatusState);
    waitExecutionResult.setTimedOut(
        timeoutLong <= 0
            && (executionStatusState.equals(ExecutionStatusState.RUNNING)
                || executionStatusState.equals(ExecutionStatusState.PENDING_PAUSE)));
    waitExecutionResult.setStepCount(prevStepCount);

    return waitExecutionResult;
  }
  public TriggeredExecutionDetailsVO run10x(
      String selectedFlowUUID,
      List<OOArg> argsToUse,
      String urlString,
      String timeout,
      BuildListener listener,
      String runName)
      throws IOException, InterruptedException {

    final HttpPost httpPost = new HttpPost(urlString + EXECUTIONS_API);

    // Convert inputs to the required type
    Map<String, String> inputs = new HashMap<String, String>();
    for (OOArg arg : argsToUse) {
      inputs.put(arg.getName(), arg.getValue());
    }

    // Create the POST object and add the parameters
    ExecutionVO executionVO = new ExecutionVO();
    executionVO.setUuid(selectedFlowUUID);
    if (runName != null && !runName.equals("")) executionVO.setRunName(runName);
    executionVO.setInputs(inputs);
    String body = gson.toJson(executionVO);
    StringEntity entity = new StringEntity(body, "UTF-8");
    httpPost.setEntity(entity);

    // Authenticate
    if (OOBuildStep.getEncodedCredentials() != null) {
      httpPost.addHeader(
          "Authorization", "Basic " + new String(OOBuildStep.getEncodedCredentials()));
    }

    // Add relevant headers
    httpPost.setHeader(
        "Content-Type", "application/json"); // this is mandatory in order for the request to work

    // Handle CSRF tokens cookies
    client.setCookieStore(handleCsrfCookies(client.getCookieStore()));

    // Execute the request
    HttpResponse response = client.execute(httpPost);

    // Verify the response is 201
    Assert.isTrue(
        response.getStatusLine().getStatusCode() == 201,
        "Invalid response code [" + response.getStatusLine().getStatusCode() + "]");

    // Read the response body
    String responseBody = EntityUtils.toString(response.getEntity());

    //        HttpEntity responseEntity = response.getEntity();
    //        InputStream is = responseEntity.getContent();

    // Extract data from response
    //        JsonObject element = (JsonObject)
    // (parser.parse(OOAccessibilityUtils.convertStreamToString(is)));
    TriggeredExecutionDetailsVO triggeredExecutionDetailsVO =
        gson.fromJson(responseBody, TriggeredExecutionDetailsVO.class);

    runId = triggeredExecutionDetailsVO.getExecutionId();
    listener.getLogger().println("Run ID : " + runId);
    runURL =
        triggeredExecutionDetailsVO.getFeedUrl().split("/oo/")[0]
            + "/oo/#/runtimeWorkspace/runs/"
            + triggeredExecutionDetailsVO.getExecutionId();

    listener.getLogger().println("Execution URL " + runURL);

    return triggeredExecutionDetailsVO;
  }