00001 #ifndef _ots_LogbookSupervisor_h
00002 #define _ots_LogbookSupervisor_h
00003
00004 #include "otsdaq-core/CoreSupervisors/CoreSupervisorBase.h"
00005
00006 namespace ots
00007 {
00008
00009
00010
00011 class LogbookSupervisor: public CoreSupervisorBase
00012 {
00013
00014 public:
00015
00016 XDAQ_INSTANTIATOR();
00017 LogbookSupervisor (xdaq::ApplicationStub* s);
00018 virtual ~LogbookSupervisor (void);
00019
00020 void init (void);
00021 void destroy (void);
00022
00023 virtual void defaultPage (xgi::Input* in, xgi::Output* out) override;
00024 virtual void request (const std::string& requestType, cgicc::Cgicc& cgiIn, HttpXmlDocument& xmlOut, const WebUsers::RequestUserInfo& userInfo) override;
00025 virtual void nonXmlRequest (const std::string& requestType, cgicc::Cgicc& cgiIn, std::ostream& out, const WebUsers::RequestUserInfo& userInfo) override;
00026
00027 virtual void setSupervisorPropertyDefaults (void) override;
00028 virtual void forceSupervisorPropertyValues (void) override;
00029
00030
00031 xoap::MessageReference MakeSystemLogbookEntry (xoap::MessageReference msg);
00032
00033 private:
00034
00035 bool validateExperimentName (std::string &experiment);
00036 std::string getActiveExperiment (void);
00037 void setActiveExperiment (std::string experiment = "");
00038 void createExperiment (std::string experiment, std::string creator, HttpXmlDocument* xmldoc = 0);
00039 void removeExperiment (std::string experiment, std::string remover, HttpXmlDocument* xmldoc = 0);
00040 void getExperiments (HttpXmlDocument* xmldoc = 0, std::ostringstream *out = 0);
00041 void webUserSetActiveExperiment (std::string experiment, HttpXmlDocument* xmldoc = 0);
00042 void refreshLogbook (time_t date, unsigned char duration, HttpXmlDocument* xmldoc = 0, std::ostringstream *out = 0, std::string experiment = "");
00043 void cleanUpPreviews (void);
00044 void savePostPreview (std::string &subject, std::string &text, const std::vector<cgicc::FormFile> &files, std::string creator, HttpXmlDocument* xmldoc = 0);
00045 void escapeLogbookEntry (std::string &entry);
00046 std::string validateUploadFileType (const std::string fileType);
00047 void movePreviewEntry (std::string previewNumber, bool approve, HttpXmlDocument* xmldoc = 0);
00048 void hideLogbookEntry (const std::string &entryId, bool hide, const std::string &hider);
00049 static void MFReceiverWorkLoop (void);
00050
00051
00052 enum {
00053 ADMIN_PERMISSIONS_THRESHOLD = 255,
00054 EXPERIMENT_NAME_MIN_LENTH = 3,
00055 EXPERIMENT_NAME_MAX_LENTH = 25,
00056 LOGBOOK_PREVIEW_EXPIRATION_TIME = 60*20,
00057 };
00058 std::vector<std::string> allowedFileUploadTypes_, matchingFileUploadTypes_;
00059
00060 std::string activeExperiment_;
00061 unsigned int mostRecentDayIndex_;
00062 };
00063
00064 }
00065
00066 #endif