1 #include "otsdaq-utilities/Visualization/VisualSupervisor.h"
2 #include "otsdaq/DataManager/DataManagerSingleton.h"
3 #include "otsdaq/Macros/BinaryStringMacros.h"
4 #include "otsdaq/RootUtilities/VisualDataManager.h"
5 #include "otsdaq/XmlUtilities/XmlDocument.h"
7 #include <boost/regex.hpp>
8 #include "otsdaq/DataManager/DQMHistosConsumerBase.h"
9 #include "otsdaq/Macros/MessageTools.h"
10 #include "otsdaq/RootUtilities/RootFileExplorer.h"
15 #include <TBranchElement.h>
17 #include <TBufferJSON.h>
20 #include <TDirectory.h>
24 #include <TIterator.h>
31 #include "TBufferFile.h"
37 #include <xdaq/NamespaceURI.h>
47 #define ROOT_BROWSER_PATH __ENV__("ROOT_BROWSER_PATH")
48 #define ROOT_DISPLAY_CONFIG_PATH __ENV__("ROOT_DISPLAY_CONFIG_PATH")
50 #define LIVEDQM_DIR std::string("LIVE_DQM")
51 #define PRE_MADE_ROOT_CFG_DIR std::string("Pre-made Views")
53 #define PRE_MADE_ROOT_CFG_FILE_EXT std::string(".rcfg")
55 #define PREFERENCES_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/VisualizerData/"
56 #define PREFERENCES_FILE_EXT ".pref"
58 #define ROOT_VIEWER_PERMISSIONS_THRESHOLD 100
63 #define __MF_SUBJECT__ "Visualizer"
68 #define STDLINE(X, Y) __COUT__ << X
71 VisualSupervisor::VisualSupervisor(xdaq::ApplicationStub* stub)
74 __SUP_COUT__ <<
"Constructor." << __E__;
77 mkdir(((std::string)PREFERENCES_PATH).c_str(), 0755);
78 ROOT::EnableThreadSafety();
80 __SUP_COUT__ <<
"Constructed." << __E__;
84 VisualSupervisor::~VisualSupervisor(
void)
86 __SUP_COUT__ <<
"Destructor." << __E__;
88 __SUP_COUT__ <<
"Destructed." << __E__;
92 void VisualSupervisor::destroy(
void)
94 __SUP_COUT__ <<
"Destroying..." << __E__;
97 if(theStateMachineImplementation_.size() > 1)
99 __SS__ <<
"Not expecting more than one visual data manager!" << __E__;
102 if(theStateMachineImplementation_.size())
103 theStateMachineImplementation_.pop_back();
105 __COUT_WARN__ <<
"No visual data manager was pushed." << __E__;
112 __SUP_COUT__ <<
"Configuring..." << __E__;
116 if(RunControlStateMachine::getIterationIndex() == 0 &&
117 RunControlStateMachine::getSubIterationIndex() == 0)
120 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
122 .getValue(
"ConfigurationTableGroupName"),
124 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
126 .getValue(
"ConfigurationTableGroupKey")));
128 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first
129 <<
" key: " << theGroup.second << __E__;
132 theConfigurationManager_->loadTableGroup(
145 ConfigurationManager::LoadGroupType::ALL_TYPES,
154 theConfigurationManager_->__GET_CONFIG__(
XDAQContextTable)->getTableName() +
155 CorePropertySupervisorBase::getSupervisorConfigurationPath());
157 catch(
const std::runtime_error& e)
159 __SS__ <<
"The link to the Visual Supervisor configuration seems to be broken. "
160 "Please check this path: "
164 CorePropertySupervisorBase::getSupervisorConfigurationPath()
165 << __E__ << __E__ << e.what() << __E__;
170 "/" + theConfigurationManager_->__GET_CONFIG__(
XDAQContextTable)->getTableName() +
171 CorePropertySupervisorBase::getSupervisorConfigurationPath());
177 theDataManager_ = DataManagerSingleton::getInstance<VisualDataManager>(
178 theConfigurationManager_->getNode(
181 CorePropertySupervisorBase::getSupervisorConfigurationPath(),
182 CorePropertySupervisorBase::getSupervisorUID());
184 CoreSupervisorBase::theStateMachineImplementation_.push_back(theDataManager_);
186 __SUP_COUT__ <<
"Done instantiating Visual data manager." << __E__;
189 __SUP_COUT__ <<
"No Visual Supervisor configuration link, so skipping Visual "
190 "data manager instantiation."
194 CoreSupervisorBase::transitionConfiguringFSMs();
196 __SUP_COUT__ <<
"Configured." << __E__;
198 catch(
const std::runtime_error& e)
200 __SS__ <<
"Error with VisualSupervisor::transitionConfiguring(): " << e.what()
202 __COUT_ERR__ << ss.str();
206 theStateMachine_.setErrorMessage(ss.str());
207 throw toolbox::fsm::exception::Exception(
210 "VisualSupervisor::transitionConfiguring" ,
217 void VisualSupervisor::transitionHalting(toolbox::Event::Reference e)
219 __SUP_COUT__ <<
"Halting..." << __E__;
224 __SUP_COUT__ <<
"Halted." << __E__;
233 CorePropertySupervisorBase::setSupervisorProperty(
234 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AllowNoLoginRequestTypes,
235 "setUserPreferences | getUserPreferences | getDirectoryContents | getRoot | "
238 CorePropertySupervisorBase::setSupervisorProperty(
239 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
240 "*=1 | rootAdminControls=100");
248 CorePropertySupervisorBase::setSupervisorProperty(
249 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
250 "getRoot | getEvents");
251 CorePropertySupervisorBase::setSupervisorProperty(
252 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.NoXmlWhiteSpaceRequestTypes,
253 "getRoot | getEvents");
261 const WebUsers::RequestUserInfo& userInfo)
288 __SUP_COUT__ <<
"Request type: " << requestType << __E__;
292 __SUP_COUT__ << __E__;
297 if(theDataManager_ ==
nullptr)
299 __SS__ <<
"No data manager instantiated." << __E__;
302 __SUP_COUT__ <<
"Getting Raw data and converting to binary string" << __E__;
305 __SUP_COUT__ << __E__;
306 __SUP_SS__ <<
"Raw data visualizion is deprecated!" << __E__;
309 catch(std::exception
const& e)
312 <<
"ERROR! Exception while getting raw data. Incoming exception data..."
314 __SUP_COUT__ << e.what() << __E__;
315 __SUP_COUT__ <<
"End Exception Data" << __E__;
319 __SUP_COUT__ <<
"ERROR! Something went wrong trying to get raw data."
325 catch(
const std::exception& e)
327 __SUP_COUT_ERR__ <<
"Exception message: " << e.what();
332 __SUP_COUT_INFO__ <<
"ERROR! Something went wrong trying to get raw data."
337 requestType ==
"setUserPreferences" &&
338 userInfo.username_ !=
341 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
342 std::string fullPath =
343 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
344 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
350 std::string autoRefreshPeriod =
353 __SUP_COUT__ <<
"radioSelect: " << radioSelect << __E__;
354 __SUP_COUT__ <<
"autoRefresh: " << autoRefresh << __E__;
355 __SUP_COUT__ <<
"autoHide: " << autoHide << __E__;
356 __SUP_COUT__ <<
"hardRefresh: " << hardRefresh << __E__;
357 __SUP_COUT__ <<
"autoRefreshPeriod: " << autoRefreshPeriod << __E__;
360 FILE* fp = fopen(fullPath.c_str(),
"r");
366 fgets(line, 100, fp);
367 sscanf(line,
"%*s %s", val);
368 if(radioSelect ==
"")
371 fgets(line, 100, fp);
372 sscanf(line,
"%*s %s", val);
373 if(autoRefresh ==
"")
376 fgets(line, 100, fp);
377 sscanf(line,
"%*s %s", val);
381 fgets(line, 100, fp);
382 sscanf(line,
"%*s %s", val);
383 if(hardRefresh ==
"")
386 fgets(line, 100, fp);
387 sscanf(line,
"%*s %s", val);
388 if(autoRefreshPeriod ==
"")
389 autoRefreshPeriod = val;
395 fp = fopen(fullPath.c_str(),
"w");
398 fprintf(fp,
"radioSelect %s\n", radioSelect.c_str());
399 fprintf(fp,
"autoRefresh %s\n", autoRefresh.c_str());
400 fprintf(fp,
"autoHide %s\n", autoHide.c_str());
401 fprintf(fp,
"hardRefresh %s\n", hardRefresh.c_str());
402 fprintf(fp,
"autoRefreshPeriod %s\n", autoRefreshPeriod.c_str());
406 __SUP_COUT_ERR__ <<
"Failure writing preferences to file: " << fullPath
411 "getUserPreferences")
413 __SUP_COUT__ <<
"Next is userinfo" << __E__;
414 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
415 std::string fullPath =
416 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
417 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
419 FILE* fp = fopen(fullPath.c_str(),
"r");
426 fgets(line, 100, fp);
427 sscanf(line,
"%*s %d", &val);
428 if(val < 0 || val > 3)
430 xmlOut.addTextElementToData(
"radioSelect", std::to_string(val));
431 fgets(line, 100, fp);
432 sscanf(line,
"%*s %d", &val);
433 xmlOut.addTextElementToData(
"autoRefresh", std::to_string(val));
434 fgets(line, 100, fp);
435 sscanf(line,
"%*s %d", &val);
436 xmlOut.addTextElementToData(
"autoHide", std::to_string(val));
437 fgets(line, 100, fp);
438 sscanf(line,
"%*s %d", &val);
439 xmlOut.addTextElementToData(
"hardRefresh", std::to_string(val));
440 fgets(line, 100, fp);
441 sscanf(line,
"%*s %d", &val);
442 xmlOut.addTextElementToData(
"autoRefreshPeriod", std::to_string(val));
448 xmlOut.addTextElementToData(
"radioSelect",
"");
449 xmlOut.addTextElementToData(
"autoRefresh",
"");
450 xmlOut.addTextElementToData(
"autoHide",
"");
451 xmlOut.addTextElementToData(
"hardRefresh",
"");
452 xmlOut.addTextElementToData(
"autoRefreshPeriod",
"");
454 __SUP_COUT__ <<
"Done with preferences!" << __E__;
458 "getDirectoryContents")
461 std::string rootpath =
462 std::string(ROOT_BROWSER_PATH) +
465 boost::regex re(
"%2F");
466 path = boost::regex_replace(path, re,
"/");
476 userInfo.permissionLevel_ >=
478 "rootAdminControls"));
479 xmlOut.addTextElementToData(
"permissions", permStr);
483 std::string dirpath = rootpath + path;
485 if(path ==
"/" + PRE_MADE_ROOT_CFG_DIR +
"/")
486 dirpath = ROOT_DISPLAY_CONFIG_PATH;
488 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
490 dirpath = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
491 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
494 __SUP_COUT__ <<
"rootpath:-" << rootpath <<
"-path:-" << path <<
"-dirpath:-"
495 << dirpath <<
"-" << __E__;
498 struct dirent* entry;
501 if((pDIR = opendir(dirpath.c_str())))
503 xmlOut.addTextElementToData(
"path", path);
504 xmlOut.addTextElementToData(
"headOfSearch",
"located");
509 if(theDataManager_ !=
nullptr)
510 __COUT__ <<
"path-" << path <<
"-DM: " << theDataManager_
511 <<
" Live: " << theDataManager_->getLiveDQMHistos() << std::endl;
515 if(theDataManager_ !=
nullptr &&
516 theDataManager_->getLiveDQMHistos() ==
true)
517 xmlOut.addTextElementToData(
"dir",
518 LIVEDQM_DIR +
".root");
521 DIR* pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH);
522 bool recheck =
false;
526 if(mkdir(ROOT_DISPLAY_CONFIG_PATH,
527 S_IRWXU | (S_IRGRP | S_IXGRP) |
528 (S_IROTH | S_IXOTH)))
529 __SUP_COUT__ <<
"Failed to make directory for pre made views: "
530 << ROOT_DISPLAY_CONFIG_PATH << __E__;
535 if(!recheck || (pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH)))
539 xmlOut.addTextElementToData(
"dir",
540 PRE_MADE_ROOT_CFG_DIR);
546 while((entry = readdir(pDIR)))
550 if(entry->d_name[0] !=
'.' &&
553 entry->d_type == 4 ||
559 std::string(entry->d_name).find(
".rcfg") == std::string::npos;
562 if(entry->d_type == 0)
566 DIR* pTmpDIR = opendir((dirpath + entry->d_name).c_str());
576 if((entry->d_type == 8 ||
577 (!isDir && entry->d_type == 0))
578 && std::string(entry->d_name).find(
".root") == std::string::npos &&
581 else if(entry->d_type == 4)
584 xmlOut.addTextElementToData(
585 isDir ?
"dir" : (isNotRtCfg ?
"dir" :
"file"), entry->d_name);
591 __SUP_COUT__ <<
"Failed to access directory contents!" << __E__;
603 unsigned splitter = path.find(
".root") + 5;
604 std::string rootFileName =
605 std::string(__ENV__(
"ROOT_BROWSER_PATH")) + path.substr(0, splitter);
606 __SUP_COUTV__(rootFileName);
608 std::string rootDirectoryName = path.substr(splitter, path.length() - splitter);
609 __SUP_COUTV__(rootDirectoryName);
614 bool isLiveDQM = (path.find(
"/" + LIVEDQM_DIR +
".root/") == 0) ?
true :
false;
615 __SUP_COUTV__(isLiveDQM);
617 TFile* rootFile =
nullptr;
618 TObject* tObject =
nullptr;
619 TDirectory* tDirectory =
nullptr;
623 rootFile = TFile::Open(rootFileName.c_str());
625 if(rootFile ==
nullptr || !rootFile->IsOpen())
627 __SUP_SS__ <<
"Failed to access ROOT file: " << rootFileName << __E__;
632 if((tObject = rootFile->Get(rootDirectoryName.c_str())) !=
634 (rootDirectoryName.size() &&
635 rootDirectoryName[0] ==
'/' &&
636 (tObject = rootFile->Get(rootDirectoryName.substr(1).c_str())) !=
639 if(tObject->IsA() == TCanvas::Class())
641 static_cast<TCanvas*
>(tObject)->Modified();
642 static_cast<TCanvas*
>(tObject)->Update();
644 TString json = TBufferJSON::ConvertToJSON(tObject);
645 TBufferFile tBuffer(TBuffer::kWrite);
646 tObject->Streamer(tBuffer);
648 tBuffer.Buffer(), tBuffer.Length());
650 __SUP_COUT__ <<
"Returning object from file '" << tObject->GetName()
651 <<
"' of class '" << tObject->ClassName() << __E__;
653 xmlOut.addTextElementToData(
"path", path);
654 xmlOut.addTextElementToData(
"rootType", tObject->ClassName());
655 xmlOut.addTextElementToData(
"rootData", hexString);
656 xmlOut.addTextElementToData(
"rootJSON", json.Data());
658 else if((tDirectory = rootFile->GetDirectory(rootDirectoryName.c_str())) !=
662 TIter next(tDirectory->GetListOfKeys());
663 xmlOut.addTextElementToData(
"path", path);
664 while((key = (TKey*)next()))
666 TString s = key->GetName();
667 TRegexp re(
"*", kTRUE);
668 if(s.Index(re) == kNPOS)
670 __SUP_COUT__ <<
"Class Name: " << key->GetClassName() << __E__;
671 xmlOut.addTextElementToData(
672 (std::string(key->GetClassName()).find(
"Directory") !=
674 std::string(key->GetClassName()) ==
"TTree" ||
675 std::string(key->GetClassName()).find(
"TBranch") !=
684 tObject = key->ReadObj();
685 __SUP_COUT__ <<
"JSON : " << key->GetClassName() << __E__;
687 TString json = TBufferJSON::ConvertToJSON(tObject);
688 TBufferFile tBuffer(TBuffer::kWrite);
689 tObject->Streamer(tBuffer);
690 std::string hexString =
694 __SUP_COUT__ <<
"Returning directory object from file '"
695 << tObject->GetName() <<
"' of class '"
696 << tObject->ClassName() << __E__;
698 __SUP_COUTV__(json.Data());
704 __SUP_COUT_ERR__ <<
"Failed to find object " << rootDirectoryName
705 <<
" in " << rootFileName << __E__;
709 else if(theDataManager_ !=
nullptr && theDataManager_->isReady())
711 if(theDataManager_ !=
nullptr)
712 theDataManager_->setDoNotStop(
true);
715 __SUP_COUT__ <<
"Attempting to get LIVE ROOT object." << __E__;
717 std::vector<DQMHistosBase*> dqmConsumers = theDataManager_->
getLiveDQMs();
719 for(
auto const& consumer : dqmConsumers)
721 rootFile = consumer->getFile();
722 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
723 if(rootFile ==
nullptr || !rootFile->IsOpen())
725 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
727 theDataManager_->setDoNotStop(
false);
731 if((tObject = rootFile->Get(rootDirectoryName.c_str())) !=
nullptr)
733 __SUP_COUT__ <<
"Object class name: " << tObject->ClassName()
735 std::string tmpClassName = tObject->ClassName();
737 TBufferFile tBuffer(TBuffer::kWrite);
738 if(tObject->IsA() == TCanvas::Class())
740 static_cast<TCanvas*
>(tObject)->Modified();
741 static_cast<TCanvas*
>(tObject)->Update();
744 std::unique_lock<std::mutex> lock(
746 ->getFillHistoMutex());
747 json = TBufferJSON::ConvertToJSON(tObject);
748 tObject->Streamer(tBuffer);
751 tBuffer.Buffer(), tBuffer.Length());
753 __SUP_COUT__ <<
"Returning object '" << tObject->GetName()
754 <<
"' of class '" << tObject->ClassName() << __E__;
757 xmlOut.addTextElementToData(
"path", path);
758 xmlOut.addTextElementToData(
"rootType", tObject->ClassName());
759 xmlOut.addTextElementToData(
"rootData", hexString);
760 xmlOut.addTextElementToData(
"rootJSON", json.Data());
762 theDataManager_->setDoNotStop(
false);
767 std::map<std::string, std::string> dirList;
769 for(
auto const& consumer : dqmConsumers)
771 __SUP_COUT__ <<
"Attempting to get LIVE ROOT directory." << __E__;
772 rootFile = consumer->getFile();
773 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
774 if(rootFile ==
nullptr || !rootFile->IsOpen())
776 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
778 xmlOut.addTextElementToData(
"Warning", ss.str());
779 theDataManager_->setDoNotStop(
false);
782 if((tDirectory = rootFile->GetDirectory(rootDirectoryName.c_str())) !=
785 xmlOut.addTextElementToData(
"path", path);
786 __SUP_COUT__ <<
"Directory found getting the content!" << __E__;
787 TRegexp re(
"*", kTRUE);
789 TIter nextobj(tDirectory->GetList());
790 while((obj = (TObject*)nextobj()))
792 TString s = obj->GetName();
793 if(s.Index(re) == kNPOS)
795 __SUP_COUT__ <<
"Class Name: " << obj->IsA()->GetName() << __E__;
796 dirList[obj->GetName()] =
797 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
799 std::string(obj->IsA()->GetName()) ==
"TTree" ||
800 std::string(obj->IsA()->GetName()).find(
"TBranch") !=
807 for(
auto const& dir : dirList)
809 xmlOut.addTextElementToData(dir.second, dir.first);
810 __SUP_COUT__ <<
"Class Name: " << dir.second <<
" Object: " << dir.first
1218 if(theDataManager_ ==
nullptr)
1220 __SS__ <<
"No Data Manager instantiated." << __E__;
1224 int Run = atoi(cgiIn(
"run").c_str());
1226 __SUP_COUT__ <<
"getEvents for run " << Run << __E__;
1228 if(Run != (
int)loadedRunNumber_ || loadedRunNumber_ == (
unsigned int)-1)
1230 theDataManager_->load(
"Run1684.root",
"Monicelli");
1231 loadedRunNumber_ = Run;
1234 xmlOut.addTextElementToData(
"events",
"");
1277 __SUP_COUT__ <<
"Done hits xml" << __E__;
1283 __SUP_COUT__ <<
"getGeometry" << __E__;
1285 if(theDataManager_ ==
nullptr)
1287 __SS__ <<
"No Data Manager instantiated." << __E__;
1292 theDataManager_->load(
"Run1684.geo",
"Geometry");
1294 __SUP_COUT__ <<
"getGeometry" << __E__;
1296 xmlOut.addTextElementToData(
"geometry",
"");
1332 __SUP_COUT__ <<
"path " << path << __E__;
1334 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1337 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1338 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
1339 __SUP_COUT__ <<
"mod path " << path << __E__;
1345 xmlOut.addTextElementToData(
"status",
"1");
1350 xmlOut.addTextElementToData(
"status",
1351 "Failed. File to properly load config file.");
1355 "rootAdminControls")
1367 std::string cmd = cgiIn(
"cmd");
1374 __SUP_COUT__ <<
"cmd " << cmd << __E__;
1375 __SUP_COUT__ <<
"path " << path << __E__;
1376 __SUP_COUT__ <<
"name " << name << __E__;
1378 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1381 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1382 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2) + name;
1383 __SUP_COUT__ <<
"mod path " << path << __E__;
1387 if(mkdir(path.c_str(),
1388 S_IRWXU | (S_IRGRP | S_IXGRP) |
1389 (S_IROTH | S_IXOTH)))
1390 xmlOut.addTextElementToData(
"status",
1391 "Failed. Directory create rejected.");
1393 xmlOut.addTextElementToData(
"status",
"1");
1395 else if(cmd ==
"save")
1397 path += PRE_MADE_ROOT_CFG_FILE_EXT;
1399 bool useRunWildCard =
1403 __SUP_COUT__ <<
"config " << config << __E__;
1404 __SUP_COUT__ <<
"useRunWildCard " << useRunWildCard << __E__;
1407 FILE* fp = fopen(path.c_str(),
"r");
1411 xmlOut.addTextElementToData(
"status",
"Failed. File already exists.");
1412 __SUP_COUT__ <<
" Failed. File already exists." << __E__;
1421 fp = fopen(path.c_str(),
"w");
1422 fputs(config.c_str(), fp);
1431 xmlOut.addTextElementToData(
"status",
"1");
1435 xmlOut.addTextElementToData(
1436 "status",
"Failed. Fatal. Improper file format.");
1437 if(remove(path.c_str()) != 0)
1438 __SUP_COUT__ <<
"Failed. Could not remove poorly formed Root "
1444 else if(cmd ==
"delete")
1447 if(rmdir(path.c_str()) == 0 ||
1448 remove((path + PRE_MADE_ROOT_CFG_FILE_EXT).c_str()) == 0)
1449 xmlOut.addTextElementToData(
"status",
"1");
1451 xmlOut.addTextElementToData(
"status",
1452 "Failed. Target could not be deleted.");
1455 xmlOut.addTextElementToData(
"status",
"Failed. Unrecognized command.");
1458 xmlOut.addTextElementToData(
"status",
"Failed. Invalid path.");
1467 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1469 boost::regex re(
"%2F");
1470 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1471 std::string fullPath = fSystemPath + fRootPath;
1473 STDLINE(std::string(
"Begin: fSystemPath = ") + fSystemPath, ACWhite);
1474 STDLINE(std::string(
"Begin: fRootPath = ") + fRootPath, ACWhite);
1475 STDLINE(std::string(
"Begin: fullPath = ") + fullPath, ACWhite);
1478 xmlOut.setRootPath(fRootPath);
1479 xmlOut.makeDirectoryBinaryTree(fSystemPath, fRootPath, 0, NULL);
1480 std::ostringstream* out =
new std::ostringstream();
1488 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1494 boost::regex re(
"%2F");
1495 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1496 fFoldersPath = boost::regex_replace(fFoldersPath, re,
"/");
1504 fSystemPath, fRootPath, fFoldersPath, fHistName, fRFoldersPath, fFileName);
1505 xmlOut.setDocument(theExplorer->initialize(
false));
1571 "saveConfiguration")
1574 STDLINE(
"configPayload: ", ACRed);
1575 STDLINE(configPayload, ACYellow);
1578 outFile.open(
"/tmp/configPayload.json", ios::out | ios::app);
1579 outFile << configPayload << endl;
1587 std::string JSONPayLoad =
"";
1588 std::string line =
"";
1590 ifstream JSONFile(
"/tmp/configPayload.json");
1592 if(JSONFile.is_open())
1594 while(getline(JSONFile, line))
1596 JSONPayLoad += line;
1601 xmlOut.addTextElementToData(
"JSONPayLoad", JSONPayLoad);
1605 if(theDataManager_ !=
nullptr)
1606 theDataManager_->setDoNotStop(
false);
static std::string postData(cgicc::Cgicc &cgi, const std::string &needle)
static std::string getData(cgicc::Cgicc &cgi, const std::string &needle)
bool isDisconnected(void) const
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
const std::string & getValueAsString(bool returnLinkTableValue=false) const
WebUsers::permissionLevel_t getSupervisorPropertyUserPermissionsThreshold(const std::string &requestType)
virtual void transitionHalting(toolbox::Event::Reference event)
static void deleteInstance(std::string instanceUID)
void copyDataChildren(HttpXmlDocument &document)
bool loadXmlDocument(const std::string &filePath)
void outputXmlDocument(std::ostringstream *out, bool dispStdOut=false, bool allowWhiteSpace=false, bool printErrors=false)
const std::vector< DQMHistosBase * > & getLiveDQMs(void)
virtual void setSupervisorPropertyDefaults(void) override
virtual void forceSupervisorPropertyValues(void) override
virtual void transitionConfiguring(toolbox::Event::Reference e) override
virtual void request(const std::string &requestType, cgicc::Cgicc &cgiIn, HttpXmlDocument &xmlOut, const WebUsers::RequestUserInfo &userInfo) override
void setDarioStyle(bool darioStyle)
void saveXmlDocument(const std::string &filePath)
void INIT_MF(const char *name)
static std::string binaryStringToHexString(const void *binaryBuffer, unsigned int numberOfBytes, const std::string &resultPreamble="", const std::string &resultDelimiter="")