put back :find_object_by_uuid in virtual_machines controller
[arvados.git] / services / api / app / models / job.rb
index bb67bda97aa6d6eb86d4012e412e0c42ddd5bf2d..c299d9d73f66eef3372c0201040e45b217b1182a 100644 (file)
@@ -75,18 +75,25 @@ class Job < ArvadosModel
 
   def dependencies
     deps = {}
-    self.script_parameters.values.each do |v|
-      next unless v.is_a? String
-      v.match(/^(([0-9a-f]{32})\b(\+[^,]+)?,?)*$/) do |locator|
-        deps[locator] = true
+    queue = self.script_parameters.values
+    while not queue.empty?
+      queue = queue.flatten.compact.collect do |v|
+        if v.is_a? Hash
+          v.values
+        elsif v.is_a? String
+          v.match(/^(([0-9a-f]{32})\b(\+[^,]+)?,?)*$/) do |locator|
+            deps[locator.to_s] = true
+          end
+          nil
+        end
       end
     end
     deps.keys
   end
 
   def permission_to_update
-    if is_locked_by_was and !(current_user and
-                              current_user.uuid == is_locked_by_was)
+    if is_locked_by_uuid_was and !(current_user and
+                                   current_user.uuid == is_locked_by_uuid_was)
       if script_changed? or
           script_parameters_changed? or
           script_version_changed? or
@@ -104,14 +111,14 @@ class Job < ArvadosModel
         return false
       end
     end
-    if !is_locked_by_changed?
+    if !is_locked_by_uuid_changed?
       super
     else
       if !current_user
         logger.warn "Anonymous user tried to change lock on #{self.class.to_s} #{uuid_was}"
         false
-      elsif is_locked_by_was and is_locked_by_was != current_user.uuid
-        logger.warn "User #{current_user.uuid} tried to steal lock on #{self.class.to_s} #{uuid_was} from #{is_locked_by_was}"
+      elsif is_locked_by_uuid_was and is_locked_by_uuid_was != current_user.uuid
+        logger.warn "User #{current_user.uuid} tried to steal lock on #{self.class.to_s} #{uuid_was} from #{is_locked_by_uuid_was}"
         false
       elsif !is_locked_by_uuid.nil? and is_locked_by_uuid != current_user.uuid
         logger.warn "User #{current_user.uuid} tried to lock #{self.class.to_s} #{uuid_was} with uuid #{is_locked_by_uuid}"