X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4d629923847cac25ed6bdaf5c96e1f33a1a8e0c8..6f6c9a2c6e7b871ad9ee592f45ebfdb7f5f26ee1:/services/api/app/models/arvados_model.rb diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index 20b260696c..25d73178c7 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -185,6 +185,10 @@ class ArvadosModel < ActiveRecord::Base %w(modified_by_client_uuid) end + def skip_uuid_existence_check + [] + end + def normalize_collection_uuids foreign_key_attributes.each do |attr| attr_value = send attr @@ -223,11 +227,18 @@ class ArvadosModel < ActiveRecord::Base foreign_key_attributes.each do |attr| if new_record? or send (attr + "_changed?") + next if skip_uuid_existence_check.include? attr attr_value = send attr - r = ArvadosModel::resource_class_for_uuid attr_value if attr_value - r = r.readable_by(current_user) if r and not skip_uuid_read_permission_check.include? attr - if r and r.where(uuid: attr_value).count == 0 and not specials.include? attr_value - errors.add(attr, "'#{attr_value}' not found") + next if specials.include? attr_value + if attr_value + if (r = ArvadosModel::resource_class_for_uuid attr_value) + unless skip_uuid_read_permission_check.include? attr + r = r.readable_by(current_user) + end + if r.where(uuid: attr_value).count == 0 + errors.add(attr, "'#{attr_value}' not found") + end + end end end end