Merge branch 'master' into 2525-java-sdk
[arvados.git] / services / api / app / models / arvados_model.rb
index ae0e490c6e08c0d2d46ba463181ced01b758a994..154929171fd42ab6485945e6d77e1390178f97c8 100644 (file)
@@ -144,6 +144,8 @@ class ArvadosModel < ActiveRecord::Base
           if x == uuid
             # Test for cycles with the new version, not the DB contents
             x = owner_uuid
+          elsif !owner_class.respond_to? :find_by_uuid
+            raise ActiveRecord::RecordNotFound.new
           else
             x = owner_class.find_by_uuid(x).owner_uuid
           end
@@ -166,7 +168,7 @@ class ArvadosModel < ActiveRecord::Base
   end
 
   def ensure_owner_uuid_is_permitted
-    return false if !current_user
+    raise PermissionDeniedError if !current_user
     self.owner_uuid ||= current_user.uuid
     if self.owner_uuid_changed?
       if current_user.uuid == self.owner_uuid or
@@ -174,7 +176,7 @@ class ArvadosModel < ActiveRecord::Base
         # current_user is, or has :write permission on, the new owner
       else
         logger.warn "User #{current_user.uuid} tried to change owner_uuid of #{self.class.to_s} #{self.uuid} to #{self.owner_uuid} but does not have permission to write to #{self.owner_uuid}"
-        return false
+        raise PermissionDeniedError
       end
     end
     if new_record?