public void run()

in import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindService.java [107:161]


    public void run() {
      try {
        if (canceled) {
          throw new CancellationException();
        }
        runThread = Thread.currentThread();

        String[] qidoPaths = AttributesUtil.attributesToQidoPathArray(keys);
        List<JSONArray> qidoResults = new ArrayList<>();
        for (String qidoPath : qidoPaths) {
          if (canceled) {
            throw new CancellationException();
          }
          if (cFINDFlags != null && cFINDFlags.fuzzyMatching)   {
	      qidoPath += "fuzzymatching=true" + "&";
          }
          log.info("CFind QidoPath: " + qidoPath);
          MonitoringService.addEvent(Event.CFIND_QIDORS_REQUEST);
          JSONArray qidoResult = dicomWebClient.qidoRs(qidoPath);
          qidoResults.add(qidoResult);
        }
        HashMap<String, JSONObject> uniqueResults = uniqueResults(qidoResults);

        for (JSONObject obj : uniqueResults.values()) {
          if (canceled) {
            throw new CancellationException();
          }
          Attributes attrs = AttributesUtil.jsonToAttributes(obj);
          String queryRetrieveLevel = keys.getString(Tag.QueryRetrieveLevel);
          if (queryRetrieveLevel != null) {
            attrs.setString(Tag.QueryRetrieveLevel, VR.CS, queryRetrieveLevel);
          }
          as.writeDimseRSP(pc, Commands.mkCFindRSP(cmd, Status.Pending), attrs);
        }
        as.writeDimseRSP(pc, Commands.mkCFindRSP(cmd, Status.Success));
      } catch (CancellationException e) {
        log.info("Canceled CFind", e);
        MonitoringService.addEvent(Event.CFIND_CANCEL);
        as.tryWriteDimseRSP(pc, Commands.mkCFindRSP(cmd, Status.Cancel));
      } catch (IDicomWebClient.DicomWebException e) {
        log.error("CFind Qido-rs error", e);
        MonitoringService.addEvent(Event.CFIND_QIDORS_ERROR);
        sendErrorResponse(e.getStatus(), e.getMessage());
      } catch (Throwable e) {
        log.error("Failure processing CFind", e);
        MonitoringService.addEvent(Event.CFIND_ERROR);
        sendErrorResponse(Status.ProcessingFailure, e.getMessage());
      } finally {
        synchronized (this) {
          runThread = null;
        }
        int msgId = cmd.getInt(Tag.MessageID, -1);
        as.removeCancelRQHandler(msgId);
      }
    }