Revision 7414a658
Added by Marc Dequènes almost 15 years ago
- ID 7414a658751edfa655cedee01a9304ce19c8fc38
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
case field
|
||
when 'aspects'
|
||
modify_aspects(op, val)
|
||
when 'parent'
|
||
modify_parent(op, val)
|
||
else
|
||
raise PreProcessingError, _("Unknown core field '%s'") % field
|
||
end
|
||
... | ... | |
true
|
||
end
|
||
|
||
def modify_parent(op, parent_full_handle)
|
||
case op
|
||
when '+=', '-='
|
||
raise PreProcessingError, _("This operator is not possible for parent")
|
||
else
|
||
raise SyntaxError, _("Unknown operator '%s'") % op
|
||
end
|
||
|
||
# TODO: provide such facilities elsewhere
|
||
raise SyntaxError, _("Bad handle '%s' for parent") % name unless parent_full_handle =~ /^([a-zA-Z]+)\/(.+)$/
|
||
parent_obj_hdl = $1.downcase.singularize
|
||
parent_item_hdl = $2
|
||
parent_obj_klass = self.class.shadow.get_object(parent_obj_hdl)
|
||
raise PreProcessingError, _("No such object '%s'") % parent_obj_hdl if parent_obj_klass.nil?
|
||
begin
|
||
parent_item = parent_obj_klass.find(parent_item_hdl, :attributes => attr_list)
|
||
rescue ActiveLdap::EntryNotFound
|
||
raise PreProcessingError, _("No such item '%s/%s'") % [parent_obj_klass.handle, parent_item_hdl]
|
||
end
|
||
|
||
p_hdl_restr = self.class.parameters[:mapping][:parent_handle_restrictions]
|
||
unless p_hdl_restr.nil? or parent_full_handle =~ Regexp.new(p_hdl_restr)
|
||
raise PreProcessingError, _("This parent can't raise such a child (handle restrictions)")
|
||
end
|
||
p_dn_restr = self.class.parameters[:mapping][:parent_dn_restrictions]
|
||
unless p_dn_restr.nil? or parent_item.dn =~ Regexp.new(p_dn_restr)
|
||
raise PreProcessingError, _("This parent can't raise such a child (DN restrictions)")
|
||
end
|
||
|
||
if self.new_entry?
|
||
self.base = parent_item.dn_obj - parent_obj_klass.base_obj
|
||
else
|
||
raise PreProcessingError, _("Moving items is not yet implemented")
|
||
end
|
||
end
|
||
|
||
def add_aspect(aspect_name)
|
||
return unless self.class.possible_aspects.include?(aspect_name)
|
||
|
Also available in: Unified diff
[evol] better parent definition for new items (not tested yet)