提交 50442ed10e16cf8011b097b38e82811e23dbceb7

作者 LJH 李佳桓
1 个父辈 48447f79

ljh

正在显示 1 个修改的文件 包含 0 行增加205 行删除
... ... @@ -126,211 +126,6 @@ bool DmpServerManager::publish(const std::string& serverName, const std::string&
126 126 delete project;
127 127 return false;
128 128 }
129   - projects_[serviceName] = project;
130   - return true;
131   -}
132   -
133   -bool DmpServerManager::deleteService(const std::string &serverName, const std::string &serviceName)
134   -{
135   - if (serverRegistry_->getServer(serverName)->remove(serviceName) && removeProject(serviceName))
136   - {
137   - return true;
138   - }
139   - else
140   - {
141   - return false;
142   - }
143   -}
144   -
145   -bool DmpServerManager::startService(const std::string &serverName, const std::string &serviceName)
146   -{
147   - return serverRegistry_->getServer(serverName)->start(serviceName);
148   -}
149   -
150   -bool DmpServerManager::stopService(const std::string &serverName, const std::string &serviceName)
151   -{
152   - return serverRegistry_->getServer(serverName)->stop(serviceName);
153   -}
154   -bool DmpServerManager::loadServices()
155   -{
156   - boost::property_tree::ptree pt,ptList;
157   - std::string conn = DmpServerConfig::Instance()->getMetaUrl();
158   - const std::string url= conn + URI_RELOAD;
159   - std::string strContent=DmpHttp::get(url);
160   - if(strContent.length()==0)
161   - {
162   - return false;
163   - }
164   - std::stringstream ssData;
165   - ssData<<strContent.c_str();
166   - boost::property_tree::read_json(ssData, pt);
167   - int iCount = std::atoi(pt.get<std::string>("data.count").c_str());
168   - if(iCount>0)
169   - {
170   - ptList=pt.get_child("data.list");
171   - for (auto& e : ptList)
172   - {
173   - std::string name = e.second.get<std::string>("name");
174   - std::string title = e.second.get<std::string>("title");
175   - std::string type = e.second.get<std::string>("type");
176   - int capabilities =e.second.get<int>("capabilities");
177   - std::string project = e.second.get<std::string>("project");
178   - this->initServices(type,name,title,capabilities,project);
179   - }
180   - }
181   - return true;
182   -}
183   -bool DmpServerManager::initServices(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData)
184   -{
185   - //project
186   - std::string projData;
187   - if (!DmpServerUtils::Base64Decode(projectData, &projData))
188   - {
189   - return false;
190   - }
191   - DmpProject *project = new DmpProject();
192   - if (!project->Read(projData))
193   - {
194   - delete project;
195   - return false;
196   - }
197   -
198   - if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project))
199   - {
200   - delete project;
201   - return false;
202   - }
203   - projects_[serviceName] = project;
204   - return true;
205   -=======
206   -/**************************************************************************
207   -* file: dmpservermanager.cpp
208   -
209   -* Author: wanzhongping
210   -* Date: 2021-07-27 21:59:46
211   -* Email: zhongpingw@chinadci.com
212   -* copyright: 广州城市信息研究所有限公司
213   -***************************************************************************/
214   -#include "dmpservermanager.h"
215   -#include "dmpserver.h"
216   -#include "dmphttputils.h"
217   -#include "dmpserverConfig.h"
218   -#include <memory>
219   -#include <boost/property_tree/ptree.hpp>
220   -#include <boost/property_tree/json_parser.hpp>
221   -#include <boost/property_tree/xml_parser.hpp>
222   -#include <sstream>
223   -#include <fstream>
224   -#include <math.h>
225   -#include "dmptilelayer.h"
226   -#include <iostream>
227   -#include "dmplogger.h"
228   -#include "dmptilelayer.h"
229   -
230   -DmpServerManager::DmpServerManager()
231   -{
232   - serverRegistry_ = new DmpServerRegistry();
233   -}
234   -
235   -DmpServerManager::~DmpServerManager()
236   -{
237   - if (serverRegistry_)
238   - {
239   - delete serverRegistry_;
240   - serverRegistry_ = NULL;
241   - }
242   -
243   - ProjectMap::iterator iter = projects_.begin();
244   - for (; iter != projects_.end(); ++iter)
245   - {
246   - DmpProject *mapProject = iter->second;
247   - if (mapProject)
248   - {
249   - delete mapProject;
250   - mapProject = nullptr;
251   - }
252   - }
253   - projects_.clear();
254   -}
255   -
256   -void DmpServerManager::init(const boost::filesystem::path &modulePath)
257   -{
258   - serverRegistry_->init(modulePath);
259   - if(!loadServices())
260   - {
261   - std::cout << "加载服务失败!" << std::endl;
262   - LOGGER_ERROR("加载服务失败!");
263   - }
264   - //LoadDmpServices();
265   -}
266   -
267   -std::string DmpServerManager::getCapabilities()
268   -{
269   - return serverRegistry_->getCapabilities();
270   -}
271   -
272   -std::shared_ptr<DmpServer> DmpServerManager::serverForRequest(const DmpServerRequest &request)
273   -{
274   - return serverRegistry_->getServerForRequest(request);
275   -}
276   -
277   -std::shared_ptr<DmpServerApi> DmpServerManager::apiForRequest(const DmpServerRequest &request)
278   -{
279   - return serverRegistry_->getApiForRequest(request);
280   -}
281   -
282   -DmpProject *DmpServerManager::getProject(const std::string &serviceName)
283   -{
284   - std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName);
285   - if (iter != projects_.end())
286   - {
287   - return iter->second;
288   - }
289   - else
290   - {
291   - return nullptr;
292   - }
293   -}
294   -
295   -bool DmpServerManager::removeProject(const std::string &serviceName)
296   -{
297   - try
298   - {
299   - std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName);
300   - if (iter != projects_.end())
301   - {
302   - delete iter->second;
303   - projects_.erase(iter);
304   - }
305   - }
306   - catch (const std::exception &e)
307   - {
308   - std::cerr << e.what() << '\n';
309   - return false;
310   - }
311   - return true;
312   -}
313   -
314   -bool DmpServerManager::publish(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData)
315   -{
316   - //project
317   - std::string projData;
318   - if (!DmpServerUtils::Base64Decode(projectData, &projData))
319   - {
320   - return false;
321   - }
322   - DmpProject *project = new DmpProject();
323   - if (!project->Read(projData))
324   - {
325   - delete project;
326   - return false;
327   - }
328   -
329   - if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project))
330   - {
331   - delete project;
332   - return false;
333   - }
334 129 projects_[serviceName] = project;
335 130
336 131 return true;
... ...
注册登录 后发表评论