Project

General

Profile

« Previous | Next » 

Revision 7414a658

Added by Marc Dequènes about 15 years ago

  • ID 7414a658751edfa655cedee01a9304ce19c8fc38

[evol] better parent definition for new items (not tested yet)

View differences:

bin/shadowwalker
self.short_desc = "Modify attributes of an item"
self.usages_params = [
"<item-full-handle> (<field>|<relation>|:aspects)(=|+=|-=)<value> [(<field>|<relation>|:aspects)(=|+=|-=)<value>] ..."
"<item-full-handle> (<field>|<relation>|:aspects)(=|+=|-=)<value> [(<field>|<relation>|:aspects|:parent)(=|+=|-=)<value>] ..."
]
end
......
self.short_desc = "Create an item"
self.usages_params = [
"<new-item-full-handle> <parent-item-full-handle> [<field>=<value>] ..."
"<new-item-full-handle> <parent-item-full-handle> [<field>=<value>|<relation>|:aspects|:parent)(=|+=|-=)<value>] ..."
]
end
......
super
obj_klass, item_hdl = params_shift_item_handle_full_handle(args, false)
loc_obj_klass, loc_item = params_shift_item_handle_full_handle(args, true, "parent full-handle")
# TODO: move this in LdapShadows::Manipulation
p_hdl_restr = obj_klass.parameters[:mapping][:parent_handle_restrictions]
unless p_hdl_restr.nil? or loc_item.full_handle =~ Regexp.new(p_hdl_restr)
raise PreProcessingError, _("This parent can't raise such a child (handle restrictions)")
end
p_dn_restr = obj_klass.parameters[:mapping][:parent_dn_restrictions]
unless p_dn_restr.nil? or loc_item.dn =~ Regexp.new(p_dn_restr)
raise PreProcessingError, _("This parent can't raise such a child (DN restrictions)")
end
item = obj_klass.new(item_hdl)
item.base = loc_item.dn_obj - obj_klass.base_obj
modification_done = LdapShadows::Manipulation.item_modify_from_strings(item, args)
#item.save!
# TODO: use default parent for such object if defined (-> predefined hook)
# TODO: detect if parent specified and allowed (-> predefined hook)
item.save!
puts "Creation done."
end
end

Also available in: Unified diff