class ZmLdifExport::ZimbraResource

Constants

BLACK_LIST_ATTRS

Attributes

attributes[R]
name[R]
real_attrs[R]

Public Class Methods

attrs_xml() click to toggle source
# File lib/zmldifexport.rb, line 236
def self.attrs_xml
  return @attrs_xml if @attrs_xml
  xml_doc = Nokogiri::XML(open(ZIMBRA_ATTRS_FILE))
  @attrs_xml = xml_doc.xpath('//attr')
  return @attrs_xml
end

Public Instance Methods

attr_to_zmprov(attr_name:, value:, plus: false) click to toggle source
# File lib/zmldifexport.rb, line 290
def attr_to_zmprov(attr_name:, value:, plus: false)
  zm_attr = zimbra_attrs[attr_name]
  zm_attr.to_zmprov(value, plus)
end
id() click to toggle source
# File lib/zmldifexport.rb, line 258
def id
  attributes['zimbraid'].first.to_s
end
invalid_attribute?(attr_name) click to toggle source
# File lib/zmldifexport.rb, line 276
def invalid_attribute?(attr_name)
  return true if BLACK_LIST_ATTRS.include?(attr_name)
  zm_attr = zimbra_attrs[attr_name]
  zm_attr.nil? ? false : zm_attr.immutable?
end
invalid_value?(value) click to toggle source
# File lib/zmldifexport.rb, line 272
def invalid_value?(value)
  return true if value.join('').to_s =~ /null/
end
parse_attributes(ldif:, exclude: []) click to toggle source
# File lib/zmldifexport.rb, line 262
def parse_attributes(ldif:, exclude: [])
  attrs = {}
  ldif.each_attribute do |a|
    value = ldif[a]
    next if invalid_attribute?(a.to_s) || exclude.include?(a) || invalid_value?(value)
    attrs[a.to_s] = value
  end
  attrs
end
to_zmprov(command: 'ca') click to toggle source
# File lib/zmldifexport.rb, line 282
def to_zmprov(command: 'ca')
  zmprov_ca if command == 'ca'
  zmprov_aaa if command == 'aaa'
  zmprov_cdl if command == 'cdl'
  zmprov_adlm if command == 'adlm'
  zmprov_adla if command == 'adla'
end
zimbra_attrs() click to toggle source
# File lib/zmldifexport.rb, line 243
def zimbra_attrs
  return @zimbra_attrs if @zimbra_attrs
  @zimbra_attrs = {}
  ZimbraResource.attrs_xml.each do |attr|
    zm_attr = Attribute.new(attr)
    @zimbra_attrs[zm_attr.name.downcase] = zm_attr
  end
  return @zimbra_attrs
end