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