[ARVADOS] updated: 22457e13e9c758f2c4a38326fa181607997bf023

git at public.curoverse.com git at public.curoverse.com
Thu Aug 14 14:48:37 EDT 2014


Summary of changes:
 .../arvados/v1/collections_controller.rb           | 47 +++-------------------
 .../app/controllers/arvados/v1/jobs_controller.rb  |  2 +-
 services/api/app/helpers/collections_helper.rb     |  8 ++++
 services/api/app/models/arvados_model.rb           | 21 ----------
 4 files changed, 14 insertions(+), 64 deletions(-)

       via  22457e13e9c758f2c4a38326fa181607997bf023 (commit)
       via  b1863eca14e92621dbea60367527ce30288ea853 (commit)
      from  51e6edf73c9dff7faa6fa4bcadc850b8cdcfea11 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 22457e13e9c758f2c4a38326fa181607997bf023
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Aug 14 14:48:32 2014 -0400

    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.

diff --git a/services/api/app/controllers/arvados/v1/jobs_controller.rb b/services/api/app/controllers/arvados/v1/jobs_controller.rb
index 6bd2c4d..8ea5ebd 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 3017985..020bdbe 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 f853565..5c23674 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

commit b1863eca14e92621dbea60367527ce30288ea853
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Aug 14 14:47:07 2014 -0400

    3036: Removed special case find_object_by_uuid.  Converted some queries that
    interact with jobs to use portable_data_hash instead of uuid.

diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb
index 48002d7..0ed5fd0 100644
--- a/services/api/app/controllers/arvados/v1/collections_controller.rb
+++ b/services/api/app/controllers/arvados/v1/collections_controller.rb
@@ -1,10 +1,5 @@
 class Arvados::V1::CollectionsController < ApplicationController
   def create
-    # Collections are owned by system_user. Creating a collection has
-    # two effects: The collection is added if it doesn't already
-    # exist, and a "permission" Link is added (if one doesn't already
-    # exist) giving the current user (or specified owner_uuid)
-    # permission to read it.
     owner_uuid = resource_attrs.delete(:owner_uuid) || current_user.uuid
     unless current_user.can? write: owner_uuid
       logger.warn "User #{current_user.andand.uuid} tried to set collection owner_uuid to #{owner_uuid}"
@@ -83,15 +78,6 @@ class Arvados::V1::CollectionsController < ApplicationController
     render json: @object.as_api_response(:with_data)
   end
 
-  def collection_uuid(uuid)
-    m = /([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?/.match(uuid)
-    if m
-      m[1]
-    else
-      nil
-    end
-  end
-
   def script_param_edges(visited, sp)
     case sp
     when Hash
@@ -104,7 +90,7 @@ class Arvados::V1::CollectionsController < ApplicationController
       end
     when String
       return if sp.empty?
-      m = collection_uuid(sp)
+      m = stripped_portable_data_hash(sp)
       if m
         generate_provenance_edges(visited, m)
       end
@@ -112,7 +98,7 @@ class Arvados::V1::CollectionsController < ApplicationController
   end
 
   def generate_provenance_edges(visited, uuid)
-    m = collection_uuid(uuid)
+    m = stripped_portable_data_hash(uuid)
     uuid = m if m
 
     if not uuid or uuid.empty? or visited[uuid]
@@ -123,7 +109,7 @@ class Arvados::V1::CollectionsController < ApplicationController
 
     if m
       # uuid is a collection
-      Collection.readable_by(current_user).where(uuid: uuid).each do |c|
+      Collection.readable_by(current_user).where(portable_data_hash: uuid).each do |c|
         visited[uuid] = c.as_api_response
         visited[uuid][:files] = []
         c.files.each do |f|
@@ -160,8 +146,6 @@ class Arvados::V1::CollectionsController < ApplicationController
       visited[link.uuid] = link.as_api_response
       generate_provenance_edges(visited, link.tail_uuid)
     end
-
-    #puts "finished #{uuid}"
   end
 
   def provenance
@@ -171,7 +155,7 @@ class Arvados::V1::CollectionsController < ApplicationController
   end
 
   def generate_used_by_edges(visited, uuid)
-    m = collection_uuid(uuid)
+    m = stripped_portable_data_hash(uuid)
     uuid = m if m
 
     if not uuid or uuid.empty? or visited[uuid]
@@ -182,7 +166,7 @@ class Arvados::V1::CollectionsController < ApplicationController
 
     if m
       # uuid is a collection
-      Collection.readable_by(current_user).where(uuid: uuid).each do |c|
+      Collection.readable_by(current_user).where(portable_data_hash: uuid).each do |c|
         visited[uuid] = c.as_api_response
         visited[uuid][:files] = []
         c.files.each do |f|
@@ -220,8 +204,6 @@ class Arvados::V1::CollectionsController < ApplicationController
       visited[link.uuid] = link.as_api_response
       generate_used_by_edges(visited, link.head_uuid)
     end
-
-    #puts "finished #{uuid}"
   end
 
   def used_by
@@ -230,23 +212,4 @@ class Arvados::V1::CollectionsController < ApplicationController
     render json: visited
   end
 
-  protected
-  def find_object_by_uuid
-    super
-    if !@object and !params[:uuid].match(/^[0-9a-f]+\+\d+$/)
-      # Normalize the given uuid and search again.
-      hash_part = params[:uuid].match(/^([0-9a-f]*)/)[1]
-      collection = Collection.where('uuid like ?', hash_part + '+%').first
-      if collection
-        # We know the collection exists, and what its real uuid is in
-        # the database. Now, throw out @objects and repeat the usual
-        # lookup procedure. (Returning the collection at this point
-        # would bypass permission checks.)
-        @objects = nil
-        @where = { uuid: collection.uuid }
-        find_objects_for_index
-        @object = @objects.first
-      end
-    end
-  end
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list