projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '2762-owner-uuid-integrity'
[arvados.git]
/
services
/
api
/
app
/
models
/
link.rb
diff --git
a/services/api/app/models/link.rb
b/services/api/app/models/link.rb
index cf4ffce8ed8b1e0a7894742a7c9993955a46ebce..af3918551e441a2ccaea47ea67e19e8f23a73b1f 100644
(file)
--- a/
services/api/app/models/link.rb
+++ b/
services/api/app/models/link.rb
@@
-1,5
+1,5
@@
class Link < ArvadosModel
class Link < ArvadosModel
- include
Assign
Uuid
+ include
Has
Uuid
include KindAndEtag
include CommonApiTemplate
serialize :properties, Hash
include KindAndEtag
include CommonApiTemplate
serialize :properties, Hash
@@
-8,6
+8,8
@@
class Link < ArvadosModel
after_update :maybe_invalidate_permissions_cache
after_create :maybe_invalidate_permissions_cache
after_destroy :maybe_invalidate_permissions_cache
after_update :maybe_invalidate_permissions_cache
after_create :maybe_invalidate_permissions_cache
after_destroy :maybe_invalidate_permissions_cache
+ attr_accessor :head_kind, :tail_kind
+ validate :name_link_has_valid_name
api_accessible :user, extend: :common do |t|
t.add :tail_uuid
api_accessible :user, extend: :common do |t|
t.add :tail_uuid
@@
-50,7
+52,7
@@
class Link < ArvadosModel
# All users can grant permissions on objects they own
head_obj = self.class.
# All users can grant permissions on objects they own
head_obj = self.class.
-
kind_class
(self.head_uuid).
+
resource_class_for_uuid
(self.head_uuid).
where('uuid=?',head_uuid).
first
if head_obj
where('uuid=?',head_uuid).
first
if head_obj
@@
-80,4
+82,14
@@
class Link < ArvadosModel
User.invalidate_permissions_cache
end
end
User.invalidate_permissions_cache
end
end
+
+ def name_link_has_valid_name
+ if link_class == 'name'
+ unless name.is_a? String and !name.empty?
+ errors.add('name', 'must be a non-empty string')
+ end
+ else
+ true
+ end
+ end
end
end