otsdaq  v2_05_02_indev
WizardSupervisor.h
1 #ifndef _ots_WizardSupervisor_h
2 #define _ots_WizardSupervisor_h
3 
4 #include "otsdaq/SOAPUtilities/SOAPMessenger.h"
5 
6 #pragma GCC diagnostic push
7 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
8 #include <xdaq/Application.h>
9 #pragma GCC diagnostic pop
10 #include "otsdaq/Macros/XDAQApplicationMacros.h"
11 
12 #include <xoap/Method.h>
13 #include <xoap/SOAPBody.h>
14 #include <xoap/SOAPEnvelope.h>
15 #include <xoap/domutils.h>
16 
17 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
19 #include <xgi/Method.h>
20 #include <cgicc/HTMLClasses.h>
21 #include <cgicc/HTMLDoctype.h>
22 #include <cgicc/HTTPCookie.h>
23 #include <cgicc/HTTPHeader.h>
24 #pragma GCC diagnostic pop
25 
26 #include <map>
27 #include <string>
28 
29 #include "otsdaq/SupervisorInfo/AllSupervisorInfo.h"
30 
31 namespace ots
32 {
33 // clang-format off
34 class HttpXmlDocument;
35 
36 // WizardSupervisor
37 // This class is a xdaq application.
38 //
39 // It is instantiated by the xdaq context when otsdaq is in "Wiz Mode."
40 //
41 // It is different from the "Normal Mode" Gateway Supervisor in that
42 // it does not have a state machine and does not inherit properties
43 // from CorePropertySupervisorBase. The assumption is that only admins
44 // have access to wiz mode, and they have access to all features of it.
45 class WizardSupervisor : public xdaq::Application, public SOAPMessenger
46 {
47  public:
48  XDAQ_INSTANTIATOR();
49 
50  WizardSupervisor(xdaq::ApplicationStub*);
51  virtual ~WizardSupervisor(void);
52 
53  void init(void);
54  void destroy(void);
55 
56  void generateURL(void);
57  static void printURL(WizardSupervisor* ptr, std::string securityCode);
58 
59  void Default(xgi::Input* in, xgi::Output* out);
60  void verification(xgi::Input* in, xgi::Output* out);
61  void request(xgi::Input* in, xgi::Output* out);
62  void requestIcons(xgi::Input* in, xgi::Output* out);
63 
64  void editSecurity(xgi::Input* in, xgi::Output* out);
65  void UserSettings(xgi::Input* in, xgi::Output* out);
66  void tooltipRequest(xgi::Input* in, xgi::Output* out);
67  void toggleSecurityCodeGeneration(xgi::Input* in, xgi::Output* out);
68  std::string validateUploadFileType(const std::string fileType);
69  void cleanUpPreviews();
70  void savePostPreview(std::string& subject,
71  std::string& text,
72  const std::vector<cgicc::FormFile>& files,
73  std::string creator,
74  HttpXmlDocument* xmldoc = nullptr);
75 
76  // External Supervisor XOAP handlers
77  xoap::MessageReference supervisorSequenceCheck(xoap::MessageReference msg);
78  xoap::MessageReference supervisorLastTableGroupRequest(xoap::MessageReference msg);
79 
80  private:
81  std::string securityCode_;
82  bool defaultSequence_;
83  static const std::vector<std::string> allowedFileUploadTypes_, matchingFileUploadTypes_;
84  static const std::string WIZ_SUPERVISOR, WIZ_PORT, SERVICE_DATA_PATH;
85 
86  std::string supervisorClass_;
87  std::string supervisorClassNoNamespace_;
88  AllSupervisorInfo allSupervisorInfo_;
89 
90  enum
91  {
92  ADMIN_PERMISSIONS_THRESHOLD = 255,
93  EXPERIMENT_NAME_MIN_LENTH = 3,
94  EXPERIMENT_NAME_MAX_LENTH = 25,
95  USER_DATA_EXPIRATION_TIME = 60 * 20, // 20 minutes
96  };
97 };
98 // clang-format on
99 } // namespace ots
100 
101 #endif