/**
   * Primary user method for importing a number of import candidates.
   *
   * @param config The configuration information.
   * @param candidates Hosts information about the files to import.
   * @return if the import did not exit because of an error
   */
  public boolean importCandidates(ImportConfig config, ImportCandidates candidates) {
    List<ImportContainer> containers = candidates.getContainers();
    if (containers != null) {
      int numDone = 0;
      for (int index = 0; index < containers.size(); index++) {
        ImportContainer ic = containers.get(index);
        ImportTarget target = config.getTarget();
        if (target != null) {
          try {
            IObject obj = target.load(store, ic);
            if (!(obj instanceof Annotation)) {
              ic.setTarget(obj);
            } else {
              // This is likely a "post-processing" annotation
              // so that we don't have to resolve the target
              // until later.
              ic.getCustomAnnotationList().add((Annotation) obj);
            }
          } catch (Exception e) {
            log.error("Could not load target: {}", target);
            throw new RuntimeException("Failed to load target", e);
          }
        }

        if (config.checksumAlgorithm.get() != null) {
          ic.setChecksumAlgorithm(config.checksumAlgorithm.get());
        }

        try {
          importImage(ic, index, numDone, containers.size());
          numDone++;
        } catch (Throwable t) {
          String message = "Error on import";
          if (t instanceof ServerError) {
            final ServerError se = (ServerError) t;
            if (StringUtils.isNotBlank(se.message)) {
              message += ": " + se.message;
            }
          }
          log.error(message, t);
          if (!config.contOnError.get()) {
            log.info("Exiting on error");
            return false;
          } else {
            log.info("Continuing after error");
          }
        }
      }
    }
    return true;
  }