23 #include "ConfigurationHandler.h"
25 ConfigurationHandler::ConfigurationHandler() {
30 ConfigurationHandler::~ConfigurationHandler() {
35 void ConfigurationHandler::listi(
string cwd,
string type,
bool apDir,strVec &folders)
37 Logger logger = Logger::getLogger(
"ConfigurationHandler");
40 if(chdir(cwd.c_str())!=0)
43 command = (
"find . \\( ! -name . -prune \\) \\( -type d -o -type l \\) 2>/dev/null");
45 command = (
"find . \\( ! -name . -prune \\) \\( -type f -o -type l \\) -name '*"+type+
"' 2>/dev/null");
47 logger << (
"Searching directory " + cwd +
" for pattern " + type) << endl;
48 if ((pipe_fp = popen(command.c_str(),
"r")) == NULL)
50 printf(
"pipe open error in cmd_list\n");
54 while ((t_char = fgetc(pipe_fp)) != EOF)
62 folderName.append(temp);
64 else if(folderName!=
"")
66 StringUtil::replaceFirst(folderName,
"*",
"");
67 StringUtil::replaceFirst(folderName,
"./",
"");
68 if(folderName.find(
"~")==string::npos)
74 folderName = cwd+
"/"+folderName+
"/";
75 StringUtil::replaceFirst(folderName,
"//",
"/");
76 folders.push_back(folderName);
80 folderName = cwd+
"/"+folderName;
81 StringUtil::replaceFirst(folderName,
"//",
"/");
82 folders.push_back(folderName);
86 folders.push_back(folderName);
94 ConfigurationData ConfigurationHandler::handle(strVec webdirs,strVec webdirs1,
string incpath,
string rtdcfpath,
string pubpath,
string respath,
bool isSSLEnabled)
96 Logger logger = Logger::getLogger(
"ConfigurationHandler");
98 configurationData.resourcePath = respath;
99 strVec all,dcps,afcd,appf,wspath,compnts,handoffVec,tpes;
103 string libs,ilibs,isrcs,iobjs,ideps;
106 strVec vecvp,pathvec;
107 map<string, string> ajintpthMap;
114 propMap sslsec = pread.getProperties(respath+
"/security.prop");
117 configurationData.key_file = sslsec[
"KEYFILE"];
118 configurationData.dh_file = sslsec[
"DHFILE"];
119 configurationData.ca_list = sslsec[
"CA_LIST"];
120 configurationData.rand_file = sslsec[
"RANDOM"];
121 configurationData.sec_password = sslsec[
"PASSWORD"];
122 string tempcl = sslsec[
"CLIENT_SEC_LEVEL"];
123 configurationData.srv_auth_prvd = sslsec[
"SRV_AUTH_PRVD"];
124 configurationData.srv_auth_mode = sslsec[
"SRV_AUTH_MODE"];
125 configurationData.srv_auth_file = sslsec[
"SRV_AUTH_FILE"];
130 configurationData.client_auth = CastUtil::lexical_cast<
int>(tempcl);
134 logger <<
"\nInvalid client auth level defined" << flush;
135 configurationData.client_auth = 1;
140 string rundyncontent;
141 for(
unsigned int var=0;var<webdirs.size();var++)
144 string defpath = webdirs.at(var);
145 string dcppath = defpath +
"dcp/";
146 string tmplpath = defpath +
"tpe/";
147 string cmppath = defpath +
"components/";
148 string usrincludes = defpath +
"include/";
151 string name = webdirs1.at(var);
152 StringUtil::replaceAll(name,
"/",
"");
153 rundyncontent +=
"cp -Rf $FEAD_CPP_PATH/public/* $FEAD_CPP_PATH/web/"+name+
"/public/\n";
154 configurationData.cntMap[name] =
"true";
155 listi(dcppath,
".dcp",
true,dcps);
156 listi(tmplpath,
".tpe",
true,tpes);
157 listi(cmppath,
".cmp",
true,compnts);
158 all.push_back(usrincludes);
159 appf.push_back(defpath+
"app.xml");
161 libs += (
"-l"+ name+
" ");
162 ilibs += (
"-I" + usrincludes+
" ");
163 wspath.push_back(name);
165 logger <<
"started reading application.xml " << endl;
166 Element root = parser.getDocument(defpath+
"config/application.xml").getRootElement();
167 if(root.getTagName()==
"app" && root.getChildElements().size()>0)
169 ElementList eles = root.getChildElements();
170 for (
unsigned int apps = 0; apps < eles.size(); apps++)
172 if(eles.at(apps).getTagName()==
"controllers")
174 ElementList cntrls = eles.at(apps).getChildElements();
175 for (
unsigned int cntn = 0; cntn < cntrls.size(); cntn++)
177 if(cntrls.at(cntn).getTagName()==
"controller")
179 string url = cntrls.at(cntn).getAttribute(
"url");
180 string clas = cntrls.at(cntn).getAttribute(
"class");
181 if(url!=
"" && clas!=
"")
183 if(cntrls.at(cntn).getAttribute(
"url").find(
"*")!=string::npos)
186 configurationData.urlpattMap[name+url] = clas;
189 url = url.substr(url.find(
"*")+1);
190 configurationData.urlMap[name+url] = clas;
194 configurationData.urlMap[name+url] = clas;
195 logger << (
"Adding Controller for " + (name + url) +
" :: " + clas) << endl;
199 string from = cntrls.at(cntn).getAttribute(
"from");
200 string to = cntrls.at(cntn).getAttribute(
"to");
201 if(to.find(
"*")!=string::npos && to!=
"")
202 to = to.substr(to.find(
"*")+1);
203 if(from.find(
"*")!=string::npos && to!=
"")
206 configurationData.mappattMap[name+from] = to;
209 from = from.substr(from.find(
"*")+1);
210 configurationData.mapMap[name+from] = to;
215 configurationData.mapMap[name+from] = to;
217 logger << (
"Adding Mapping for " + (name + from) +
" :: " + to) << endl;
222 else if(eles.at(apps).getTagName()==
"authhandlers")
224 ElementList cntrls = eles.at(apps).getChildElements();
225 for (
unsigned int cntn = 0; cntn < cntrls.size(); cntn++)
227 if(cntrls.at(cntn).getTagName()==
"authhandler")
229 string url = cntrls.at(cntn).getAttribute(
"url");
230 string provider = cntrls.at(cntn).getAttribute(
"provider");
231 if(url!=
"" && provider!=
"")
233 if(url.find(
"*")!=string::npos)
236 configurationData.autpattMap[name+url] = provider;
239 url = url.substr(url.find(
"*")+1);
240 configurationData.autMap[name+url] = provider;
243 else if(provider!=
"")
244 configurationData.autMap[name+url] = provider;
245 logger << (
"Adding Authhandler for " + (name + url) +
" :: " + provider) << endl;
250 else if(eles.at(apps).getTagName()==
"filters")
252 ElementList cntrls = eles.at(apps).getChildElements();
253 for (
unsigned int cntn = 0; cntn < cntrls.size(); cntn++)
255 if(cntrls.at(cntn).getTagName()==
"filter")
257 string url = cntrls.at(cntn).getAttribute(
"url");
258 string clas = cntrls.at(cntn).getAttribute(
"class");
259 string type = cntrls.at(cntn).getAttribute(
"type");
260 if(clas!=
"" && (type==
"in" || type==
"out"))
262 if(url==
"")url=
"*.*";
263 if(url.find(
"*")!=string::npos)
267 configurationData.filterMap[name+url+type].push_back(clas);
271 url = url.substr(url.find(
"*")+1);
272 configurationData.filterMap[name+url+type].push_back(clas);
275 logger << (
"Adding Filter for " + (name + url + type) +
" :: " + clas) << endl;
280 else if(eles.at(apps).getTagName()==
"templates")
282 ElementList tmplts = eles.at(apps).getChildElements();
283 for (
unsigned int tmpn = 0; tmpn < tmplts.size(); tmpn++)
285 if(tmplts.at(tmpn).getTagName()==
"template")
287 configurationData.tmplMap[name+tmplts.at(tmpn).getAttribute(
"file")] = tmplts.at(tmpn).getAttribute(
"class");
288 tpes.push_back(defpath+tmplts.at(tmpn).getAttribute(
"file"));
289 logger << (
"Adding Template for " + (name+tmplts.at(tmpn).getAttribute(
"file")) +
" :: " + tmplts.at(tmpn).getAttribute(
"class")) << endl;
293 else if(eles.at(apps).getTagName()==
"dviews")
295 ElementList dvs = eles.at(apps).getChildElements();
296 for (
unsigned int dn = 0; dn < dvs.size(); dn++)
298 if(dvs.at(dn).getTagName()==
"dview")
300 configurationData.vwMap[name+dvs.at(dn).getAttribute(
"path")] = dvs.at(dn).getAttribute(
"class");
301 logger << (
"Adding Dynamic View for " + (name+dvs.at(dn).getAttribute(
"path")) +
" :: " + dvs.at(dn).getAttribute(
"class")) << endl;
305 else if(eles.at(apps).getTagName()==
"ajax-interfaces")
307 ElementList ajintfs = eles.at(apps).getChildElements();
308 for (
unsigned int dn = 0; dn < ajintfs.size(); dn++)
310 if(ajintfs.at(dn).getTagName()==
"ajax-interface")
312 string url = ajintfs.at(dn).getAttribute(
"url");
313 if(url.find(
"*")==string::npos)
317 else if(url.at(0)!=
'/')
319 configurationData.ajaxIntfMap[name+url] = ajintfs.at(dn).getAttribute(
"class");
320 pathvec.push_back(name);
321 vecvp.push_back(usrincludes);
322 stat.push_back(
false);
323 ajintpthMap[ajintfs.at(dn).getAttribute(
"class")] =
"/" + name+url;
324 afcd.push_back(ajintfs.at(dn).getAttribute(
"class"));
325 logger << (
"Adding Ajax Interface for " + (name+url) +
" :: " + ajintfs.at(dn).getAttribute(
"class")) << endl;
330 else if(eles.at(apps).getTagName()==
"restcontrollers")
332 ElementList cntrls = eles.at(apps).getChildElements();
333 for (
unsigned int cntn = 0; cntn < cntrls.size(); cntn++)
335 if(cntrls.at(cntn).getTagName()==
"restcontroller")
337 string url = cntrls.at(cntn).getAttribute(
"urlpath");
338 string clas = cntrls.at(cntn).getAttribute(
"class");
339 string rname = cntrls.at(cntn).getAttribute(
"name");
340 ElementList resfuncs = cntrls.at(cntn).getChildElements();
341 for (
unsigned int cntn1 = 0; cntn1 < resfuncs.size(); cntn1++)
343 if(resfuncs.at(cntn1).getTagName()==
"restfunction")
346 restfunction.name = resfuncs.at(cntn1).getAttribute(
"name");
347 restfunction.alias = resfuncs.at(cntn1).getAttribute(
"alias");
348 restfunction.clas = clas;
349 restfunction.meth = resfuncs.at(cntn1).getAttribute(
"meth");
350 restfunction.baseUrl = resfuncs.at(cntn1).getAttribute(
"baseUrl");
351 if(restfunction.baseUrl!=
"")
353 if(restfunction.baseUrl.at(0)!=
'/')
354 restfunction.baseUrl =
"/" + restfunction.baseUrl;
356 restfunction.icontentType = resfuncs.at(cntn1).getAttribute(
"icontentType");
357 restfunction.ocontentType = resfuncs.at(cntn1).getAttribute(
"ocontentType");
358 ElementList resfuncparams = resfuncs.at(cntn1).getChildElements();
359 bool hasBodyParam =
false, invalidParam =
false;;
360 for (
unsigned int cntn2 = 0; cntn2 < resfuncparams.size(); cntn2++)
362 if(resfuncparams.at(cntn2).getTagName()==
"param")
365 param.type = resfuncparams.at(cntn2).getAttribute(
"type");
366 param.from = resfuncparams.at(cntn2).getAttribute(
"from");
367 param.name = resfuncparams.at(cntn2).getAttribute(
"name");
368 if(param.from==
"body")
372 if(StringUtil::trimCopy(param.type)==
"")
375 logger <<
"no type specified for param" << endl;
377 else if(param.from!=
"body" && StringUtil::trimCopy(param.name)==
"")
380 logger <<
"no name specified for param" << endl;
382 else if(param.from==
"body" && (restfunction.meth==
"GET" || restfunction.meth==
"OPTIONS" || restfunction.meth==
"TRACE"
383 || restfunction.meth==
"HEAD"))
386 logger << (
"skipping param " + param.type +
", from is body and method is " + restfunction.meth) << endl;
388 else if(!(param.type==
"int" || param.type==
"short" || param.type==
"long" || param.type==
"float" || param.type==
"string"
389 || param.type==
"std::string" || param.type==
"double" || param.type==
"bool") && param.from!=
"body")
392 logger << (
"skipping param " + param.type +
", from is body input is complex type") << endl;
394 else if(param.from==
"postparam" && (restfunction.meth==
"GET" || restfunction.meth==
"OPTIONS" || restfunction.meth==
"TRACE"
395 || restfunction.meth==
"HEAD"))
398 logger << (
"skipping param " + param.type +
", from is postparam and method is " + restfunction.meth) << endl;
401 restfunction.params.push_back(param);
404 if(hasBodyParam && restfunction.params.size()>1)
414 if(url.find(
"*")==string::npos)
418 else if(url.at(0)!=
'/')
423 if(restfunction.alias!=
"")
425 if(restfunction.baseUrl==
"")
426 urlmpp = name+url+rname+
"/"+restfunction.alias;
428 urlmpp = name+restfunction.baseUrl;
429 StringUtil::replaceFirst(urlmpp,
"//",
"/");
430 configurationData.rstCntMap[urlmpp] = restfunction;
434 if(restfunction.baseUrl==
"")
435 urlmpp = name+url+rname+
"/"+restfunction.name;
437 urlmpp = name+restfunction.baseUrl;
438 StringUtil::replaceFirst(urlmpp,
"//",
"/");
439 configurationData.rstCntMap[urlmpp] = restfunction;
444 if(restfunction.alias!=
"")
446 if(restfunction.baseUrl==
"")
447 urlmpp = name+url+clas+
"/"+restfunction.alias;
449 urlmpp = name+restfunction.baseUrl;
450 StringUtil::replaceFirst(urlmpp,
"//",
"/");
451 configurationData.rstCntMap[urlmpp] = restfunction;
455 if(restfunction.baseUrl==
"")
456 urlmpp = name+url+clas+
"/"+restfunction.name;
458 urlmpp = name+restfunction.baseUrl;
459 StringUtil::replaceFirst(urlmpp,
"//",
"/");
460 configurationData.rstCntMap[urlmpp] = restfunction;
463 logger << (
"Adding rest-controller => " + urlmpp +
" , class => " + clas) << endl;
471 else if(eles.at(apps).getTagName()==
"security")
473 ElementList cntrls = eles.at(apps).getChildElements();
474 for (
unsigned int cntn = 0; cntn < cntrls.size(); cntn++)
476 if(cntrls.at(cntn).getTagName()==
"login-handler")
478 string provider = cntrls.at(cntn).getAttribute(
"provider");
479 string url = cntrls.at(cntn).getAttribute(
"url");
480 string sessionTimeoutV = cntrls.at(cntn).getAttribute(
"sessionTimeout");
482 securityObject.loginProvider = provider;
483 StringUtil::replaceFirst(url,
"//",
"/");
484 if(url.at(0)==
'/' && url.length()>1)
486 securityObject.loginUrl = url;
488 securityObject.sessTimeout = CastUtil::lexical_cast<
long>(sessionTimeoutV);
490 securityObject.sessTimeout = 3600;
491 logger <<
"\nInvalid session timeout value defined, defaulting to 1hour/3600sec" << endl;
493 configurationData.securityObjectMap[name] = securityObject;
495 else if(cntrls.at(cntn).getTagName()==
"secure")
497 if(configurationData.securityObjectMap.find(name)!=configurationData.securityObjectMap.end())
499 Security securityObject = configurationData.securityObjectMap[name];
500 string path = cntrls.at(cntn).getAttribute(
"path");
501 string role = cntrls.at(cntn).getAttribute(
"role");
503 secureAspect.path = path;
504 secureAspect.role = role;
505 securityObject.secures.push_back(secureAspect);
506 configurationData.securityObjectMap[name] = securityObject;
509 else if(cntrls.at(cntn).getTagName()==
"welcome")
511 string welcomeFile = cntrls.at(cntn).getAttribute(
"file");
512 if(configurationData.securityObjectMap.find(name)!=configurationData.securityObjectMap.end())
514 Security securityObject = configurationData.securityObjectMap[name];
515 securityObject.welocmeFile = welcomeFile;
516 configurationData.securityObjectMap[name] = securityObject;
521 else if(eles.at(apps).getTagName()==
"handoffs")
523 ElementList cntrls = eles.at(apps).getChildElements();
524 for (
unsigned int cntn = 0; cntn < cntrls.size(); cntn++)
526 if(cntrls.at(cntn).getTagName()==
"handoff")
528 string app = cntrls.at(cntn).getAttribute(
"app");
529 string def = cntrls.at(cntn).getAttribute(
"default");
530 string ext = cntrls.at(cntn).getAttribute(
"ext");
531 configurationData.handoffs[app] = def;
532 configurationData.handoffs[app+
"extension"] = ext;
533 handoffVec.push_back(
"-l"+ app+
" ");
539 logger <<
"done reading application.xml " << endl;
636 configureCibernate(name, defpath+
"config/cibernate.xml");
674 logger <<
"started reading fviews.xml " << endl;
675 root = parser.getDocument(defpath+
"config/fviews.xml").getRootElement();
676 if(root.getTagName()==
"fview" && root.getChildElements().size()>0)
678 ElementList eles = root.getChildElements();
679 for (
unsigned int apps = 0; apps < eles.size(); apps++)
681 if(eles.at(apps).getTagName()==
"page")
683 string fvw = eles.at(apps).getAttribute(
"htm");
684 StringUtil::replaceFirst(fvw,
".html",
".fview");
685 configurationData.fviewmap[eles.at(apps).getAttribute(
"htm")] = eles.at(apps).getAttribute(
"class");
686 pathvec.push_back(name);
687 vecvp.push_back(usrincludes);
688 stat.push_back(
false);
689 afcd.push_back(eles.at(apps).getAttribute(
"class"));
690 ElementList elese = eles.at(apps).getChildElements();
691 string nsfns =
"\nvar _fview_namespace = {";
692 string js =
"\n\nwindow.onload = function(){";
693 for (
int appse = 0; appse < (int)elese.size(); appse++)
695 if(elese.at(appse).getTagName()==
"event")
697 nsfns +=
"\n\"_fview_cntxt_global_js_callback"+CastUtil::lexical_cast<
string>(appse)+
"\" : function(response){" + elese.at(appse).getAttribute(
"cb") +
"},";
698 js +=
"\ndocument.getElementById('"+elese.at(appse).getAttribute(
"eid")+
"').";
699 js += elese.at(appse).getAttribute(
"type") +
" = function(){";
700 js += eles.at(apps).getAttribute(
"class")+
"."+elese.at(appse).getAttribute(
"func")+
"(";
701 string args = elese.at(appse).getAttribute(
"args");
704 js += args +
"\"_fview_cntxt_global_js_callback"+CastUtil::lexical_cast<
string>(appse)+
"\",\"/"+name+
"/"+fvw+
"\",_fview_namespace);}";
706 else if(elese.at(appse).getTagName()==
"form")
708 pathvec.push_back(name);
709 vecvp.push_back(usrincludes);
710 stat.push_back(
true);
711 afcd.push_back(elese.at(appse).getAttribute(
"bean"));
712 configurationData.formMap[elese.at(appse).getAttribute(
"name")] = elese.at(appse);
716 nsfns = nsfns.substr(0,nsfns.length()-1) +
"\n}\n";
718 for (
unsigned int appse = 0; appse < elese.size(); appse++)
720 if(elese.at(appse).getTagName()==
"functions")
722 js += elese.at(appse).getText();
725 AfcUtil::writeTofile(pubpath+eles.at(apps).getAttribute(
"class")+
".js",js,
true);
729 logger <<
"done reading fviews.xml " << endl;
731 logger <<
"started generating component code" <<endl;
732 for (
unsigned int var1 = 0;var1<compnts.size();var1++)
734 string cudata,cuheader,curemote,curemoteheaders;
737 string file = gen.generateComponentCU(compnts.at(var1),cudata,cuheader,curemote,curemoteheaders);
738 AfcUtil::writeTofile(rtdcfpath+file+
".h",cuheader,
true);
739 AfcUtil::writeTofile(rtdcfpath+file+
".cpp",cudata,
true);
740 AfcUtil::writeTofile(rtdcfpath+file+
"_Remote.h",curemoteheaders,
true);
741 AfcUtil::writeTofile(rtdcfpath+file+
"_Remote.cpp",curemote,
true);
742 isrcs +=
"./"+file+
".cpp \\\n"+
"./"+file+
"_Remote.cpp \\\n";
743 iobjs +=
"./"+file+
".o \\\n"+
"./"+file+
"_Remote.o \\\n";
744 ideps +=
"./"+file+
".d \\\n"+
"./"+file+
"_Remote.d \\\n";
745 configurationData.cmpnames.push_back(file);
747 catch(
const char* ex)
749 logger << (
"Exception occurred during component code generation : ") << ex << endl;
752 for (
unsigned int cntn = 0; cntn < handoffVec.size(); cntn++)
754 StringUtil::replaceFirst(libs, handoffVec.at(cntn),
"");
756 logger <<
"done generating component code" <<endl;
757 logger <<
"started generating reflection/serialization code" <<endl;
758 string ret = ref.generateClassDefinitionsAll(all,includeRef);
759 string objs, ajaxret, headers,typerefs;
760 AfcUtil::writeTofile(rtdcfpath+
"ReflectorInterface.cpp",ret,
true);
761 ret = ref.generateSerDefinitionAll(all,includeRef,
true, objs, ajaxret, headers,typerefs);
762 AfcUtil::writeTofile(rtdcfpath+
"SerializeInterface.cpp",ret,
true);
763 logger <<
"done generating reflection/serialization code" <<endl;
764 cntxt[
"RUNTIME_LIBRARIES"] = libs;
765 ret = templ.evaluate(rtdcfpath+
"objects.mk.template",cntxt);
766 AfcUtil::writeTofile(rtdcfpath+
"objects.mk",ret,
true);
768 cntxt[
"USER_DEFINED_INC"] = ilibs;
769 cntxt[
"RUNTIME_COMP_SRCS"] = isrcs;
770 cntxt[
"RUNTIME_COMP_OBJS"] = iobjs;
771 cntxt[
"RUNTIME_COMP_DEPS"] = ideps;
772 ret = templ.evaluate(rtdcfpath+
"subdir.mk.template",cntxt);
773 AfcUtil::writeTofile(rtdcfpath+
"subdir.mk",ret,
true);
774 configurationData.dcpsss = dcps;
775 logger <<
"started generating dcp code" <<endl;
776 ret = DCPGenerator::generateDCPAll(dcps);
777 AfcUtil::writeTofile(rtdcfpath+
"DCPInterface.cpp",ret,
true);
778 logger <<
"done generating dcp code" <<endl;
779 configurationData.tpes = tpes;
780 logger <<
"started generating template code" <<endl;
781 ret = TemplateGenerator::generateTempCdAll(tpes);
783 AfcUtil::writeTofile(rtdcfpath+
"TemplateInterface.cpp",ret,
true);
784 logger <<
"done generating template code" <<endl;
786 logger << endl<<
"started generating ajax code" <<endl;
788 ret = AfcUtil::generateJsObjectsAll(vecvp,afcd,stat,ajaxHeaders,objs,infjs,pathvec,ajaxret,typerefs,ajintpthMap);
789 AfcUtil::writeTofile(rtdcfpath+
"AjaxInterface.cpp",ret,
true);
790 AfcUtil::writeTofile(pubpath+
"_afc_Objects.js",objs,
true);
791 AfcUtil::writeTofile(pubpath+
"_afc_Interfaces.js",infjs,
true);
792 AfcUtil::writeTofile(incpath+
"AfcInclude.h",(ajaxHeaders+headers),
true);
793 logger <<
"done generating ajax code" <<endl;
796 logger <<
"started generating application code" <<endl;
797 ret = apputil.buildAllApplications(appf,webdirs1,configurationData.appMap);
798 AfcUtil::writeTofile(rtdcfpath+
"ApplicationInterface.cpp",ret,
true);
799 logger <<
"done generating application code" <<endl;
801 logger <<
"started generating web-service code" <<endl;
802 ret = wsu.generateAllWSDL(wspath,respath,configurationData.wsdlmap);
803 AfcUtil::writeTofile(rtdcfpath+
"WsInterface.cpp",ret,
true);
804 logger <<
"done generating web-service code" <<endl;
807 cntxt[
"TARGET_LIB"] =
"all";
808 cntxt[
"Dynamic_Public_Folder_Copy"] = rundyncontent;
809 string cont = engine.evaluate(respath+
"/rundyn_template.sh", cntxt);
810 AfcUtil::writeTofile(respath+
"/rundyn.sh", cont,
true);
812 cntxt[
"TARGET_LIB"] =
"libdinter";
813 cntxt[
"Dynamic_Public_Folder_Copy"] = rundyncontent;
814 cont = engine.evaluate(respath+
"/rundyn_template.sh", cntxt);
815 AfcUtil::writeTofile(respath+
"/rundyn_dinter.sh", cont,
true);
816 return configurationData;
819 void ConfigurationHandler::configureCibernate(
string name,
string configFile)
821 Logger logger = Logger::getLogger(
"ConfigurationHandler");
823 logger << (
"started reading cibernate config file " + configFile) << endl;
825 smstrMap appTableColMapping;
827 relMap appTableRelMapping;
828 Element dbroot = parser.getDocument(configFile).getRootElement();
829 if(dbroot.getTagName()==
"cibernate")
831 ElementList dbeles = dbroot.getChildElements();
832 for (
unsigned int dbs = 0; dbs < dbeles.size(); dbs++)
834 if(dbeles.at(dbs).getTagName()==
"config")
836 ElementList confs = dbeles.at(dbs).getChildElements();
839 for (
unsigned int cns = 0; cns < confs.size(); cns++)
841 if(confs.at(cns).getTagName()==
"uid")
843 uid = confs.at(cns).getText();
845 else if(confs.at(cns).getTagName()==
"pwd")
847 pwd = confs.at(cns).getText();
849 else if(confs.at(cns).getTagName()==
"dsn")
851 dsn = confs.at(cns).getText();
853 else if(confs.at(cns).getTagName()==
"pool-size")
855 if(confs.at(cns).getText()!=
"")
856 psize = CastUtil::lexical_cast<int>(confs.at(cns).getText());
859 CibernateConnPools::addPool(psize,uid,pwd,dsn,name);
861 else if(dbeles.at(dbs).getTagName()==
"tables")
863 ElementList tabs = dbeles.at(dbs).getChildElements();
864 for (
unsigned int dn = 0; dn < tabs.size(); dn++)
866 if(tabs.at(dn).getTagName()==
"table")
869 maptcl[tabs.at(dn).getAttribute(
"class")] = tabs.at(dn).getAttribute(
"name");
870 ElementList cols = tabs.at(dn).getChildElements();
871 for (
unsigned int cn = 0; cn < cols.size(); cn++)
873 if(cols.at(cn).getTagName()==
"hasOne")
876 relation.clsName = cols.at(cn).getText();
878 relation.fk = cols.at(cn).getAttribute(
"fk");
879 relation.pk = cols.at(cn).getAttribute(
"pk");
880 relation.field = cols.at(cn).getAttribute(
"field");
881 relv.push_back(relation);
883 else if(cols.at(cn).getTagName()==
"hasMany")
886 relation.clsName = cols.at(cn).getText();
888 relation.fk = cols.at(cn).getAttribute(
"fk");
889 relation.pk = cols.at(cn).getAttribute(
"pk");
890 relation.field = cols.at(cn).getAttribute(
"field");
891 relv.push_back(relation);
893 else if(cols.at(cn).getTagName()==
"many")
896 relation.clsName = cols.at(cn).getText();
898 relation.fk = cols.at(cn).getAttribute(
"fk");
899 relation.pk = cols.at(cn).getAttribute(
"pk");
900 relv.push_back(relation);
902 else if(cols.at(cn).getTagName()==
"col")
904 maptc[cols.at(cn).getAttribute(
"obf")] = StringUtil::toLowerCopy(cols.at(cn).getAttribute(
"dbf"));
907 appTableColMapping[tabs.at(dn).getAttribute(
"class")] = maptc;
908 appTableRelMapping[tabs.at(dn).getAttribute(
"class")] = relv;
914 mapping->setAppTableColMapping(appTableColMapping);
915 mapping->setAppTableClassMapping(maptcl);
916 mapping->setAppTableRelMapping(appTableRelMapping);
917 CibernateConnPools::addMapping(name,mapping);
918 logger <<
"done reading cibernate config file " + configFile << endl;
922 void ConfigurationHandler::destroyCibernate()
924 map<string,Mapping*> mappings = CibernateConnPools::getMappings();
925 map<string,Mapping*>::iterator it;
926 for(it=mappings.begin();it!=mappings.end();it++)