3527: Support using a Docker image from any stream in a Collection.
[arvados.git] / services / api / lib / current_api_client.rb
index 94bd2b56a887999fa73b6603944a45136cef4bd9..7bd475278ce7d320e643cd2e78e9636f54511995 100644 (file)
@@ -158,4 +158,24 @@ module CurrentApiClient
     $anonymous_user
   end
 
+  def empty_collection_uuid
+    'd41d8cd98f00b204e9800998ecf8427e+0'
+  end
+
+  def empty_collection
+    if not $empty_collection
+      act_as_system_user do
+        ActiveRecord::Base.transaction do
+          $empty_collection = Collection.
+            where(uuid: empty_collection_uuid).
+            first_or_create!(manifest_text: '')
+          Link.where(tail_uuid: anonymous_group.uuid,
+                     head_uuid: empty_collection_uuid,
+                     link_class: 'permission',
+                     name: 'can_read').first_or_create!
+        end
+      end
+    end
+    $empty_collection
+  end
 end