class LicenseAcceptance::Acceptor

def check_and_persist(product_id, version)

def check_and_persist(product_id, version)
  if accepted_no_persist?
    logger.debug("Chef License accepted with no persistence")
    @acceptance_value = ACCEPT_NO_PERSIST
    return true
  end
  product_relationship = product_reader.lookup(product_id, version)
  missing_licenses = file_strategy.accepted?(product_relationship)
  # They have already accepted all licenses and stored their acceptance in the persistent files
  if missing_licenses.empty?
    logger.debug("All licenses present")
    @acceptance_value = ACCEPT
    return true
  end
  if accepted? || accepted_silent?
    if config.persist
      errs = file_strategy.persist(product_relationship, missing_licenses)
      if errs.empty?
        output_num_persisted(missing_licenses.size) unless accepted_silent?
      else
        output_persist_failed(errs)
      end
    end
    @acceptance_value = accepted_silent? ? ACCEPT_SILENT : ACCEPT
    return true
  elsif config.output.isatty && prompt_strategy.request(missing_licenses) do
      # We have to infer the acceptance value if they use the prompt to accept
      if config.persist
        @acceptance_value = ACCEPT
        file_strategy.persist(product_relationship, missing_licenses)
      else
        @acceptance_value = ACCEPT_NO_PERSIST
        []
      end
    end
    return true
  else
    raise LicenseNotAcceptedError.new(product_relationship.parent, missing_licenses)
  end
end