Module: Zimbra::DirectoryService::Parser
- Defined in:
- lib/zimbra/directory.rb
Class Method Summary collapse
-
.clean_node(node) ⇒ Object
This method is to erase all others nodes from document so the xpath search like (//xxxx) works, beacuse (//) always start at the beginning of the document, not the current element.
- .get_grants_response(response, type) ⇒ Object
-
.object_list_response(node, type) ⇒ Object
This just call the parser_response method of the object in the case of the account type, it will call Zimbra::AccountService::Parser.account_response(node).
- .search_directory_response(response, type) ⇒ Object
Class Method Details
.clean_node(node) ⇒ Object
This method is to erase all others nodes from document so the xpath search like (//xxxx) works, beacuse (//) always start at the beginning of the document, not the current element
164 165 166 167 168 169 170 |
# File 'lib/zimbra/directory.rb', line 164 def clean_node(node) element = node.instance_variable_get("@element") directory_response = element.document.css("n2|SearchDirectoryResponse", 'n2' => 'urn:zimbraAdmin').first directory_response.children.each {|c| c.remove} directory_response.add_child element node end |
.get_grants_response(response, type) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/zimbra/directory.rb', line 138 def get_grants_response(response, type) result = [] grants = (response/"//n2:grant") grants.each do |n| hash = {} hash[:grantee_id] = (n/'n2:grantee'/'@id').to_s hash[:grantee_class] = Zimbra::ACL::TARGET_MAPPINGS[(n/'n2:grantee'/'@type').to_s] hash[:grantee_name] = (n/'n2:grantee'/'@name').to_s hash[:name] = (n/'n2:right').to_s result << Zimbra::ACL.new(hash) end result end |
.object_list_response(node, type) ⇒ Object
This just call the parser_response method of the object in the case of the account type, it will call Zimbra::AccountService::Parser.account_response(node)
155 156 157 158 159 |
# File 'lib/zimbra/directory.rb', line 155 def object_list_response(node, type) node = clean_node node class_name = ZIMBRA_TYPES_HASH[type][:class].name.gsub(/Zimbra::/, '') Zimbra::BaseService::Parser.response(class_name, node, false) end |
.search_directory_response(response, type) ⇒ Object
132 133 134 135 136 |
# File 'lib/zimbra/directory.rb', line 132 def search_directory_response(response, type) # look for the node given by the type items = (response/"//n2:#{ZIMBRA_TYPES_HASH[type][:node_name]}") items.map { |i| object_list_response(i, type) } end |