otsdaq_utilities  v2_05_02_indev
LogbookSupervisor.h
1 #ifndef _ots_LogbookSupervisor_h
2 #define _ots_LogbookSupervisor_h
3 
4 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
5 
6 namespace ots
7 {
8 // LogbookSupervisor
9 // This class handles the write and read requests for web users interfacing to the web
10 // desktop Logbook
11 class LogbookSupervisor : public CoreSupervisorBase
12 {
13  public:
14  XDAQ_INSTANTIATOR();
15  LogbookSupervisor(xdaq::ApplicationStub* s);
16  virtual ~LogbookSupervisor(void);
17 
18  void init(void);
19  void destroy(void);
20 
21  virtual void defaultPage(xgi::Input* in, xgi::Output* out) override;
22  virtual void request(const std::string& requestType,
23  cgicc::Cgicc& cgiIn,
24  HttpXmlDocument& xmlOut,
25  const WebUsers::RequestUserInfo& userInfo) override;
26  virtual void nonXmlRequest(const std::string& requestType,
27  cgicc::Cgicc& cgiIn,
28  std::ostream& out,
29  const WebUsers::RequestUserInfo& userInfo) override;
30 
31  virtual void setSupervisorPropertyDefaults(
32  void) override; // override to control supervisor specific defaults
33  virtual void forceSupervisorPropertyValues(void) override; // override to force
34  // supervisor property
35  // values (and ignore user
36  // settings)
37 
38  // External Supervisor XOAP handlers
39  xoap::MessageReference MakeSystemLogbookEntry(xoap::MessageReference msg);
40 
41  private:
42  bool validateExperimentName(std::string& experiment);
43  std::string getActiveExperiment(void);
44  void setActiveExperiment(std::string experiment = "");
45  void createExperiment(std::string experiment,
46  std::string creator,
47  HttpXmlDocument* xmldoc = 0);
48  void removeExperiment(std::string experiment,
49  std::string remover,
50  HttpXmlDocument* xmldoc = 0);
51  void getExperiments(HttpXmlDocument* xmldoc = 0, std::ostringstream* out = 0);
52  void webUserSetActiveExperiment(std::string experiment, HttpXmlDocument* xmldoc = 0);
53  void refreshLogbook(time_t date,
54  unsigned char duration,
55  HttpXmlDocument* xmldoc = 0,
56  std::ostringstream* out = 0,
57  std::string experiment = "");
58  void cleanUpPreviews(void);
59  void savePostPreview(std::string& subject,
60  std::string& text,
61  const std::vector<cgicc::FormFile>& files,
62  std::string creator,
63  HttpXmlDocument* xmldoc = 0);
64  void escapeLogbookEntry(std::string& entry);
65  std::string validateUploadFileType(const std::string fileType);
66  void movePreviewEntry(std::string previewNumber,
67  bool approve,
68  HttpXmlDocument* xmldoc = 0);
69  void hideLogbookEntry(const std::string& entryId,
70  bool hide,
71  const std::string& hider);
72  static void MFReceiverWorkLoop(void);
73 
74  enum
75  {
76  ADMIN_PERMISSIONS_THRESHOLD = 255,
77  EXPERIMENT_NAME_MIN_LENTH = 3,
78  EXPERIMENT_NAME_MAX_LENTH = 25,
79  LOGBOOK_PREVIEW_EXPIRATION_TIME = 60 * 20, // 20 minutes
80  };
81  std::vector<std::string> allowedFileUploadTypes_, matchingFileUploadTypes_;
82 
83  std::string activeExperiment_;
84  unsigned int mostRecentDayIndex_;
85 };
86 }
87 
88 #endif