refs #4926 Merge branch '4926-getting-started'
[arvados.git] / services / api / app / models / job.rb
index bc64cf57d25bf876439d936efbaaeffef87e3403..0444528b6bda671a4327ef39fff1918fabebf9d8 100644 (file)
@@ -15,7 +15,7 @@ class Job < ArvadosModel
   validate :find_docker_image_locator
   validate :validate_status
   validate :validate_state_change
-  validate :no_collection_uuids
+  validate :ensure_no_collection_uuids_in_script_params
   before_save :update_timestamps_when_state_changes
 
   has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
@@ -311,6 +311,8 @@ class Job < ArvadosModel
     end
     self.running ||= false # Default to false instead of nil.
 
+    @need_crunch_dispatch_trigger = true
+
     true
   end
 
@@ -376,7 +378,7 @@ class Job < ArvadosModel
     ok
   end
 
-  def no_collection_uuids
+  def ensure_no_collection_uuids_in_script_params
     # recursive_hash_search searches recursively through hashes and
     # arrays in 'thing' for string fields matching regular expression
     # 'pattern'.  Returns true if pattern is found, false otherwise.
@@ -398,7 +400,7 @@ class Job < ArvadosModel
     # Fail validation if any script_parameters field includes a string containing a
     # collection uuid pattern.
     if self.script_parameters_changed?
-      if recursive_hash_search(self.script_parameters, /[a-z0-9]{5}-4zz18-[a-z0-9]{15}/)
+      if recursive_hash_search(self.script_parameters, Collection.uuid_regex)
         self.errors.add :script_parameters, "must use portable_data_hash instead of collection uuid"
         return false
       end