Merge branch 'master' into 16811-public-favs
[arvados.git] / services / api / app / controllers / arvados / v1 / collections_controller.rb
index a8ef4b91b4b018f863c0a156e784e05622995893..656bd37ae6e3cf7e53bae89eac6e1b6086257d33 100644 (file)
@@ -56,11 +56,19 @@ class Arvados::V1::CollectionsController < ApplicationController
   end
 
   def find_object_by_uuid
-    @include_old_versions = true
+    if params[:include_old_versions].nil?
+      @include_old_versions = true
+    else
+      @include_old_versions = params[:include_old_versions]
+    end
 
     if loc = Keep::Locator.parse(params[:id])
       loc.strip_hints!
 
+      opts = {}
+      opts.update({include_trash: true}) if params[:include_trash]
+      opts.update({include_old_versions: @include_old_versions})
+
       # It matters which Collection object we pick because we use it to get signed_manifest_text,
       # the value of which is affected by the value of trash_at.
       #
@@ -72,14 +80,13 @@ class Arvados::V1::CollectionsController < ApplicationController
       # it will select the Collection object with the longest
       # available lifetime.
 
-      if c = Collection.readable_by(*@read_users).where({ portable_data_hash: loc.to_s }).order("trash_at desc").limit(1).first
+      if c = Collection.readable_by(*@read_users, opts).where({ portable_data_hash: loc.to_s }).order("trash_at desc").limit(1).first
         @object = {
           uuid: c.portable_data_hash,
           portable_data_hash: c.portable_data_hash,
           manifest_text: c.signed_manifest_text,
         }
       end
-      true
     else
       super
     end
@@ -152,7 +159,7 @@ class Arvados::V1::CollectionsController < ApplicationController
 
       if direction == :search_up
         # Search upstream for jobs where this locator is the output of some job
-        if !Rails.configuration.API.DisabledAPIs.include?("jobs.list")
+        if !Rails.configuration.API.DisabledAPIs["jobs.list"]
           Job.readable_by(*@read_users).where(output: loc.to_s).each do |job|
             search_edges(visited, job.uuid, :search_up)
           end
@@ -176,7 +183,7 @@ class Arvados::V1::CollectionsController < ApplicationController
         end
 
         # Search downstream for jobs where this locator is in script_parameters
-        if !Rails.configuration.API.DisabledAPIs.include?("jobs.list")
+        if !Rails.configuration.API.DisabledAPIs["jobs.list"]
           Job.readable_by(*@read_users).where(["jobs.script_parameters like ?", "%#{loc.to_s}%"]).each do |job|
             search_edges(visited, job.uuid, :search_down)
           end
@@ -245,7 +252,7 @@ class Arvados::V1::CollectionsController < ApplicationController
           if direction == :search_up
             visited[c.uuid] = c.as_api_response
 
-            if !Rails.configuration.API.DisabledAPIs.include?("jobs.list")
+            if !Rails.configuration.API.DisabledAPIs["jobs.list"]
               Job.readable_by(*@read_users).where(output: c.portable_data_hash).each do |job|
                 search_edges(visited, job.uuid, :search_up)
               end