otsdaq  v2_05_02_indev
CodeEditorSupervisor.cc
1 #include "otsdaq/CodeEditor/CodeEditorSupervisor.h"
2 
3 using namespace ots;
4 
5 XDAQ_INSTANTIATOR_IMPL(CodeEditorSupervisor)
6 
7 //==============================================================================
8 CodeEditorSupervisor::CodeEditorSupervisor(xdaq::ApplicationStub* s) : CoreSupervisorBase(s) { __SUP_COUT__ << "Constructed." << __E__; } // end constructor
9 
10 //==============================================================================
11 CodeEditorSupervisor::~CodeEditorSupervisor(void)
12 {
13  __SUP_COUT__ << "Destroying..." << __E__;
14  // theStateMachineImplementation_ is reset and the object it points to deleted in
15  // ~CoreSupervisorBase()
16 } // end destructor
17 
18 //==============================================================================
19 void CodeEditorSupervisor::defaultPage(xgi::Input* /*in*/, xgi::Output* out)
20 {
21  __SUP_COUT__ << "ApplicationDescriptor LID=" << getApplicationDescriptor()->getLocalId() << __E__;
22  *out << "<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame "
23  "src='/WebPath/html/CodeEditor.html?urn="
24  << getApplicationDescriptor()->getLocalId() << "'></frameset></html>";
25 } // end defaultPage()
26 
27 //==============================================================================
28 // setSupervisorPropertyDefaults
29 // override to set defaults for supervisor property values (before user settings
30 // override)
31 void CodeEditorSupervisor::setSupervisorPropertyDefaults()
32 {
33  CorePropertySupervisorBase::setSupervisorProperty(CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
34  std::string() + "*=1 | codeEditor=-1");
35 
36 } // end setSupervisorPropertyDefaults()
37 
38 //==============================================================================
39 // forceSupervisorPropertyValues
40 // override to force supervisor property values (and ignore user settings)
41 void CodeEditorSupervisor::forceSupervisorPropertyValues()
42 {
43  CorePropertySupervisorBase::setSupervisorProperty(CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.RequireUserLockRequestTypes, "codeEditor");
44  CorePropertySupervisorBase::setSupervisorProperty(CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.RequireSecurityRequestTypes, "codeEditor");
45 
46 } // end forceSupervisorPropertyValues()
47 
48 //==============================================================================
49 // Request
50 // Handles Web Interface requests to Console supervisor.
51 // Does not refresh cookie for automatic update checks.
52 void CodeEditorSupervisor::request(const std::string& requestType, cgicc::Cgicc& cgiIn, HttpXmlDocument& xmlOut, const WebUsers::RequestUserInfo& userInfo)
53 {
54  // Commands:
55  // codeEditor
56 
57  if(requestType == "codeEditor")
58  {
59  __SUP_COUT__ << "Code Editor" << __E__;
60 
61  codeEditor_.xmlRequest(CgiDataUtilities::getData(cgiIn, "option"),
62  false, // Indicates Edit mode
63  cgiIn,
64  &xmlOut,
65  userInfo.username_);
66  }
67  else if(requestType == "readOnlycodeEditor")
68  {
69  codeEditor_.xmlRequest(CgiDataUtilities::getData(cgiIn, "option"),
70  true, // Indicates read only mode
71  cgiIn,
72  &xmlOut,
73  userInfo.username_);
74  }
75  else
76  {
77  __SUP_SS__ << "requestType Request, " << requestType << ", not recognized." << __E__;
78  __SUP_SS_THROW__;
79  }
80 } // end request()