From 22457e13e9c758f2c4a38326fa181607997bf023 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 14 Aug 2014 14:48:32 -0400 Subject: [PATCH] 3036: Removed special case normalize_collection_uuids. Removed special case 'name' links granting read permission. Renamed helper function "collection_uuid" to "stripped_portable_data_hash" and moved to helpers directory. --- .../controllers/arvados/v1/jobs_controller.rb | 2 +- .../api/app/helpers/collections_helper.rb | 8 +++++++ services/api/app/models/arvados_model.rb | 21 ------------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/services/api/app/controllers/arvados/v1/jobs_controller.rb b/services/api/app/controllers/arvados/v1/jobs_controller.rb index 6bd2c4d491..8ea5ebd050 100644 --- a/services/api/app/controllers/arvados/v1/jobs_controller.rb +++ b/services/api/app/controllers/arvados/v1/jobs_controller.rb @@ -71,7 +71,7 @@ class Arvados::V1::JobsController < ApplicationController # We'll use this if we don't find a job that has completed incomplete_job ||= j else - if Collection.readable_by(current_user).find_by_uuid(j.output) + if Collection.readable_by(current_user).find_by_portable_data_hash(j.output) # Record the first job in the list if !@object @object = j diff --git a/services/api/app/helpers/collections_helper.rb b/services/api/app/helpers/collections_helper.rb index 30179854a2..020bdbe020 100644 --- a/services/api/app/helpers/collections_helper.rb +++ b/services/api/app/helpers/collections_helper.rb @@ -1,2 +1,10 @@ module CollectionsHelper + def stripped_portable_data_hash(uuid) + m = /([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?/.match(uuid) + if m + m[1] + else + nil + end + end end diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index f853565c20..5c23674e31 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -22,7 +22,6 @@ class ArvadosModel < ActiveRecord::Base after_destroy :log_destroy after_find :convert_serialized_symbols_to_strings validate :ensure_serialized_attribute_type - validate :normalize_collection_uuids validate :ensure_valid_uuids # Note: This only returns permission links. It does not account for @@ -146,12 +145,6 @@ class ArvadosModel < ActiveRecord::Base sql_params += [uuid_list] end - if sql_table == "collections" and users_list.any? - # There is a 'name' link going from a readable group to the collection. - name_links = "(SELECT head_uuid FROM links WHERE link_class='name' AND tail_uuid IN (#{sanitized_uuid_list}))" - sql_conds += ["#{sql_table}.uuid IN #{name_links}"] - end - # Link head points to this row, or to the owner of this row (the thing to be read) # # Link tail originates from this user, or a group that is readable by this @@ -362,20 +355,6 @@ class ArvadosModel < ActiveRecord::Base [] end - def normalize_collection_uuids - foreign_key_attributes.each do |attr| - attr_value = send attr - if attr_value.is_a? String and - attr_value.match /^[0-9a-f]{32,}(\+[@\w]+)*$/ - begin - send "#{attr}=", Collection.normalize_uuid(attr_value) - rescue - # TODO: abort instead of silently accepting unnormalizable value? - end - end - end - end - @@UUID_REGEX = /^[0-9a-z]{5}-([0-9a-z]{5})-[0-9a-z]{15}$/ @@prefixes_hash = nil -- 2.39.5