Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>
<pre>
Collections:
ManagedProperties:
- foo: {value: bar}
+ foo: {Value: bar}
</pre>
h4. Original owner UUID
<pre>
Collections:
ManagedProperties:
- responsible_person_uuid: {function: original_owner}
+ responsible_person_uuid: {Function: original_owner}
</pre>
h4. Protected properties
-If there's a need to prevent a non-admin user from modifying a specific property, even by its owner, the @protected@ attribute can be set to @true@, like so:
+If there's a need to prevent a non-admin user from modifying a specific property, even by its owner, the @Protected@ attribute can be set to @true@, like so:
<pre>
Collections:
ManagedProperties:
- responsible_person_uuid: {function: original_owner, protected: true}
+ responsible_person_uuid: {Function: original_owner, Protected: true}
</pre>
This property can be applied to any of the defined managed properties. If missing, it's assumed as being @false@ by default.
When enabling this feature, there may be pre-existing collections that won't have the managed properties just configured. The following script examples may be helpful to sync these older collections.
-For the following examples we assume that the @responsible_person_uuid@ property is set as @{function: original_owner, protected: true}@.
+For the following examples we assume that the @responsible_person_uuid@ property is set as @{Function: original_owner, Protected: true}@.
h4. List uuid/names of collections without @responsible_person_uuid@ property
This example can be useful to change responsibility from one user to another.
-Please note that the following code should run with admin privileges, assuming that the managed property is @protected@.
+Please note that the following code should run with admin privileges, assuming that the managed property is @Protected@.
{% codeblock as python %}
{% include 'admin_update_collection_property_py' %}
# one of the following behaviors:
#
# * UUID of the user who owns the containing project.
- # responsible_person_uuid: {function: original_owner, protected: true}
+ # responsible_person_uuid: {Function: original_owner, Protected: true}
#
# * Default concrete value.
- # foo_bar: {value: baz, protected: false}
+ # foo_bar: {Value: baz, Protected: false}
#
- # If protected is true, only an admin user can modify its value.
+ # If Protected is true, only an admin user can modify its value.
ManagedProperties:
- SAMPLE: {function: original_owner, protected: true}
+ SAMPLE: {Function: original_owner, Protected: true}
Login:
# These settings are provided by your OAuth2 provider (e.g.,
before_validation :default_empty_manifest
before_validation :default_storage_classes, on: :create
- before_validation :default_properties, on: :create
+ before_validation :managed_properties, on: :create
before_validation :check_encoding
before_validation :check_manifest_validity
before_validation :check_signatures
validate :ensure_storage_classes_contain_non_empty_strings
validate :versioning_metadata_updates, on: :update
validate :past_versions_cannot_be_updated, on: :update
- validate :protected_default_properties_updates, on: :update
+ validate :protected_managed_properties_updates, on: :update
after_validation :set_file_count_and_total_size
before_save :set_file_names
around_update :manage_versioning, unless: :is_past_version?
self.storage_classes_confirmed ||= []
end
- # Sets default properties at creation time
- def default_properties
- default_props = Rails.configuration.Collections.ManagedProperties.with_indifferent_access
- if default_props.empty?
+ # Sets managed properties at creation time
+ def managed_properties
+ managed_props = Rails.configuration.Collections.ManagedProperties.with_indifferent_access
+ if managed_props.empty?
return
end
- (default_props.keys - self.properties.keys).each do |key|
- if default_props[key].has_key?('value')
- self.properties[key] = default_props[key]['value']
- elsif default_props[key]['function'].andand == 'original_owner'
+ (managed_props.keys - self.properties.keys).each do |key|
+ if managed_props[key].has_key?('Value')
+ self.properties[key] = managed_props[key]['Value']
+ elsif managed_props[key]['Function'].andand == 'original_owner'
self.properties[key] = self.user_owner_uuid
else
- logger.warn "Unidentified default property definition '#{key}': #{default_props[key].inspect}"
+ logger.warn "Unidentified default property definition '#{key}': #{managed_props[key].inspect}"
end
end
end
end
end
- def protected_default_properties_updates
- default_properties = Rails.configuration.Collections.ManagedProperties.with_indifferent_access
- if default_properties.empty? || !properties_changed? || current_user.is_admin
+ def protected_managed_properties_updates
+ managed_properties = Rails.configuration.Collections.ManagedProperties.with_indifferent_access
+ if managed_properties.empty? || !properties_changed? || current_user.is_admin
return true
end
- protected_props = default_properties.keys.select do |p|
- Rails.configuration.Collections.ManagedProperties[p]['protected']
+ protected_props = managed_properties.keys.select do |p|
+ Rails.configuration.Collections.ManagedProperties[p]['Protected']
end
# Pre-existent protected properties can't be updated
invalid_updates = properties_was.keys.select{|p| properties_was[p] != properties[p]} & protected_props
assert_empty Collection.where(uuid: uuid)
end
- test "create collections with default properties" do
+ test "create collections with managed properties" do
Rails.configuration.Collections.ManagedProperties = {
- 'default_prop1' => {'value' => 'prop1_value'},
- 'responsible_person_uuid' => {'function' => 'original_owner'}
+ 'default_prop1' => {'Value' => 'prop1_value'},
+ 'responsible_person_uuid' => {'Function' => 'original_owner'}
}
# Test collection without initial properties
act_as_user users(:active) do
end
end
- test "update collection with protected default properties" do
+ test "update collection with protected managed properties" do
Rails.configuration.Collections.ManagedProperties = {
- 'default_prop1' => {'value' => 'prop1_value', 'protected' => true},
+ 'default_prop1' => {'Value' => 'prop1_value', 'Protected' => true},
}
act_as_user users(:active) do
c = create_collection 'foo', Encoding::US_ASCII