#include "RequestLoader.h" namespace TREPS { namespace RequestManager { RequestLoaderClass::RequestLoaderClass(void):XMLManagerClass(), requestNode(NULL), typeStr("") { this->argNodeList.clear(); } bool RequestLoaderClass::loadAndValid(const char *request_path) { //load xml file if (!this->loadFile(request_path)) { LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot init request manager"); return false; } LOG4CXX_INFO(this->app->getLog()->getPtr(),"Request file loaded " << request_path); //validation if (!this->isValid(TREPS_REQUEST_XSD)) { LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot valid request file " << request_path << " with schema " << TREPS_REQUEST_XSD); return false; } //get request node this->requestNode = this->getChildFromRoot("request"); if (this->requestNode == NULL) { LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot get request node " << request_path); return false; } //get request type string this->typeStr = this->getAttributeFromNode("type",requestNode); if (this->typeStr.compare("") == 0) { LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot get request type " << request_path); return false; } //get arg node list this->argNodeList = this->getChildrenFromNode("arg",this->requestNode); return true; } string RequestLoaderClass::getType(void) { return this->typeStr; } string RequestLoaderClass::getArgStrByName(const char *arg_name) { for (NodeList::iterator argNode = this->argNodeList.begin(); argNode != this->argNodeList.end(); ++argNode) { string crtName = this->getAttributeFromNode("name",*argNode); if (crtName.compare(arg_name) == 0) return this->getNodeContent(*argNode); } return ""; } } }