$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_CodeEditor_h_ 00002 #define _ots_CodeEditor_h_ 00003 00004 #include "otsdaq-core/Macros/CoutMacros.h" 00005 #include "otsdaq-core/Macros/StringMacros.h" 00006 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00007 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h" 00008 #include "xgi/Method.h" //for cgicc::Cgicc 00009 00010 #include <iostream> 00011 #include <string> 00012 #include <unordered_map> 00013 #include <vector> 00014 00015 namespace ots 00016 { 00017 class HttpXmlDocument; 00018 00019 // CodeEditor 00020 // This class provides the functionality for editing, saving, and building code 00021 class CodeEditor 00022 { 00023 public: 00024 CodeEditor(); 00025 00026 // request are handled here 00027 void xmlRequest(const std::string& option, 00028 cgicc::Cgicc& cgiIn, 00029 HttpXmlDocument* xmlOut, 00030 const std::string& username); 00031 00032 private: 00033 void getDirectoryContent(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut); 00034 void getPathContent(const std::string& basepath, 00035 const std::string& path, 00036 HttpXmlDocument* xmlOut); 00037 void getFileContent(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut); 00038 void saveFileContent(cgicc::Cgicc& cgiIn, 00039 HttpXmlDocument* xmlOut, 00040 const std::string& username); 00041 void build(cgicc::Cgicc& cgiIn, HttpXmlDocument* xmlOut, const std::string& username); 00042 00043 std::string safePathString(const std::string& path); 00044 std::string safeExtensionString(const std::string& extension); 00045 00046 public: 00047 static const std::string SPECIAL_TYPE_FEInterface, SPECIAL_TYPE_DataProcessor, 00048 SPECIAL_TYPE_Table, SPECIAL_TYPE_ControlsInterface, SPECIAL_TYPE_Tools, 00049 SPECIAL_TYPE_UserData, SPECIAL_TYPE_OutputData; 00050 00051 static const std::string SOURCE_BASE_PATH, USER_DATA_PATH, OTSDAQ_DATA_PATH; 00052 00053 static std::map<std::string /*special type*/, 00054 std::set<std::string> /*special file paths*/> 00055 getSpecialsMap(void); 00056 00057 static void readFile(const std::string& basepath, 00058 const std::string& path, 00059 std::string& contents); 00060 static void writeFile(const std::string& basepath, 00061 const std::string& path, 00062 const std::string& contents, 00063 const std::string& username, 00064 const unsigned long long& insertPos = -1, 00065 const std::string& insertString = ""); 00066 00067 const std::set<std::string> ALLOWED_FILE_EXTENSIONS_; 00068 }; 00069 00070 } // namespace ots 00071 00072 #endif