提交 0e4c22efcefedb61b9c0984348b432b79d1d3034

作者 qingxiongf
2 个父辈 19a301f6 59b65cb8
... ... @@ -170,6 +170,10 @@ target_link_libraries(dmap_serv
170 170 )
171 171 ########################################################
172 172 # Install
  173 +INSTALL(FILES
  174 + dmpserver.ini
  175 + DESTINATION ${DMAP_LIBEXEC_SUBDIR}
  176 +)
173 177
174 178 INSTALL(TARGETS dmap_server
175 179 RUNTIME DESTINATION ${DMAP_BIN_DIR}
... ...
... ... @@ -23,7 +23,7 @@ bool DmpServer::accept(const std::string &url)
23 23 }
24 24
25 25 //子类实现
26   -bool DmpServer::publish(const std::string &name, unsigned int capability, const DmpProject &project)
  26 +bool DmpServer::publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project)
27 27 {
28 28 return false;
29 29 }
... ...
... ... @@ -28,7 +28,7 @@ public:
28 28 virtual bool accept(const std::string &url);
29 29 virtual void executeRequest(DmpServerRequest &request, DmpServerResponse &response) = 0;
30 30
31   - virtual bool publish(const std::string &serviceName, unsigned int capability, const DmpProject &project);
  31 + virtual bool publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project);
32 32 virtual bool remove(const std::string &serviceName);
33 33 virtual bool start(const std::string &serviceName);
34 34 virtual bool stop(const std::string &serviceName);
... ...
  1 +[MetaData]
  2 +pgsqlConnect="hostaddr=localhost port=5432 dbname='dmap_dms' user='postgres' password='chinadci'"
  3 +metaUrl=http://ip:port
  4 +email=zhongpingw@chinadci.com
\ No newline at end of file
... ...
... ... @@ -8,10 +8,10 @@
8 8 ***************************************************************************/
9 9 #include "dmpservercontext.h"
10 10
11   -DmpServerContext::DmpServerContext(const DmpServerRequest *request, DmpServerResponse *response, const DmpProject *project):
  11 +DmpServerContext::DmpServerContext(const DmpServerRequest *request, DmpServerResponse *response, const DmpServerProject *serverProject):
12 12 request_(request),
13 13 response_(response),
14   - project_(project)
  14 + serverProject_(serverProject)
15 15 {
16 16
17 17 }
\ No newline at end of file
... ...
... ... @@ -15,18 +15,18 @@
15 15
16 16 class DmpServerResponse;
17 17 class DmpServerRequest;
18   -class DmpProject;
  18 +class DmpServerProject;
19 19 class SERVER_EXPORT DmpServerContext
20 20 {
21 21 public:
22   - DmpServerContext(const DmpServerRequest *request, DmpServerResponse *response, const DmpProject *project);
  22 + DmpServerContext(const DmpServerRequest *request, DmpServerResponse *response, const DmpServerProject *serverProject);
23 23 const DmpServerRequest *request() const { return request_;}
24 24 DmpServerResponse *response() const { return response_;}
25   - const DmpProject *project() const { return project_;}
  25 + const DmpServerProject *serverProject() const { return serverProject_;}
26 26
27 27 private:
28 28 const DmpServerRequest *request_ = nullptr;
29 29 DmpServerResponse *response_ = nullptr;
30   - const DmpProject *project_ = nullptr;
  30 + const DmpServerProject *serverProject_ = nullptr;
31 31 };
32 32 #endif // __dmpservercontext_h__
... ...
... ... @@ -9,6 +9,7 @@
9 9 #include "dmpservermanager.h"
10 10 #include "dmpserver.h"
11 11 #include "dmphttputils.h"
  12 +#include "dmpserverConfig.h"
12 13 #include <memory>
13 14 #include <boost/property_tree/ptree.hpp>
14 15 #include <boost/property_tree/json_parser.hpp>
... ... @@ -99,7 +100,7 @@ bool DmpServerManager::removeProject(const std::string &serviceName)
99 100 return true;
100 101 }
101 102
102   -bool DmpServerManager::publish(const std::string &serverName, const std::string &serviceName, int capabilities, const std::string &projectData)
  103 +bool DmpServerManager::publish(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData)
103 104 {
104 105 //project
105 106 std::string projData;
... ... @@ -114,7 +115,7 @@ bool DmpServerManager::publish(const std::string &serverName, const std::string
114 115 return false;
115 116 }
116 117
117   - if (!serverRegistry_->getServer(serverName)->publish(serviceName, capabilities, *project))
  118 + if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project))
118 119 {
119 120 delete project;
120 121 return false;
... ... @@ -122,6 +123,7 @@ bool DmpServerManager::publish(const std::string &serverName, const std::string
122 123 projects_[serviceName] = project;
123 124 return true;
124 125 }
  126 +
125 127 bool DmpServerManager::deleteService(const std::string &serverName, const std::string &serviceName)
126 128 {
127 129 if (serverRegistry_->getServer(serverName)->remove(serviceName) && removeProject(serviceName))
... ... @@ -146,8 +148,8 @@ bool DmpServerManager::stopService(const std::string &serverName, const std::str
146 148 bool DmpServerManager::LoadServices()
147 149 {
148 150 boost::property_tree::ptree pt,ptList;
149   -
150   - const std::string url="http://172.26.60.100:8841/API/Service/TileService/Reload";
  151 + std::string conn = DmpServerConfig::Instance()->getMetaUrl();
  152 + const std::string url= conn + URI_RELOAD;
151 153 std::string strContent=DmpHttp::get(url);
152 154 if(strContent.length()==0)
153 155 {
... ... @@ -176,7 +178,7 @@ bool DmpServerManager::LoadServices()
176 178 std::string type = e.second.get<std::string>("type");
177 179 int capabilities =e.second.get<int>("capabilities");
178 180 std::string project = e.second.get<std::string>("project");
179   - this->publish(type,name,capabilities,project);
  181 + this->publish(type,name,title,capabilities,project);
180 182 }
181 183 }
182 184 return true;
... ...
... ... @@ -19,7 +19,7 @@
19 19 #include "dmpserverrequest.h"
20 20 #include "dmpserverregistry.h"
21 21
22   -
  22 +#define URI_RELOAD ("/API/Service/TileService/Reload") //加载已注册服务接口
23 23 class SERVER_EXPORT DmpServerManager
24 24 {
25 25 public:
... ... @@ -30,7 +30,7 @@ public:
30 30 std::shared_ptr<DmpServer> serverForRequest(const DmpServerRequest& request);
31 31 std::shared_ptr<DmpServerApi> apiForRequest(const DmpServerRequest& request);
32 32
33   - bool publish(const std::string& serverName, const std::string& serviceName, int capabilities, const std::string& projectData);
  33 + bool publish(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData);
34 34 bool deleteService(const std::string& serverName, const std::string& serviceName);
35 35 bool startService(const std::string& serverName, const std::string& serviceName);
36 36 bool stopService(const std::string& serverName, const std::string& serviceName);
... ...
... ... @@ -9,10 +9,9 @@
9 9 #include "dmpserverproject.h"
10 10
11 11
12   -DmpServerProject::DmpServerProject(const std::string &name, const std::string &title, const std::string &description,const DmpProject *project):
  12 +DmpServerProject::DmpServerProject(const std::string &name, const std::string &title, const DmpProject *project):
13 13 name_(name),
14 14 title_(title),
15   - description_(description),
16 15 project_(project)
17 16 {
18 17 status_ = 1;
... ...
... ... @@ -18,18 +18,16 @@
18 18 class SERVER_EXPORT DmpServerProject
19 19 {
20 20 public:
21   - DmpServerProject(const std::string &name,
22   - const std::string &title,
23   - const std::string &description,
24   - const DmpProject *project);
  21 + DmpServerProject(const std::string &name, const std::string &title, const DmpProject *project);
25 22 std::string createTime() { return time_;}
26   - const DmpProject* project() { return project_;}
  23 + const DmpProject* project() const { return project_;}
  24 + std::string name() const { return name_;}
  25 + std::string title() const { return title_;}
27 26 int status() { return status_;}
28 27 void setStatus(int status) { status_ = status;}
29 28 private:
30 29 std::string name_;
31 30 std::string title_;
32   - std::string description_;
33 31 std::string time_;
34 32 int status_;
35 33 int flag_;
... ...
... ... @@ -50,8 +50,6 @@ public:
50 50 void setHeader(const std::string &name, const std::string &value);
51 51 Headers headers() const { return headers_; }
52 52 bool isRestful() const { return isRestful_; }
53   - std::string serviceName() const { return serviceName_;}
54   - void setServiceName(const std::string &serviceName) { serviceName_ = serviceName;}
55 53
56 54 DmpServerParameters serverParameters() const { return params_; }
57 55 void setParameter(const std::string &name, const std::string &value);
... ... @@ -70,7 +68,6 @@ protected:
70 68 std::string port_;
71 69 std::string path_;
72 70 std::string query_;
73   - std::string serviceName_;
74 71 bool isRestful_;
75 72
76 73 private:
... ...
... ... @@ -15,6 +15,7 @@
15 15 #include <map>
16 16 #include "dmpservercontext.h"
17 17 #include "dmpserverrequest.h"
  18 +#include "dmpserverproject.h"
18 19
19 20 typedef enum
20 21 {
... ...
... ... @@ -198,7 +198,7 @@ BOOST_PYTHON_MODULE(dmap_server)
198 198 .def("allow_method", pure_virtual(&DmpService::allowMethod))
199 199 .def("execute_request", pure_virtual(&DmpService::executeRequest));
200 200
201   - class_<DmpServerContext>("DmpServerContext",init<DmpServerRequest*, DmpServerResponse*, DmpProject*>());
  201 + // class_<DmpServerContext>("DmpServerContext",init<DmpServerRequest*, DmpServerResponse*, DmpProject*>());
202 202
203 203 class_<DmpServerRequest>("DmpServerRequest",init<std::string&>());
204 204
... ...
... ... @@ -125,7 +125,7 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const
125 125 context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}");
126 126 return;
127 127 }
128   - if(context.manager()->publish(serverType, name, capabilities, project)) {
  128 + if(context.manager()->publish(serverType, name, title, capabilities, project)) {
129 129 LOGGER_INFO("服务发布成功");
130 130 context.response()->write("{\"status\":\"true\",\"message\":\"Pulish service successful!\"}");
131 131 // std::string projData;
... ...
... ... @@ -70,7 +70,7 @@ void DmpMapServer::executeRequest(DmpServerRequest &request, DmpServerResponse &
70 70 response.writeHtml(htmlstr + "服务\"" + serviceName + "\"已经停止。</p></body></html>\n");
71 71 return;
72 72 }
73   - DmpServerContext context {&request, &response, serverProj->project()};
  73 + DmpServerContext context {&request, &response, serverProj};
74 74 service->executeRequest(context);
75 75 }
76 76 else {
... ... @@ -91,7 +91,7 @@ void DmpMapServer::executeRequest(DmpServerRequest &request, DmpServerResponse &
91 91 }
92 92 }
93 93
94   -bool DmpMapServer::publish(const std::string &name, unsigned int capability, const DmpProject &project)
  94 +bool DmpMapServer::publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project)
95 95 {
96 96 if(capability & DmpServiceType::WMTS) {
97 97 DmpService* wmtsservice = getService("WMTSService");
... ... @@ -105,8 +105,8 @@ bool DmpMapServer::publish(const std::string &name, unsigned int capability, con
105 105 return false;
106 106 }
107 107 }
108   - DmpServerProject* serverProject = new DmpServerProject(name,"","", &project);
109   - serverProjects_[name] = serverProject;
  108 + DmpServerProject* serverProject = new DmpServerProject(serviceName, title, &project);
  109 + serverProjects_[serviceName] = serverProject;
110 110
111 111 return true;
112 112 }
... ...
... ... @@ -37,7 +37,7 @@ public:
37 37 std::string path() const override { return std::string("^/DMap/Services/?([\\w./]*)/MapServer/([\\w]+)"); }
38 38 std::string capability() const override;
39 39 void executeRequest(DmpServerRequest &request, DmpServerResponse &response) override;
40   - bool publish(const std::string &serviceName, unsigned int capability, const DmpProject &project) override;
  40 + bool publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project) override;
41 41 bool remove(const std::string &serviceName) override;
42 42 bool start(const std::string &serviceName) override;
43 43 bool stop(const std::string &serviceName) override;
... ...
... ... @@ -36,7 +36,7 @@ namespace DmpWms
36 36 void DmpWMSService::executeRequest(const DmpServerContext &context)
37 37 {
38 38 const DmpWmsParameters params(context.request()->serverParameters());
39   - const DmpProject* project = context.project();
  39 + const DmpProject* project = context.serverProject()->project();
40 40 const std::string request = params.Request();
41 41 if (request.empty())
42 42 {
... ... @@ -44,7 +44,7 @@ namespace DmpWms
44 44 }
45 45 else if(boost::iequals(request, "getcapabilities"))
46 46 {
47   - writeGetCapabilities(context,params, project);
  47 + writeGetCapabilities(context,params, project);
48 48 }
49 49 else if(boost::iequals(request, "getmap"))
50 50 {
... ...
... ... @@ -65,7 +65,6 @@ void DmpTileServer::executeRequest(DmpServerRequest &request, DmpServerResponse
65 65 if(what.size() == 4) {
66 66 std::string serviceName = what[1].str();
67 67 std::string serverType = what[2].str();
68   - request.setServiceName(serviceName);
69 68 if(request.isRestful()) {
70 69 std::string queryString = what[3].str();
71 70 request.setQuery(queryString);
... ... @@ -79,7 +78,7 @@ void DmpTileServer::executeRequest(DmpServerRequest &request, DmpServerResponse
79 78 response.writeHtml(htmlstr + "服务\"" + serviceName + "\"已经停止。</p></body></html>\n");
80 79 return;
81 80 }
82   - DmpServerContext context {&request, &response, serverProj->project()};
  81 + DmpServerContext context {&request, &response, serverProj};
83 82 service->executeRequest(context);
84 83 }
85 84 else {
... ... @@ -99,7 +98,7 @@ void DmpTileServer::executeRequest(DmpServerRequest &request, DmpServerResponse
99 98 }
100 99 }
101 100
102   -bool DmpTileServer::publish(const std::string &name, unsigned int capability, const DmpProject &project)
  101 +bool DmpTileServer::publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project)
103 102 {
104 103 if(capability & DmpServiceType::WMTS) {
105 104 DmpService* wmtsservice = getService("WMTSService");
... ... @@ -113,8 +112,8 @@ bool DmpTileServer::publish(const std::string &name, unsigned int capability, co
113 112 return false;
114 113 }
115 114 }
116   - DmpServerProject* serverProject = new DmpServerProject(name,"","", &project);
117   - serverProjects_[name] = serverProject;
  115 + DmpServerProject* serverProject = new DmpServerProject(serviceName, title, &project);
  116 + serverProjects_[serviceName] = serverProject;
118 117
119 118 return true;
120 119 }
... ...
... ... @@ -37,7 +37,7 @@ public:
37 37 std::string path() const override { return std::string("^/DMap/Services/?([\\w./]*)/TileServer/([\\w.]+)([\\w./]*)"); }
38 38 std::string capability() const override;
39 39 void executeRequest(DmpServerRequest &request, DmpServerResponse &response) override;
40   - bool publish(const std::string &serviceName, unsigned int capability, const DmpProject &project) override;
  40 + bool publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project) override;
41 41 bool remove(const std::string &serviceName) override;
42 42 bool start(const std::string &serviceName) override;
43 43 bool stop(const std::string &serviceName) override;
... ...
... ... @@ -55,7 +55,7 @@ namespace DmpTms
55 55 int tileCol=atoi(vec0[0].c_str());
56 56 int tileRow=atoi(vec[isize-2].c_str());
57 57 int tileMatrix=atoi(vec[isize-3].c_str());
58   - const DmpProject *project = context.project();
  58 + const DmpProject *project = context.serverProject()->project();
59 59 DmpTileLayer *tileLayer = static_cast<DmpTileLayer *>(project->getLayer());
60 60 std::string format=vec0[1].c_str();
61 61 std::string filePath=tileLayer->getDataSource();
... ...
... ... @@ -65,10 +65,9 @@ namespace DmpWmts
65 65 params = nullptr;
66 66 }
67 67
68   - const DmpProject *project = context.project();
  68 + const DmpServerProject *serverProject = context.serverProject();
  69 + const DmpProject *project = serverProject->project();
69 70 DmpTileLayer *tileLayer = static_cast<DmpTileLayer *>(project->getLayer(layerName));
70   - //context.response()->writeHtml("hello,wmts");
71   - //const DmpWmtsParameters params(context.request()->serverParameters());
72 71
73 72 if (req.empty())
74 73 {
... ... @@ -83,7 +82,7 @@ namespace DmpWmts
83 82 else if (boost::iequals(req, "GetCapabilities"))
84 83 {
85 84 const std::string host=context.request()->domain()+":"+context.request()->port();;
86   - const std::string servicename=context.request()->serviceName();
  85 + const std::string servicename=serverProject->name();
87 86
88 87 boost::property_tree::ptree pt;
89 88 pt.add("Layer.ows:Title",tileLayer->title());
... ...
注册登录 后发表评论