Merge branch '10287-sso-username' refs #10287
[arvados.git] / services / api / app / models / arvados_model.rb
index f89e9f405946ddcb34d814c3fb953a34fb51497f..672374bc6c768f4f7bd8be0ba81daf2fbefa1629 100644 (file)
@@ -42,13 +42,13 @@ class ArvadosModel < ActiveRecord::Base
 
   class AlreadyLockedError < StandardError
     def http_status
-      403
+      422
     end
   end
 
   class InvalidStateTransitionError < StandardError
     def http_status
-      403
+      422
     end
   end
 
@@ -271,6 +271,18 @@ class ArvadosModel < ActiveRecord::Base
 
   protected
 
+  def self.deep_sort_hash(x)
+    if x.is_a? Hash
+      x.sort.collect do |k, v|
+        [k, deep_sort_hash(v)]
+      end.to_h
+    elsif x.is_a? Array
+      x.collect { |v| deep_sort_hash(v) }
+    else
+      x
+    end
+  end
+
   def ensure_ownership_path_leads_to_user
     if new_record? or owner_uuid_changed?
       uuid_in_path = {owner_uuid => true, uuid => true}
@@ -518,7 +530,7 @@ class ArvadosModel < ActiveRecord::Base
   end
 
   def self.uuid_like_pattern
-    "_____-#{uuid_prefix}-_______________"
+    "#{Rails.configuration.uuid_prefix}-#{uuid_prefix}-_______________"
   end
 
   def self.uuid_regex