otsdaq  3.11.00
CodeEditor.h
1 #ifndef _ots_CodeEditor_h_
2 #define _ots_CodeEditor_h_
3 
4 #include "otsdaq/Macros/CoutMacros.h"
5 #include "otsdaq/Macros/StringMacros.h"
6 #include "otsdaq/MessageFacility/MessageFacility.h"
7 #include "otsdaq/SOAPUtilities/SOAPMessenger.h"
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
10 #include <xgi/Method.h> //for cgicc::Cgicc
11 #pragma GCC diagnostic pop
12 
13 #include <iostream>
14 #include <string>
15 #include <unordered_map>
16 #include <vector>
17 
18 namespace ots
19 {
20 class HttpXmlDocument;
21 
25 {
26  public:
27  CodeEditor();
28 
30  void xmlRequest(const std::string& option,
31  bool readOnlyMode,
32  cgicc::Cgicc& cgiIn,
33  HttpXmlDocument* xmlOut,
34  const std::string& username);
35 
36  private:
37  void getDirectoryContent(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut);
38  void getPathContent(const std::string& basepath,
39  const std::string& path,
40  HttpXmlDocument* xmlOut);
41  void getFileContent(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut);
42  void getFhiclFileContent(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut);
43  void getFileGitURL(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut);
44  void saveFileContent(cgicc::Cgicc& cgiIn,
45  HttpXmlDocument* xmlOut,
46  const std::string& username);
47  void build(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut, const std::string& username);
48 
49  std::string safePathString(const std::string& path);
50  std::string safeExtensionString(const std::string& extension);
51 
52  public:
53  static const std::string SPECIAL_TYPE_FEInterface, SPECIAL_TYPE_DataProcessor,
54  SPECIAL_TYPE_Table, SPECIAL_TYPE_SlowControls, SPECIAL_TYPE_Tools,
55  SPECIAL_TYPE_UserData, SPECIAL_TYPE_WebPath, SPECIAL_TYPE_OutputData;
56 
57  static const std::string SOURCE_BASE_PATH, USER_DATA_PATH, OTSDAQ_WEB_PATH,
58  OTSDAQ_DATA_PATH;
59 
60  static std::map<std::string /*special type*/,
61  std::set<std::string> /*special file paths*/>
62  getSpecialsMap(void);
63 
64  static void readFile(const std::string& basepath,
65  const std::string& path,
66  std::string& contents,
67  bool binaryRead = false);
68  static void writeFile(const std::string& basepath,
69  const std::string& path,
70  const std::string& contents,
71  const std::string& username,
72  const unsigned long long& insertPos = -1,
73  const std::string& insertString = "");
74  static std::string getFileGitURL(const std::string& basepath,
75  const std::string& path);
76 
77  const std::set<std::string> ALLOWED_FILE_EXTENSIONS_;
78 };
79 
80 } // namespace ots
81 
82 #endif
void xmlRequest(const std::string &option, bool readOnlyMode, cgicc::Cgicc &cgiIn, HttpXmlDocument *xmlOut, const std::string &username)
request are handled here
defines used also by OtsConfigurationWizardSupervisor