public void run()

in import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/cstore/backup/BackupUploadService.java [187:234]


    public void run() {
      try {
        InputStream inputStream = readBackupExceptionally();
        webClient.stowRs(inputStream);
        logSuccessUpload();
      } catch (DicomWebException dwe) {
        logUploadFailed(dwe);

        // If we get a conflict, and want to overwrite, then delete and retry. This
        // could run several times if the instance is being recreated by others (non-atomic).
        // Note that if the md5 of the instances match, we will get a HTTP 200. We will only get
        // an HTTP 409 when there is a difference in the MD5 between the instances
        int httpCode = dwe.getHttpStatus();
        Boolean isHttpConflictAndRetry =
            httpCode == HttpStatusCodes.STATUS_CODE_CONFLICT && webClient.getStowOverwrite();
        if (isHttpConflictAndRetry) {
          try {
            InputStream deleteInputStream = readBackupExceptionally();
            webClient.delete(deleteInputStream);
            log.debug("stowOverwrite: instance deleted");
          } catch (DicomWebException innerDwe) {
            MonitoringService.addEvent(Event.CSTORE_ERROR);
            throw new CompletionException(innerDwe);
          }
        }

        if (filterHttpCode(httpCode) || isHttpConflictAndRetry) {
          if (backupState.getAttemptsCountdown() > 0) {
            try {
              scheduleUploadWithDelay(
                  backupState,
                  new HealthcareDestinationUploadAsyncJob(webClient, backupState),
                  delayCalculator.getExponentialDelayMillis(backupState.getAttemptsCountdown(), attemptsAmount))
                      .get();

            } catch (BackupException | ExecutionException | InterruptedException ex) {
              throw new CompletionException(ex);
            }
          } else {
            MonitoringService.addEvent(Event.CSTORE_ERROR);
            throwOnNoResendAttemptsLeft(dwe, uniqueFileName);
          }
        } else {
          MonitoringService.addEvent(Event.CSTORE_ERROR);
          throwOnHttpFilterFail(dwe, dwe.getHttpStatus(), uniqueFileName);
        }
      }
    }