Revision f43a4cb1
Added by Marc Dequènes over 14 years ago
- ID f43a4cb1f55d9e168f0e458c1af4229e96675767
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
class LdapObject < ActiveLdap::Base
|
||
include LdapElement
|
||
|
||
FULL_HANDLE_PATTERN = /^([a-zA-Z_]+)\/(.+)$/
|
||
|
||
attr_reader :parent_changed
|
||
|
||
@relations_info = {}
|
||
... | ... | |
"#{self.class.handle}/#{self.handle}"
|
||
end
|
||
|
||
def self.looks_like_full_handle?(full_handle)
|
||
full_handle =~ FULL_HANDLE_PATTERN
|
||
$~
|
||
end
|
||
|
||
def self.cast
|
||
super
|
||
|
||
... | ... | |
raise PreProcessingError, _("The file for the binary field '%s' cannot be read: ") % [field, $!]
|
||
end
|
||
elsif attr_info.syntax.to_param == "1.3.6.1.4.1.1466.115.121.1.12"
|
||
if val =~ /([a-zA-Z]+)\/([a-zA-Z]+)/
|
||
if val =~ FULL_HANDLE_PATTERN
|
||
obj_hdl = $1.downcase
|
||
item_hdl = $2
|
||
|
||
... | ... | |
end
|
||
|
||
def self.find_by_full_handle(full_handle)
|
||
raise PreProcessingError, _("Bad handle '%s'") % name unless full_handle =~ /^([a-zA-Z]+)\/(.+)$/
|
||
if full_handle == "root" and LdapShadows.const_defined?('Manipulation')
|
||
raw_item_dn = ActiveLdap::Base.base.to_s
|
||
raw_item = ActiveLdap::Base.find(:first, :base => raw_item_dn, :scope => :base)
|
||
info = LdapShadows::Manipulation.raw_item_info(self.shadow, raw_item, raw_item_dn)
|
||
if info.nil?
|
||
raise PreProcessingError, _("No such item 'root'")
|
||
elsif info[:object].nil?
|
||
raise PreProcessingError, _("Root item found, but no corresponding object defined")
|
||
else
|
||
full_handle = info[:full_handle]
|
||
end
|
||
end
|
||
|
||
raise SyntaxError, _("Bad handle '%s'") % full_handle unless full_handle =~ FULL_HANDLE_PATTERN
|
||
obj_hdl = $1.downcase.singularize
|
||
item_hdl = $2
|
||
|
Also available in: Unified diff
[evol] recognize 'root' and understand it as value (but not yet as argument), clarify the full handle format, and recognize the MP root