class DTK::Client::Violation

Public Class Methods

fix_violations(service_id, violation_hash_array) click to toggle source
# File lib/violation.rb, line 33
def self.fix_violations(service_id, violation_hash_array)
  violation_objects = violation_hash_array.map { |violation_hash| Violation.create?(service_id, violation_hash) }.compact
  if violation_objects.empty?
    Fix::Result.ok
  else
    run_fix_wizard(violation_objects) 
  end
end
new(service_id, violation_hash) click to toggle source
# File lib/violation.rb, line 27
def initialize(service_id, violation_hash)
  @service_id  = service_id
  @description = violation_hash['description']
end

Private Class Methods

create?(service_id, violation_hash) click to toggle source
# File lib/violation.rb, line 44
def self.create?(service_id, violation_hash)
  unless violation_type = violation_hash['type']
    DtkLogger.error "No type in violation hash: #{violation_hash.inspect}"
    return nil
  end

  case violation_type
   when 'required_unset_attribute'
    RequiredUnsetAttribute.new(service_id, violation_hash)
   when 'illegal_attribute_value'
    IllegalAttributeValue.new(service_id, violation_hash)
   when 'invalid_credentials'
    InvalidCredentials.new(service_id, violation_hash)
   else
    DtkLogger.error "untreated violation type '#{violation_type}'"
    nil
  end
end
run_and_repeat_when_error(violation) click to toggle source
# File lib/violation.rb, line 73
def self.run_and_repeat_when_error(violation)
  result = violation.get_input_and_apply_fix
  if result.error? 
    result.render_error_msg
    run_and_repeat_when_error(violation) 
  else
    result
  end
end
run_fix_wizard(violation_objects) click to toggle source
# File lib/violation.rb, line 63
def self.run_fix_wizard(violation_objects)
  rerun_violation_check = false
  violation_objects.each do |violation| 
    result = run_and_repeat_when_error(violation)
    return result if result.skip_all?
    rerun_violation_check = true if result.rerun_violation_check?
  end
  rerun_violation_check ? Fix::Result.rerun_violation_check : Fix::Result.ok
end