SmartPtrCProviderEventResponseDoc ProviderEventResponseXml::parse(
	const SmartPtrCXmlElement thisXml) {
	CAF_CM_STATIC_FUNC_VALIDATE("ProviderEventResponseXml", "parse");

	SmartPtrCProviderEventResponseDoc providerEventResponseDoc;

	CAF_CM_ENTER {
		CAF_CM_VALIDATE_SMARTPTR(thisXml);

		const std::string pmeIdVal =
			thisXml->findRequiredAttribute("pmeId");

		const SmartPtrCXmlElement responseHeaderXml =
			thisXml->findOptionalChild("responseHeader");
		SmartPtrCResponseHeaderDoc responseHeaderVal;
		if (! responseHeaderXml.IsNull()) {
			responseHeaderVal = ResponseHeaderXml::parse(responseHeaderXml);
		}

		const SmartPtrCXmlElement manifestXml =
			thisXml->findRequiredChild("manifest");
		SmartPtrCEventManifestDoc manifestVal;
		if (! manifestXml.IsNull()) {
			manifestVal = EventManifestXml::parse(manifestXml);
		}

		const SmartPtrCXmlElement eventKeyCollectionXml =
			thisXml->findOptionalChild("eventKeyCollection");
		SmartPtrCEventKeyCollectionDoc eventKeyCollectionVal;
		if (! eventKeyCollectionXml.IsNull()) {
			eventKeyCollectionVal = EventKeyCollectionXml::parse(eventKeyCollectionXml);
		}

		const SmartPtrCXmlElement statisticsXml =
			thisXml->findOptionalChild("statistics");
		SmartPtrCStatisticsDoc statisticsVal;
		if (! statisticsXml.IsNull()) {
			statisticsVal = StatisticsXml::parse(statisticsXml);
		}

		providerEventResponseDoc.CreateInstance();
		providerEventResponseDoc->initialize(
			pmeIdVal,
			responseHeaderVal,
			manifestVal,
			eventKeyCollectionVal,
			statisticsVal);
	}
	CAF_CM_EXIT;

	return providerEventResponseDoc;
}
예제 #2
0
SmartPtrCErrorResponseDoc ErrorResponseXml::parse(
	const SmartPtrCXmlElement thisXml) {
	CAF_CM_STATIC_FUNC_VALIDATE("ErrorResponseXml", "parse");

	SmartPtrCErrorResponseDoc errorResponseDoc;

	CAF_CM_ENTER {
		CAF_CM_VALIDATE_SMARTPTR(thisXml);

		const std::string clientIdStrVal =
			thisXml->findOptionalAttribute("clientId");
		UUID clientIdVal = CAFCOMMON_GUID_NULL;
		if (! clientIdStrVal.empty()) {
			BasePlatform::UuidFromString(clientIdStrVal.c_str(), clientIdVal);
		}

		const std::string requestIdStrVal =
			thisXml->findOptionalAttribute("requestId");
		UUID requestIdVal = CAFCOMMON_GUID_NULL;
		if (! requestIdStrVal.empty()) {
			BasePlatform::UuidFromString(requestIdStrVal.c_str(), requestIdVal);
		}

		const std::string pmeIdVal =
			thisXml->findOptionalAttribute("pmeId");

		const SmartPtrCXmlElement responseHeaderXml =
			thisXml->findOptionalChild("responseHeader");
		SmartPtrCResponseHeaderDoc responseHeaderVal;
		if (! responseHeaderXml.IsNull()) {
			responseHeaderVal = ResponseHeaderXml::parse(responseHeaderXml);
		}

		const SmartPtrCXmlElement errorMessageXml =
			thisXml->findOptionalChild("errorMessage");
		std::string errorMessageVal;
		if (! errorMessageXml.IsNull()) {
			errorMessageVal = errorMessageXml->getValue();
		}

		errorResponseDoc.CreateInstance();
		errorResponseDoc->initialize(
			clientIdVal,
			requestIdVal,
			pmeIdVal,
			responseHeaderVal,
			errorMessageVal);
	}
	CAF_CM_EXIT;

	return errorResponseDoc;
}
예제 #3
0
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;
}