private static IDestinationClientFactory configureDestinationClientFactory()

in import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/ImportAdapter.java [172:208]


  private static IDestinationClientFactory configureDestinationClientFactory(
      IDicomWebClient defaultCstoreDicomWebClient,
      GoogleCredentials credentials,
      Flags flags, boolean backupServicePresent) throws IOException {
    IDestinationClientFactory destinationClientFactory;
    if (flags.sendToAllMatchingDestinations) {
      if (backupServicePresent == false) {
        throw new IllegalArgumentException(
            "backup is not configured properly. '--send_to_all_matching_destinations' flag must be"
                + " used only in pair with backup, local or GCP. Please see readme to configure"
                + " backup.");
      }
      Pair<ImmutableList<Pair<DestinationFilter, IDicomWebClient>>,
          ImmutableList<Pair<DestinationFilter, AetDictionary.Aet>>> multipleDestinations = configureMultipleDestinationTypesMap(
          flags.destinationConfigInline,
          flags.destinationConfigPath,
          DestinationsConfig.ENV_DESTINATION_CONFIG_JSON,
          credentials, flags.useStowOverwrite);

      destinationClientFactory = new MultipleDestinationClientFactory(
          multipleDestinations.getLeft(),
          multipleDestinations.getRight(),
          defaultCstoreDicomWebClient);
    } else { // with or without backup usage.
      if ((flags.destinationConfigPath != null || flags.destinationConfigInline != null)
          && flags.useStowOverwrite) {
        throw new IllegalArgumentException(
            "Must use '--send_to_all_matching_destinations' when using '--stow_overwrite' and"
                + " providing a destination config.");
      }
      destinationClientFactory = new SingleDestinationClientFactory(
          configureDestinationMap(
              flags.destinationConfigInline, flags.destinationConfigPath, credentials, flags.useStowOverwrite),
          defaultCstoreDicomWebClient);
    }
    return destinationClientFactory;
  }