Feature #1611: Clean DefaultQuotas to/from xml methods

This commit is contained in:
Carlos Martín committed 2012-11-29 17:36:10 +01:00
1 parent 9d3fb42970
commit d680315fce
1 file changed
+3 -49
+3 -49
View File
@@ -30,16 +30,10 @@ string& DefaultQuotas::to_xml(string& xml) const
{
ostringstream oss;
string ds_quota_xml;
string net_quota_xml;
string vm_quota_xml;
string image_quota_xml;
string aux_xml;
oss << "<" << root_elem << ">"
<< datastore_quota.to_xml(ds_quota_xml)
<< network_quota.to_xml(net_quota_xml)
<< vm_quota.to_xml(vm_quota_xml)
<< image_quota.to_xml(image_quota_xml)
<< Quotas::to_xml(aux_xml)
<< "</" << root_elem << ">";
xml = oss.str();
@@ -52,49 +46,9 @@ string& DefaultQuotas::to_xml(string& xml) const
int DefaultQuotas::from_xml(const string& xml)
{
vector<xmlNodePtr> content;
int rc = 0;
ObjectXML *object_xml = new ObjectXML(xml);
object_xml->get_nodes(ds_xpath, content);
if (!content.empty())
{
rc += datastore_quota.from_xml_node(content[0]);
}
object_xml->free_nodes(content);
content.clear();
object_xml->get_nodes(net_xpath, content);
if (!content.empty())
{
rc += network_quota.from_xml_node(content[0]);
}
object_xml->free_nodes(content);
content.clear();
object_xml->get_nodes(vm_xpath, content);
if (!content.empty())
{
rc += vm_quota.from_xml_node(content[0]);
}
object_xml->free_nodes(content);
content.clear();
object_xml->get_nodes(img_xpath, content);
if (!content.empty())
{
rc += image_quota.from_xml_node(content[0]);
}
object_xml->free_nodes(content);
int rc = Quotas::from_xml(object_xml);
delete object_xml;