void CConfigProvider::setValue( const std::string& filePath, const std::string& encoding, const std::string& valueName, const std::string& valueData) const { CAF_CM_FUNCNAME("setValue"); CAF_CM_ENTER { CAF_CM_VALIDATE_STRING(filePath); CAF_CM_VALIDATE_STRING(encoding); CAF_CM_VALIDATE_STRING(valueName); CAF_CM_VALIDATE_STRING(valueData); if (encoding.compare("iniFileWithoutSection") == 0) { SmartPtrCIniFileWithoutSection iniFileWithoutSection; iniFileWithoutSection.CreateInstance(); iniFileWithoutSection->initialize(filePath); iniFileWithoutSection->setValue(valueName, valueData); } else if (encoding.compare("iniFile") == 0) { std::string sectionName; std::string keyName; parseIniFileValuePath(valueName, sectionName, keyName); SmartPtrCIniFile iniFile; iniFile.CreateInstance(); iniFile->initialize(filePath); iniFile->setValue(sectionName, keyName, valueData); } else if (encoding.compare("xmlFile") == 0) { std::string keyName; std::deque<std::string> keyPathCollection; parseKeyPath(valueName, keyPathCollection, keyName); const SmartPtrCXmlElement rootXml = CXmlUtils::parseFile(filePath, std::string()); const SmartPtrCXmlElement parentXml = findXmlElement(keyPathCollection, rootXml); const SmartPtrCXmlElement foundElement = parentXml->findOptionalChild(keyName); if (! foundElement.IsNull()) { foundElement->setValue(valueData); } else { const std::string foundAttribute = parentXml->findOptionalAttribute(keyName); if (! foundAttribute.empty()) { parentXml->setAttribute(keyName, valueData); } else { const SmartPtrCXmlElement createdElement = parentXml->createAndAddElement(keyName); createdElement->setValue(valueData); } } rootXml->saveToFile(filePath); } else { CAF_CM_EXCEPTIONEX_VA2(InvalidArgumentException, E_INVALIDARG, "URI encoding is not recognized - filePath: %s, encoding: %s", filePath.c_str(), encoding.c_str()); } } CAF_CM_EXIT; }
void DiagDeleteValueXml::add( const SmartPtrCDiagDeleteValueDoc diagDeleteValueDoc, const SmartPtrCXmlElement thisXml) { CAF_CM_STATIC_FUNC_VALIDATE("DiagDeleteValueXml", "add"); CAF_CM_ENTER { CAF_CM_VALIDATE_SMARTPTR(diagDeleteValueDoc); CAF_CM_VALIDATE_SMARTPTR(thisXml); const std::string jobIdVal = BasePlatform::UuidToString(diagDeleteValueDoc->getJobId()); CAF_CM_VALIDATE_STRING(jobIdVal); thisXml->addAttribute("jobId", jobIdVal); const std::string fileAliasVal = diagDeleteValueDoc->getFileAlias(); CAF_CM_VALIDATE_STRING(fileAliasVal); thisXml->addAttribute("fileAlias", fileAliasVal); const std::string valueNameVal = diagDeleteValueDoc->getValueName(); CAF_CM_VALIDATE_STRING(valueNameVal); const SmartPtrCXmlElement valueNameXml = thisXml->createAndAddElement("valueName"); valueNameXml->setValue(valueNameVal); } CAF_CM_EXIT; }
void PropertyXml::add( const SmartPtrCPropertyDoc propertyDoc, const SmartPtrCXmlElement thisXml) { CAF_CM_STATIC_FUNC_VALIDATE("PropertyXml", "add"); CAF_CM_ENTER { CAF_CM_VALIDATE_SMARTPTR(propertyDoc); CAF_CM_VALIDATE_SMARTPTR(thisXml); const std::string nameVal = propertyDoc->getName(); CAF_CM_VALIDATE_STRING(nameVal); thisXml->addAttribute("name", nameVal); const std::string typeVal = EnumConvertersXml::convertPropertyTypeToString(propertyDoc->getType()); CAF_CM_VALIDATE_STRING(typeVal); thisXml->addAttribute("type", typeVal); const std::deque<std::string> valueVal = propertyDoc->getValue(); CAF_CM_VALIDATE_STL(valueVal); if (! valueVal.empty()) { for (TConstIterator<std::deque<std::string> > valueIter(valueVal); valueIter; valueIter++) { const SmartPtrCXmlElement valueXml = thisXml->createAndAddElement("value"); valueXml->setValue(*valueIter); } } } CAF_CM_EXIT; }
void ErrorResponseXml::add( const SmartPtrCErrorResponseDoc errorResponseDoc, const SmartPtrCXmlElement thisXml) { CAF_CM_STATIC_FUNC_VALIDATE("ErrorResponseXml", "add"); CAF_CM_ENTER { CAF_CM_VALIDATE_SMARTPTR(errorResponseDoc); CAF_CM_VALIDATE_SMARTPTR(thisXml); const std::string clientIdVal = BasePlatform::UuidToString(errorResponseDoc->getClientId()); if (! clientIdVal.empty()) { thisXml->addAttribute("clientId", clientIdVal); } const std::string requestIdVal = BasePlatform::UuidToString(errorResponseDoc->getRequestId()); if (! requestIdVal.empty()) { thisXml->addAttribute("requestId", requestIdVal); } const std::string pmeIdVal = errorResponseDoc->getPmeId(); if (! pmeIdVal.empty()) { thisXml->addAttribute("pmeId", pmeIdVal); } const SmartPtrCResponseHeaderDoc responseHeaderVal = errorResponseDoc->getResponseHeader(); if (! responseHeaderVal.IsNull()) { const SmartPtrCXmlElement responseHeaderXml = thisXml->createAndAddElement("responseHeader"); ResponseHeaderXml::add(responseHeaderVal, responseHeaderXml); } const std::string errorMessageVal = errorResponseDoc->getErrorMessage(); if (! errorMessageVal.empty()) { const SmartPtrCXmlElement errorMessageXml = thisXml->createAndAddElement("errorMessage"); errorMessageXml->setValue(errorMessageVal); } } CAF_CM_EXIT; }
void CmdlMetadataXml::add( const SmartPtrCCmdlMetadataDoc cmdlMetadataDoc, const SmartPtrCXmlElement thisXml) { CAF_CM_STATIC_FUNC_VALIDATE("CmdlMetadataXml", "add"); CAF_CM_ENTER { CAF_CM_VALIDATE_SMARTPTR(cmdlMetadataDoc); CAF_CM_VALIDATE_SMARTPTR(thisXml); const std::string nameVal = cmdlMetadataDoc->getName(); CAF_CM_VALIDATE_STRING(nameVal); thisXml->addAttribute("name", nameVal); const std::string valueVal = cmdlMetadataDoc->getValue(); CAF_CM_VALIDATE_STRING(valueVal); const SmartPtrCXmlElement valueXml = thisXml->createAndAddElement("value"); valueXml->setValue(valueVal); } CAF_CM_EXIT; }