11652: Merge branch 'master' into 11652-recursive-contents
[arvados.git] / services / api / app / controllers / arvados / v1 / collections_controller.rb
index 2beb1e714d7c3fd1af64731c9023b989caa9ed14..73a7e09c5e69cdd6447d91f1e9d0907c97d143ce 100644 (file)
@@ -3,10 +3,6 @@ require "arvados/keep"
 class Arvados::V1::CollectionsController < ApplicationController
   include DbCurrentTime
 
-  def self.limit_index_columns_read
-    ["manifest_text"]
-  end
-
   def create
     if resource_attrs[:uuid] and (loc = Keep::Locator.parse(resource_attrs[:uuid]))
       resource_attrs[:portable_data_hash] = loc.to_s
@@ -16,8 +12,8 @@ class Arvados::V1::CollectionsController < ApplicationController
   end
 
   def find_objects_for_index
-    if params[:include_trash] || ['destroy', 'trash'].include?(action_name)
-      @objects = Collection.unscoped.readable_by(*@read_users)
+    if params[:include_trash] || ['destroy', 'trash', 'untrash'].include?(action_name)
+      @objects = Collection.readable_by(*@read_users).unscoped
     end
     super
   end
@@ -67,6 +63,15 @@ class Arvados::V1::CollectionsController < ApplicationController
     show
   end
 
+  def untrash
+    if @object.is_trashed
+      @object.update_attributes!(trash_at: nil)
+    else
+      raise InvalidStateTransitionError
+    end
+    show
+  end
+
   def find_collections(visited, sp, &b)
     case sp
     when ArvadosModel