/* * Copyright (C) 2006 Registro.br. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * 1. Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ /* $Id: DomParser.cpp 886 2007-03-06 19:39:07Z eduardo $ */ #include "config.h" #include #include #include #include #include #include "DomParser.H" #include "DomErrorHandler.H" #include "XmlException.H" #include "StrUtil.H" using std::map; XERCES_CPP_NAMESPACE_USE LIBEPP_NICBR_NS_BEGIN void DomParser::parse_command(const string &xml_payload) { string utf8_xml_payload; StrUtil::iso88591_to_utf8(xml_payload, utf8_xml_payload); parse(utf8_xml_payload); } void DomParser::parse_login_rsp(const string &xml_payload, Response *rsp) { parse_response(xml_payload, rsp); } void DomParser::parse_logout_rsp(const string &xml_payload, Response *rsp) { parse_response(xml_payload, rsp); } void DomParser::parse_greeting(const string &xml_payload, Greeting *greeting) { DOMNode *n = parse(xml_payload); fill_greeting(n, greeting); } void DomParser::parse_contact_check_rsp(const string &xml_payload, ContactCheckRsp *rsp) { DOMNode *n = parse(xml_payload); fill_contact_check_rsp(n, rsp); } void DomParser::parse_contact_create_rsp(const string &xml_payload, ContactCreateRsp *rsp) { DOMNode *n = parse(xml_payload); fill_contact_create_rsp(n, rsp); } void DomParser::parse_contact_info_rsp(const string &xml_payload, ContactInfoRsp *rsp) { DOMNode *n = parse(xml_payload); fill_contact_info_rsp(n, rsp); } void DomParser::parse_contact_update_rsp(const string &xml_payload, Response *rsp) { return parse_response(xml_payload, rsp); } void DomParser::parse_domain_check_rsp(const string &xml_payload, DomainCheckRsp *rsp) { DOMNode *n = parse(xml_payload); fill_domain_check_rsp(n, rsp); } void DomParser::parse_domain_create_rsp(const string &xml_payload, DomainCreateRsp *rsp) { DOMNode *n = parse(xml_payload); fill_domain_create_rsp(n, rsp); } void DomParser::parse_domain_info_rsp(const string &xml_payload, DomainInfoRsp *rsp) { DOMNode *n = parse(xml_payload); fill_domain_info_rsp(n, rsp); } void DomParser::parse_domain_renew_rsp(const string &xml_payload, DomainRenewRsp *rsp) { DOMNode *n = parse(xml_payload); fill_domain_renew_rsp(n, rsp); } void DomParser::parse_domain_update_rsp(const string &xml_payload, Response *rsp) { return parse_response(xml_payload, rsp); } void DomParser::parse_poll_rsp(const string &xml_payload, PollRsp *rsp) { DOMNode *n = parse(xml_payload); fill_poll_rsp(n, rsp); } void DomParser::parse_response(const string &xml_payload, Response *rsp) { DOMNode *n = parse(xml_payload); fill_response(n, rsp); } void DomParser::get_extValue_info(DOMNode *n, string &value, string &xmlns, string &reason) { DOMNode *child; string elem_name; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } elem_name = str_transcode(child->getNodeName()); if (elem_name == "value") { value = str_transcode(child->getTextContent()); map< string, string, less > attributes = get_attributes(child); map< string, string, less >::const_iterator it; it = attributes.begin(); if (it != attributes.end() && it->first.substr(0, 5) == "xmlns") { xmlns = it->first + "=\"" + it->second + "\""; } } else if (elem_name == "reason") { reason = str_transcode(child->getTextContent()); } } } void DomParser::fill_result(DOMNode *n, Response *rsp) { string msg, lang, value, xmlns, reason, elem_name; Response::ResultCode code; map< string, string, less > attributes = get_attributes(n); code = (Response::ResultCode) atoi(attributes["code"].c_str()); DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) { elem_name = str_transcode(child->getNodeName()); if (elem_name == "msg" && msg == "") { attributes = get_attributes(child); lang = attributes["lang"]; msg = str_transcode(child->getTextContent()); rsp->insert_result(code, msg); } else if (elem_name == "value") { if (code != Response::UNSET && msg != "") { value = str_transcode(child->getTextContent()); map< string, string, less > attributes = get_attributes(n); map< string, string, less >::const_iterator it; it = attributes.begin(); xmlns = ""; if (it != attributes.end() && it->first.substr(0, 5) == "xmlns") { xmlns = it->first + "=\"" + it->second + "\""; } if (value != "" && xmlns != "") { rsp->insert_result(code, msg, value, xmlns); } } } else if (elem_name == "extValue" && msg != "") { value = xmlns = reason = ""; get_extValue_info(child, value, xmlns, reason); if (value != "" && xmlns != "") { rsp->insert_result(code, msg, value, xmlns, reason); } } } } } void DomParser::fill_response(DOMNode *n, Response *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, rsp); } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brdomain:updData") { fill_brdomain_update_rsp(n, (BrDomainUpdateRsp *) rsp); #endif //USE_BR_DOMAINS } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_response(child, rsp); } } } void DomParser::fill_greeting(DOMNode *n, Greeting *greeting) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "greeting") { look_children = true; } else if (elem_name == "svID") { greeting->set_svID(str_transcode(n->getTextContent())); } else if (elem_name == "svDate") { greeting->set_svDate(str_transcode(n->getTextContent())); } else if (elem_name == "svcMenu") { look_children = true; } else if (elem_name == "version") { greeting->set_version(str_transcode(n->getTextContent())); } else if (elem_name == "lang") { greeting->set_lang(str_transcode(n->getTextContent())); } else if (elem_name == "objURI") { greeting->set_objURI(str_transcode(n->getTextContent())); } else if (elem_name == "svcExtension") { look_children = true; } else if (elem_name == "extURI") { greeting->set_extURI(str_transcode(n->getTextContent())); } else if (elem_name == "dcp") { look_children = true; } else if (elem_name == "access") { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) { string e_name = str_transcode(child->getNodeName()); if (e_name == "all") { greeting->set_access(Greeting::ALL); } else if (e_name == "none") { greeting->set_access(Greeting::NONE_AC); } else if (e_name == "null") { greeting->set_access(Greeting::NULL_AC); } else if (e_name == "other") { greeting->set_access(Greeting::OTHER_AC); } else if (e_name == "personal") { greeting->set_access(Greeting::PERSONAL); } else if (e_name == "personalAndOther") { greeting->set_access(Greeting::PERSONAL_AND_OTHER); } } } } else if (elem_name == "statement") { look_children = true; } else if (elem_name == "purpose") { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) { string e_name = str_transcode(child->getNodeName()); if (e_name == "admin") { greeting->set_purpose(Greeting::ADMIN); } else if (e_name == "contact") { greeting->set_purpose(Greeting::CONTACT); } else if (e_name == "other") { greeting->set_purpose(Greeting::OTHER_PR); } else if (e_name == "prov") { greeting->set_purpose(Greeting::PROV); } } } } else if (elem_name == "recipient") { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) { string e_name = str_transcode(child->getNodeName()); if (e_name == "other") { greeting->set_recipient(Greeting::OTHER_RC); } else if (e_name == "ours") { greeting->set_recipient(Greeting::OURS); DOMNode *recDesc = child->getFirstChild(); if (recDesc && recDesc->getNodeType() == DOMNode::ELEMENT_NODE) { if (str_transcode(recDesc->getNodeName()) == "recDesc") { greeting->set_recDesc(str_transcode(recDesc->getTextContent())); } } } else if (e_name == "public") { greeting->set_recipient(Greeting::PUBLIC); } else if (e_name == "same") { greeting->set_recipient(Greeting::SAME); } else if (e_name == "unrelated") { greeting->set_recipient(Greeting::UNRELATED); } } } } else if (elem_name == "retention") { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) { string e_name = str_transcode(child->getNodeName()); if (e_name == "business") { greeting->set_retention(Greeting::BUSINESS); } else if (e_name == "indefinite") { greeting->set_retention(Greeting::INDEFINITE); } else if (e_name == "legal") { greeting->set_retention(Greeting::LEGAL); } else if (e_name == "none") { greeting->set_retention(Greeting::NONE_RT); } else if (e_name == "stated") { greeting->set_retention(Greeting::STATED); } } } } else if (elem_name == "expiry") { look_children = true; } else if (elem_name == "absolute") { greeting->set_expiry(0, str_transcode(n->getTextContent())); } else if (elem_name == "relative") { greeting->set_expiry(1, str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_greeting(child, greeting); } } } void DomParser::fill_contact_check_rsp(DOMNode *n, ContactCheckRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "contact:chkData") { look_children = true; } else if (elem_name == "contact:cd") { DOMNode *child; string id, avail, reason; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string e_name = str_transcode(child->getNodeName()); if (e_name == "contact:id") { map< string, string, less > attributes = get_attributes(child); if (attributes["avail"] != "") { avail = attributes["avail"]; } id = str_transcode(child->getTextContent()); } else if (e_name == "contact:reason") { reason = str_transcode(child->getTextContent()); } } rsp->insert_availability(id, avail, reason); } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brorg:chkData") { //brorg extension fill_brorg_check_rsp(n, (BrOrgCheckRsp*) rsp); #endif //USE_BR_DOMAINS } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_contact_check_rsp(child, rsp); } } } void DomParser::fill_contact_info_rsp(DOMNode *n, ContactInfoRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); CommonData common = rsp->get_common_data(); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "contact:infData") { look_children = true; } else if (elem_name == "contact:id") { common.set_id(str_transcode(n->getTextContent())); } else if (elem_name == "contact:roid") { rsp->set_roid(str_transcode(n->getTextContent())); } else if (elem_name == "contact:status") { map< string, string, less > attributes = get_attributes(n); if (attributes["s"] != "") { rsp->insert_status(attributes["s"]); } } else if (elem_name == "contact:postalInfo") { PostalInfo pi; fill_postal_info(n, &pi); common.insert_postal_info(pi); } else if (elem_name == "contact:voice") { struct CommonData::Phone phone; map< string, string, less > attributes = get_attributes(n); if (attributes["x"] != "") { phone.ext = attributes["x"]; } phone.number = str_transcode(n->getTextContent()); common.set_voice(phone); } else if (elem_name == "contact:fax") { struct CommonData::Phone phone; map< string, string, less > attributes = get_attributes(n); if (attributes["x"] != "") { phone.ext = attributes["x"]; } phone.number = str_transcode(n->getTextContent()); common.set_fax(phone); } else if (elem_name == "contact:email") { string email = str_transcode(n->getTextContent()); common.set_email(email); } else if (elem_name == "contact:clID") { rsp->set_clID(str_transcode(n->getTextContent())); } else if (elem_name == "contact:crID") { rsp->set_crID(str_transcode(n->getTextContent())); } else if (elem_name == "contact:crDate") { rsp->set_crDate(str_transcode(n->getTextContent())); } else if (elem_name == "contact:upID") { rsp->set_upID(str_transcode(n->getTextContent())); } else if (elem_name == "contact:upDate") { rsp->set_upDate(str_transcode(n->getTextContent())); } else if (elem_name == "contact:trDate") { rsp->set_trDate(str_transcode(n->getTextContent())); } else if (elem_name == "contact:authInfo") { struct AuthInfo authInfo; map< string, string, less > attributes = get_attributes(n); if (attributes["roid"] != "") { authInfo.set_roid(attributes["roid"]); } DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string e_name = str_transcode(child->getNodeName()); if (e_name == "contact:pw") { authInfo.set_pw(str_transcode(child->getTextContent())); break; } } rsp->set_authInfo(authInfo); } else if (elem_name == "contact:disclose") { CommonData::Disclose disc; bool has_flag = false; map< string, string, less > attributes = get_attributes(n); if (attributes["flag"] != "") { has_flag = true; if (attributes["flag"] == "0") { disc.flag = false; } else { disc.flag = true; } } if (has_flag) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string e_name = str_transcode(child->getNodeName()); if (e_name == "contact:name") { attributes = get_attributes(n); if (!attributes.empty()) { if (attributes.count("loc") > 0) { disc.name_loc = true; } else if (attributes.count("int") > 0) { disc.name_int = true; } } } else if (e_name == "contact:org") { attributes = get_attributes(n); if (!attributes.empty()) { if (attributes.count("loc") > 0) { disc.org_loc = true; } else if (attributes.count("int") > 0) { disc.org_int = true; } } } else if (e_name == "contact:addr") { attributes = get_attributes(n); if (!attributes.empty()) { if (attributes.count("loc") > 0) { disc.addr_loc = true; } else if (attributes.count("int") > 0) { disc.addr_int = true; } } } else if (e_name == "contact:voice") { disc.voice = true; } else if (e_name == "contact:fax") { disc.fax = true; } else if (e_name == "contact:email") { disc.email = true; } } common.set_disclose(disc); } } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brorg:infData") { fill_brorg_info_rsp(n, (BrOrgInfoRsp *) rsp); #endif //USE_BR_DOMAINS } rsp->set_common_data(common); } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_contact_info_rsp(child, rsp); } } } void DomParser::fill_contact_create_rsp(DOMNode *n, ContactCreateRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "contact:creData") { look_children = true; } else if (elem_name == "contact:id") { rsp->set_id(str_transcode(n->getTextContent())); } else if (elem_name == "contact:crDate") { rsp->set_crDate(str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_contact_create_rsp(child, rsp); } } } void DomParser::fill_contact_pandata_rsp(DOMNode *n, PanDataRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "contact:panData") { look_children = true; } else if (elem_name == "contact:id") { rsp->set_object_id(str_transcode(n->getTextContent())); // attribute map< string, string, less > attributes = get_attributes(n); if (attributes["paResult"] == "1") { rsp->set_paResult(true); } } else if (elem_name == "contact:paTRID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "contact:paDate") { rsp->set_paDate(str_transcode(n->getTextContent())); } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_contact_pandata_rsp(child, rsp); } } } } void DomParser::fill_domain_check_rsp(DOMNode *n, DomainCheckRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "domain:chkData") { look_children = true; } else if (elem_name == "domain:cd") { DOMNode *child; string name, avail, reason; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string e_name = str_transcode(child->getNodeName()); if (e_name == "domain:name") { map< string, string, less > attributes = get_attributes(child); if (attributes["avail"] != "") { avail = attributes["avail"]; } name = str_transcode(child->getTextContent()); } else if (e_name == "domain:reason") { reason = str_transcode(child->getTextContent()); } } rsp->insert_availability(name, avail, reason); } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brdomain:chkData") { //brdomain extension fill_brdomain_check_rsp(n, (BrDomainCheckRsp*) rsp); #endif //USE_BR_DOMAINS } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_domain_check_rsp(child, rsp); } } } void DomParser::fill_domain_info_rsp(DOMNode *n, DomainInfoRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "domain:infData") { look_children = true; } else if (elem_name == "domain:name") { rsp->set_name(str_transcode(n->getTextContent())); } else if (elem_name == "domain:roid") { rsp->set_roid(str_transcode(n->getTextContent())); } else if (elem_name == "domain:status") { map< string, string, less > attributes = get_attributes(n); if (attributes["s"] != "") { rsp->insert_status(attributes["s"]); } } else if (elem_name == "domain:registrant") { rsp->set_registrant(str_transcode(n->getTextContent())); } else if (elem_name == "domain:contact") { map< string, string, less > attributes = get_attributes(n); rsp->insert_contact(attributes["type"], str_transcode(n->getTextContent())); } else if (elem_name == "domain:ns") { look_children = true; } else if (elem_name == "domain:hostAttr") { NameServer ns; DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string e_name = str_transcode(child->getNodeName()); if (e_name == "domain:hostName") { ns.name = str_transcode(child->getTextContent()); } else if (e_name == "domain:hostAddr") { NSIPAddr ip; ip.addr = str_transcode(child->getTextContent()); map > attributes = get_attributes(child); ip.version = attributes["ip"]; ns.ips.insert(ip); } } rsp->insert_nameserver(ns); } else if (elem_name == "domain:clID") { rsp->set_clID(str_transcode(n->getTextContent())); } else if (elem_name == "domain:crID") { rsp->set_crID(str_transcode(n->getTextContent())); } else if (elem_name == "domain:crDate") { rsp->set_crDate(str_transcode(n->getTextContent())); } else if (elem_name == "domain:upID") { rsp->set_upID(str_transcode(n->getTextContent())); } else if (elem_name == "domain:upDate") { rsp->set_upDate(str_transcode(n->getTextContent())); } else if (elem_name == "domain:exDate") { rsp->set_exDate(str_transcode(n->getTextContent())); } else if (elem_name == "domain:trDate") { rsp->set_trDate(str_transcode(n->getTextContent())); } else if (elem_name == "domain:authInfo") { map< string, string, less > attributes = get_attributes(n); AuthInfo authInfo; authInfo.set_roid(attributes["roid"]); authInfo.set_pw(str_transcode(n->getTextContent())); rsp->set_authInfo(authInfo); } else if (elem_name == "domain:host") { // Ignored } else if (elem_name == "domain:hostObj") { // Ignored } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brdomain:infData") { //brdomain extension fill_brdomain_info_rsp(n, (BrDomainInfoRsp *) rsp); #endif //USE_BR_DOMAINS } else if (elem_name == "secDNS:infData") { look_children = true; } else if (elem_name == "secDNS:dsData") { DSInfo dsInfo; fill_ds_info(n, &dsInfo); rsp->add_dsInfo(dsInfo); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_domain_info_rsp(child, rsp); } } } void DomParser::fill_domain_create_rsp(DOMNode *n, DomainCreateRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "domain:creData") { look_children = true; } else if (elem_name == "domain:name") { rsp->set_name(str_transcode(n->getTextContent())); } else if (elem_name == "domain:crDate") { rsp->set_crDate(str_transcode(n->getTextContent())); } else if (elem_name == "domain:exDate") { rsp->set_exDate(str_transcode(n->getTextContent())); } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brdomain:creData") { fill_brdomain_create_rsp(n, (BrDomainCreateRsp *) rsp); #endif //USE_BR_DOMAINS } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_domain_create_rsp(child, rsp); } } } void DomParser::fill_domain_renew_rsp(DOMNode *n, DomainRenewRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "resData") { look_children = true; } else if (elem_name == "domain:renData") { look_children = true; } else if (elem_name == "domain:name") { rsp->set_name(str_transcode(n->getTextContent())); } else if (elem_name == "domain:exDate") { rsp->set_exDate(str_transcode(n->getTextContent())); } else if (elem_name == "extension") { look_children = true; #if USE_BR_DOMAINS } else if (elem_name == "brdomain:renData") { //brdomain extension fill_brdomain_renew_rsp(n, (BrDomainRenewRsp*) rsp); #endif //USE_BR_DOMAINS } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_domain_renew_rsp(child, rsp); } } } void DomParser::fill_domain_pandata_rsp(DOMNode *n, PanDataRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "domain:panData") { look_children = true; } else if (elem_name == "domain:name") { rsp->set_object_id(str_transcode(n->getTextContent())); // attribute map< string, string, less > attributes = get_attributes(n); if (attributes["paResult"] == "1") { rsp->set_paResult(true); } } else if (elem_name == "domain:paTRID") { look_children = true; } else if (elem_name == "clTRID") { rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "domain:paDate") { rsp->set_paDate(str_transcode(n->getTextContent())); } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_domain_pandata_rsp(child, rsp); } } } } void DomParser::fill_poll_rsp(DOMNode *n, PollRsp *poll_rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "epp" || elem_name == "response") { look_children = true; } else if (elem_name == "result") { fill_result(n, (Response *)poll_rsp); } else if (elem_name == "trID") { look_children = true; } else if (elem_name == "clTRID") { poll_rsp->set_clTRID(str_transcode(n->getTextContent())); } else if (elem_name == "svTRID") { poll_rsp->set_svTRID(str_transcode(n->getTextContent())); } else if (elem_name == "msgQ") { look_children = true; map< string, string, less > attributes = get_attributes(n); if (attributes["count"] != "") { poll_rsp->set_count(attributes["count"]); } if (attributes["id"] != "") { poll_rsp->set_id(attributes["id"]); } } else if (elem_name == "qDate") { poll_rsp->set_qDate(str_transcode(n->getTextContent())); } else if (elem_name == "msg") { // Get the attribute lang map< string, string, less > attributes = get_attributes(n); if (attributes["lang"] != "") { poll_rsp->set_lang(attributes["lang"]); } // Run thru the child elements, getting the attributes and // text content DOMNode *child; int child_count = 0; map > content; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) { child_count++; PollRsp::MsgContent msg_content; map< string, string, less > attributes = get_attributes(child); string child_name = str_transcode(child->getNodeName()); string child_text_content = str_transcode(child->getTextContent()); msg_content.value = child_text_content; msg_content.attributes = attributes; content[child_name] = msg_content; } } poll_rsp->set_content(content); // If there were no child elements, get text content if (child_count == 0) { string msg_text_content = str_transcode(n->getTextContent()); if (msg_text_content != "") { poll_rsp->set_text(msg_text_content); } } } else if (elem_name == "resData") { // resDatas look_children = true; } else if (elem_name == "domain:panData") { auto_ptr rsp = auto_ptr(new PanDataRsp()); fill_domain_pandata_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), DOMAIN_PANDATA); } else if (elem_name == "contact:panData") { auto_ptr rsp = auto_ptr(new PanDataRsp()); fill_contact_pandata_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), CONTACT_PANDATA); } else if (elem_name == "contact:chkData") { auto_ptr rsp = auto_ptr(new ContactCheckRsp()); fill_contact_check_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), CONTACT_CHECK); } else if (elem_name == "contact:infData") { auto_ptr rsp = auto_ptr(new ContactInfoRsp()); fill_contact_info_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), CONTACT_INFO); } else if (elem_name == "contact:creData") { auto_ptr rsp = auto_ptr(new ContactCreateRsp()); fill_contact_create_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), CONTACT_CREATE); } else if (elem_name == "domain:chkData") { auto_ptr rsp = auto_ptr(new DomainCheckRsp()); fill_domain_check_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), DOMAIN_CHECK); } else if (elem_name == "domain:infData") { auto_ptr rsp = auto_ptr(new DomainInfoRsp()); fill_domain_info_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), DOMAIN_INFO); } else if (elem_name == "domain:creData") { auto_ptr rsp = auto_ptr(new DomainCreateRsp()); fill_domain_create_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), DOMAIN_CREATE); } else if (elem_name == "domain:renData") { auto_ptr rsp = auto_ptr(new DomainRenewRsp()); fill_domain_renew_rsp(n, rsp.get()); poll_rsp->set_response((Response *) rsp.release(), DOMAIN_RENEW); } else if (elem_name == "extension") { // extensions look_children = true; } else if (elem_name == "brorg:panData") { if (poll_rsp->get_response_type() == CONTACT_PANDATA) { PanDataRsp *parent = (PanDataRsp *) poll_rsp->get_response(); auto_ptr extension_rsp = auto_ptr(new BrOrgPanDataRsp()); extension_rsp->copy_parent_data(*parent); fill_brorg_pandata_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_ORG_PANDATA); } } else if (elem_name == "brdomain:panData") { if (poll_rsp->get_response_type() == DOMAIN_PANDATA) { PanDataRsp *parent = (PanDataRsp *) poll_rsp->get_response(); auto_ptr extension_rsp(new BrDomainPanDataRsp()); extension_rsp->copy_parent_data(*parent); fill_brdomain_pandata_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_DOMAIN_PANDATA); } } else if (elem_name == "brorg:infData") { if (poll_rsp->get_response_type() == CONTACT_INFO) { ContactInfoRsp *parent = (ContactInfoRsp *) poll_rsp->get_response(); auto_ptr extension_rsp = auto_ptr(new BrOrgInfoRsp()); extension_rsp->copy_parent_data(*parent); fill_brorg_info_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_ORG_INFO); } } else if (elem_name == "brdomain:chkData") { if (poll_rsp->get_response_type() == DOMAIN_CHECK) { DomainCheckRsp *parent = (DomainCheckRsp *) poll_rsp->get_response(); auto_ptr extension_rsp = auto_ptr(new BrDomainCheckRsp()); extension_rsp->copy_parent_data(*parent); fill_brdomain_check_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_DOMAIN_CHECK); } } else if (elem_name == "brdomain:infData") { if (poll_rsp->get_response_type() == DOMAIN_INFO) { DomainInfoRsp *parent = (DomainInfoRsp *) poll_rsp->get_response(); auto_ptr extension_rsp = auto_ptr(new BrDomainInfoRsp()); extension_rsp->copy_parent_data(*parent); fill_brdomain_info_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_DOMAIN_INFO); } } else if (elem_name == "brdomain:creData") { if (poll_rsp->get_response_type() == DOMAIN_CREATE) { DomainCreateRsp *parent = (DomainCreateRsp *) poll_rsp->get_response(); auto_ptr extension_rsp = auto_ptr(new BrDomainCreateRsp()); extension_rsp->copy_parent_data(*parent); fill_brdomain_create_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_DOMAIN_CREATE); } } else if (elem_name == "brdomain:renData") { if (poll_rsp->get_response_type() == DOMAIN_RENEW) { DomainRenewRsp *parent = (DomainRenewRsp *) poll_rsp->get_response(); auto_ptr extension_rsp = auto_ptr(new BrDomainRenewRsp()); extension_rsp->copy_parent_data(*parent); fill_brdomain_renew_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_DOMAIN_RENEW); } } else if (elem_name == "brdomain:updData") { if (poll_rsp->get_response_type() == DOMAIN_UPDATE) { auto_ptr extension_rsp = auto_ptr(new BrDomainUpdateRsp()); fill_brdomain_update_rsp(n, extension_rsp.get()); poll_rsp->set_response((Response *) extension_rsp.release(), BR_DOMAIN_UPDATE); } } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_poll_rsp(child, poll_rsp); } } } void DomParser::fill_brorg_info_rsp(DOMNode *n, BrOrgInfoRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brorg:infData") { look_children = true; } else if (elem_name == "brorg:organization") { rsp->set_organization(str_transcode(n->getTextContent())); } else if (elem_name == "brorg:responsible") { rsp->set_responsible(str_transcode(n->getTextContent())); } else if (elem_name == "brorg:contact") { string id = str_transcode(n->getTextContent()); map< string, string, less > attributes = get_attributes(n); string type = attributes["type"]; rsp->insert_contact(type, id); } else if (elem_name == "brorg:proxy") { rsp->set_proxy(str_transcode(n->getTextContent())); } else if (elem_name == "brorg:domainName") { rsp->insert_domainName(str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brorg_info_rsp(child, rsp); } } } void DomParser::fill_brorg_check_rsp(DOMNode *n, BrOrgCheckRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brorg:chkData") { look_children = true; } else if (elem_name == "brorg:ticketInfo") { string org; struct BrOrgCheckRsp::Unavailability unavail; unavail.tkt_num = 0; unavail.tkt_fqdn = ""; DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } elem_name = str_transcode(child->getNodeName()); if (elem_name == "brorg:organization") { org = str_transcode(child->getTextContent()); } else if (elem_name == "brorg:domainName") { unavail.tkt_fqdn = str_transcode(child->getTextContent()); } else if (elem_name == "brorg:ticketNumber") { unavail.tkt_num = atoi(str_transcode(child->getTextContent()).c_str()); } } rsp->insert_unavailability(org, unavail); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brorg_check_rsp(child, rsp); } } } void DomParser::fill_brorg_pandata_rsp(DOMNode *n, BrOrgPanDataRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brorg:panData") { look_children = true; } else if (elem_name == "brorg:organization") { rsp->set_organization(str_transcode(n->getTextContent())); } else if (elem_name == "brorg:reason") { // Get the lang attribute map< string, string, less > attributes = get_attributes(n); if (attributes["lang"] != "") { rsp->set_reason_lang(attributes["lang"]); } rsp->set_reason(str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brorg_pandata_rsp(child, rsp); } } } void DomParser::fill_brdomain_check_rsp(DOMNode *n, BrDomainCheckRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brdomain:chkData") { look_children = true; } else if (elem_name == "brdomain:cd") { string domain; // attributes struct BrDomainCheckRsp::Unavailability unavail; unavail.hasConcurrent = false; unavail.inReleaseProcess = false; map< string, string, less > attributes = get_attributes(n); if (attributes["hasConcurrent"] == "1") { unavail.hasConcurrent = true; } if (attributes["inReleaseProcess"] == "1") { unavail.inReleaseProcess = true; } unavail.organization = ""; unavail.equivalentName = ""; DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } elem_name = str_transcode(child->getNodeName()); if (elem_name == "brdomain:name") { domain = str_transcode(child->getTextContent()); } else if (elem_name == "brdomain:organization") { unavail.organization = str_transcode(child->getTextContent()); } else if (elem_name == "brdomain:equivalentName") { unavail.equivalentName = str_transcode(child->getTextContent()); } else if (elem_name == "brdomain:ticketNumber") { unavail.tickets.insert(atoi(str_transcode( child->getTextContent()).c_str())); } } rsp->insert_unavailability(domain, unavail); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brdomain_check_rsp(child, rsp); } } } void DomParser::fill_brdomain_info_rsp(DOMNode *n, BrDomainInfoRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brdomain:infData") { look_children = true; } else if (elem_name == "brdomain:ticketNumber") { rsp->set_ticketNumber(atoi(str_transcode(n->getTextContent()).c_str())); } else if (elem_name == "brdomain:organization") { rsp->set_organization(str_transcode(n->getTextContent())); } else if (elem_name == "brdomain:releaseProcessFlags") { struct ReleaseProcessFlags rpf; rpf.flag1 = 0; rpf.flag2 = 0; rpf.flag3 = 0; map< string, string, less > attributes = get_attributes(n); if (attributes["flag1"] == "1") { rpf.flag1 = 1; } if (attributes["flag2"] == "1") { rpf.flag2 = 1; } if (attributes["flag3"] == "1") { rpf.flag3 = 1; } rsp->set_releaseProcessFlags(rpf); } else if (elem_name == "brdomain:pending") { look_children = true; } else if (elem_name == "brdomain:doc") { struct PendingDoc pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:doc child elements DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string curr_name = str_transcode(child->getNodeName()); if (curr_name == "brdomain:docType") { pend.docType = str_transcode(child->getTextContent()); } else if (curr_name == "brdomain:limit") { pend.limit = str_transcode(child->getTextContent()); } else if (curr_name == "brdomain:description") { map< string, string, less > description_attributes; description_attributes = get_attributes(child); pend.description_lang = description_attributes["lang"]; pend.description = str_transcode(child->getTextContent()); } } rsp->insert_doc_pending(pend); } else if (elem_name == "brdomain:dns") { struct PendingDns pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:dns child elements map< string, string, less > children = get_children_simple(n); pend.hostName = children["brdomain:hostName"]; pend.limit = children["brdomain:limit"]; rsp->insert_dns_pending(pend); } else if (elem_name == "brdomain:releaseProc") { struct PendingReleaseProc pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:releaseProc child element map< string, string, less > children = get_children_simple(n); pend.limit = children["brdomain:limit"]; rsp->set_rel_pending(pend); } else if (elem_name == "brdomain:ticketNumberConc") { int tkt = atoi(str_transcode(n->getTextContent()).c_str()); rsp->insert_concurrent_ticket(tkt); } else if (elem_name == "brdomain:publicationStatus") { // attribute map< string, string, less > attributes = get_attributes(n); rsp->set_publication_flag(attributes["publicationFlag"]); look_children = true; } else if (elem_name == "brdomain:onHoldReason") { rsp->insert_onhold_reason(str_transcode(n->getTextContent())); } else if (elem_name == "brdomain:autoRenew") { map< string, string, less > attributes = get_attributes(n); rsp->set_active(atoi(attributes["active"].c_str())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brdomain_info_rsp(child, rsp); } } } void DomParser::fill_brdomain_create_rsp(DOMNode *n, BrDomainCreateRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brdomain:creData") { look_children = true; } else if (elem_name == "brdomain:ticketNumber") { rsp->set_ticketNumber(atoi(str_transcode(n->getTextContent()).c_str())); } else if (elem_name == "brdomain:pending") { look_children = true; } else if (elem_name == "brdomain:doc") { struct PendingDoc pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:doc child elements DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string curr_name = str_transcode(child->getNodeName()); if (curr_name == "brdomain:docType") { pend.docType = str_transcode(child->getTextContent()); } else if (curr_name == "brdomain:limit") { pend.limit = str_transcode(child->getTextContent()); } else if (curr_name == "brdomain:description") { map< string, string, less > description_attributes; description_attributes = get_attributes(child); pend.description_lang = description_attributes["lang"]; pend.description = str_transcode(child->getTextContent()); } } rsp->insert_doc_pending(pend); } else if (elem_name == "brdomain:dns") { struct PendingDns pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:dns child elements map< string, string, less > children = get_children_simple(n); pend.hostName = children["brdomain:hostName"]; pend.limit = children["brdomain:limit"]; rsp->insert_dns_pending(pend); } else if (elem_name == "brdomain:releaseProc") { struct PendingReleaseProc pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:releaseProc child element map< string, string, less > children = get_children_simple(n); pend.limit = children["brdomain:limit"]; rsp->set_rel_pending(pend); } else if (elem_name == "brdomain:ticketNumberConc") { int tkt = atoi(str_transcode(n->getTextContent()).c_str()); rsp->insert_concurrent_ticket(tkt); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brdomain_create_rsp(child, rsp); } } } void DomParser::fill_brdomain_renew_rsp(DOMNode *n, BrDomainRenewRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brdomain:renData") { look_children = true; } else if (elem_name == "brdomain:publicationStatus") { // attribute map< string, string, less > attributes = get_attributes(n); rsp->set_publication_flag(attributes["publicationFlag"]); look_children = true; } else if (elem_name == "brdomain:onHoldReason") { rsp->insert_onhold_reason(str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brdomain_renew_rsp(child, rsp); } } } void DomParser::fill_brdomain_update_rsp(DOMNode *n, BrDomainUpdateRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brdomain:updData") { look_children = true; } else if (elem_name == "brdomain:ticketNumber") { rsp->set_ticketNumber(atoi(str_transcode(n->getTextContent()).c_str())); } else if (elem_name == "brdomain:pending") { look_children = true; } else if (elem_name == "brdomain:doc") { struct PendingDoc pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:doc child elements DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { if (child->getNodeType() != DOMNode::ELEMENT_NODE) { continue; } string curr_name = str_transcode(child->getNodeName()); if (curr_name == "brdomain:docType") { pend.docType = str_transcode(child->getTextContent()); } else if (curr_name == "brdomain:limit") { pend.limit = str_transcode(child->getTextContent()); } else if (curr_name == "brdomain:description") { map< string, string, less > description_attributes; description_attributes = get_attributes(child); pend.description_lang = description_attributes["lang"]; pend.description = str_transcode(child->getTextContent()); } } rsp->insert_doc_pending(pend); } else if (elem_name == "brdomain:dns") { struct PendingDns pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:dns child elements map< string, string, less > children = get_children_simple(n); pend.hostName = children["brdomain:hostName"]; pend.limit = children["brdomain:limit"]; rsp->insert_dns_pending(pend); } else if (elem_name == "brdomain:releaseProc") { struct PendingReleaseProc pend; // attribute map< string, string, less > attributes = get_attributes(n); pend.status = attributes["status"]; // brdomain:releaseProc child element map< string, string, less > children = get_children_simple(n); pend.limit = children["brdomain:limit"]; rsp->set_rel_pending(pend); } else if (elem_name == "brdomain:hostStatus") { map< string, string, less > children = get_children_simple(n); struct HostStatus hs; hs.host = children["brdomain:hostName"]; hs.status = children["brdomain:dnsAnswer"]; rsp->insert_host_status(hs); } else if (elem_name == "brdomain:publicationStatus") { // attribute map< string, string, less > attributes = get_attributes(n); rsp->set_publication_flag(attributes["publicationFlag"]); look_children = true; } else if (elem_name == "brdomain:onHoldReason") { rsp->insert_onhold_reason(str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brdomain_update_rsp(child, rsp); } } } void DomParser::fill_brdomain_pandata_rsp(DOMNode *n, BrDomainPanDataRsp *rsp) { bool look_children = false; if (n->getNodeType() == DOMNode::ELEMENT_NODE) { string elem_name = str_transcode(n->getNodeName()); if (elem_name == "brdomain:panData") { look_children = true; } else if (elem_name == "brdomain:ticketNumber") { rsp->set_ticketNumber(atoi(str_transcode(n->getTextContent()).c_str())); } else if (elem_name == "brdomain:reason") { // Get the lang attribute map< string, string, less > attributes = get_attributes(n); if (attributes["lang"] != "") { rsp->set_reason_lang(attributes["lang"]); } rsp->set_reason(str_transcode(n->getTextContent())); } } if (look_children) { DOMNode *child; for (child = n->getFirstChild(); child != 0; child = child->getNextSibling()) { fill_brdomain_pandata_rsp(child, rsp); } } } LIBEPP_NICBR_NS_END