Back to index

nordugrid-arc-nox  1.1.0~rc6
configurator.h
Go to the documentation of this file.
00001 #ifndef __ARC_PAUL_CONFIGURATOR_H__
00002 #define __ARC_PAUL_CONFIGURATOR_H__
00003 
00004 #include <string>
00005 #include <map>
00006 
00007 #include <arc/ArcConfig.h>
00008 #include <arc/Logger.h>
00009 #include <arc/message/MCC_Status.h>
00010 #include <arc/message/Message.h>
00011 #include "job_queue.h"
00012 
00013 namespace Paul
00014 {
00015 
00016 class InvalidMessageException: public std::exception
00017 {
00018     virtual const char* what() const throw()
00019     {
00020         return "InvalidMessage ";
00021     }
00022 };
00023 
00024 class HTMLRequest
00025 {
00026     public:
00027         std::map<std::string, std::string> POST;
00028         std::string path;
00029         std::string base_path;
00030         std::string method;
00031         HTMLRequest(Arc::Message &in);
00032         HTMLRequest() {};
00033         ~HTMLRequest() {};
00034 };
00035 
00036 class HTMLResponse
00037 {
00038     public:
00039         std::string html;
00040         std::string content_type;
00041         std::string header;
00042         std::string footer;
00043         HTMLResponse() { html=""; header=""; footer=""; content_type = "text/html"; };
00044         ~HTMLResponse() {};
00045         HTMLResponse &operator+=(const std::string &html_) {
00046             html += (html_ + "\n");
00047             return *this;
00048         };
00049 };
00050 
00051 
00052 class Configurator
00053 {
00054     private:
00055         Arc::Config cfg_;
00056         Arc::Logger logger_;
00057         JobQueue *jobq_;
00058     public:
00059         Configurator():logger_(Arc::Logger::rootLogger, "Paul::Configurator") {};
00060         Configurator(Arc::Config *cfg);
00061         ~Configurator() {};
00062         void set(Arc::Config *cfg) { cfg_ = *cfg; };
00063         Arc::MCC_Status process(Arc::Message &in, Arc::Message &out);
00064         int getPeriod(void);
00065         Arc::XMLNode getApplicationEnvironments(void);
00066         std::map<std::string, std::string> getPki(void);
00067         std::vector<std::string> getSchedulers(void);
00068         std::string getCachePath(void);
00069         std::string getJobRoot(void);
00070         std::string getEndpoint(void);
00071         void setJobQueue(JobQueue *jq) { jobq_ = jq; };
00072         JobQueue *getJobQueue(void) { return jobq_; };
00073         // view functions
00074         static void index(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00075         static void style(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00076         static void conf(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00077         static void sched(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00078         static void sched_add(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00079         static void sched_del(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00080         static void rte(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00081         static void rte_add(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00082         static void rte_del(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00083         static void log(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00084         static void jobs(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00085         static void job(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00086         static void job_stop(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00087         static void icon(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00088 }; // Configurator
00089 
00090 typedef void (*view_func)(Configurator *self, HTMLRequest &request, HTMLResponse &response);
00091 typedef std::map<std::string, view_func> Controller;
00092 
00093 } // namespace Paul
00094 #endif // __PAUL_SERVICE_CONFIGURATOR_H__