正在显示
2 个修改的文件
包含
31 行增加
和
615 行删除
| 1 | -/************************************************************************** | |
| 2 | -* file: dmpmanagerapihandler.cpp | |
| 3 | - | |
| 4 | -* Author: wanzhongping | |
| 5 | -* Date: 2021-07-15 14:46:40 | |
| 6 | -* Email: zhongpingw@chinadci.com | |
| 7 | -* copyright: 广州城市信息研究所有限公司 | |
| 8 | -***************************************************************************/ | |
| 9 | -#include <iostream> | |
| 10 | -#include <boost/json.hpp> | |
| 11 | -#include <boost/property_tree/ptree.hpp> | |
| 12 | -#include <boost/property_tree/json_parser.hpp> | |
| 13 | -#include <boost/property_tree/xml_parser.hpp> | |
| 14 | -#include <boost/foreach.hpp> | |
| 15 | -#include <boost/lexical_cast.hpp> | |
| 16 | -#include <boost/algorithm/string.hpp> | |
| 17 | -#include <boost/date_time.hpp> | |
| 18 | - | |
| 19 | -#include "dmpmanagerapihandler.h" | |
| 20 | -#include "dmpserverrequest.h" | |
| 21 | -#include "dmpserverresponse.h" | |
| 22 | -#include "dmpapiparameters.h" | |
| 23 | -#include "dmplogger.h" | |
| 24 | -#include "dmpapiutils.h" | |
| 25 | -#include "dmpservermanager.h" | |
| 26 | -#include "dmpserverutils.h" | |
| 27 | - | |
| 28 | -DmpManagerApiHandler::DmpManagerApiHandler() | |
| 29 | -{ | |
| 30 | - | |
| 31 | -} | |
| 32 | - | |
| 33 | -void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) const | |
| 34 | -{ | |
| 35 | - if (OperationId().compare("regservice") == 0) { | |
| 36 | - regService(context); | |
| 37 | - } | |
| 38 | - else if (OperationId().compare("startservice") == 0) { | |
| 39 | - startService(context); | |
| 40 | - } | |
| 41 | - else if (OperationId().compare("stopservice") == 0) { | |
| 42 | - stopService(context); | |
| 43 | - } | |
| 44 | - else if(OperationId().compare("regtileservice") == 0) { | |
| 45 | - RegTileService(context); | |
| 46 | - } | |
| 47 | - else if(OperationId().compare("getservicelist") == 0) { | |
| 48 | - GetServiceList(context); | |
| 49 | - } | |
| 50 | - else if(OperationId().compare("getservicedetail") == 0) { | |
| 51 | - GetServiceDetail(context); | |
| 52 | - } | |
| 53 | - else if(OperationId().compare("getcapabilities") == 0) { | |
| 54 | - getCapabilities(context); | |
| 55 | - } | |
| 56 | - else if(OperationId().compare("updateservice") == 0) { | |
| 57 | - UpdateService(context); | |
| 58 | - } | |
| 59 | - else if(OperationId().compare("deleteservice") == 0) { | |
| 60 | - deleteService(context); | |
| 61 | - } | |
| 62 | - else if(OperationId().compare("gettileserviceinfo") == 0) { | |
| 63 | - GetTileServiceInfo(context); | |
| 64 | - } | |
| 65 | - else if(OperationId().compare("addcatalog") == 0) { | |
| 66 | - AddCatalog(context); | |
| 67 | - } | |
| 68 | - else if(OperationId().compare("deletecatalog") == 0) { | |
| 69 | - DeleteCatalog(context); | |
| 70 | - } | |
| 71 | - else if(OperationId().compare("getservicesmatrixsets") == 0) { | |
| 72 | - GetServicesMatrixSets(context); | |
| 73 | - } | |
| 74 | - else if(OperationId().compare("deletecache") == 0) { | |
| 75 | - DeleteCache(context); | |
| 76 | - } | |
| 77 | - else if(OperationId().compare("updatecache") == 0) { | |
| 78 | - UpdateCache(context); | |
| 79 | - } | |
| 80 | - else if(OperationId().compare("reloadservices") == 0) { | |
| 81 | - reloadServices(context); | |
| 82 | - } | |
| 83 | - else { | |
| 84 | - context.response()->write("not find oparation: " + OperationId()); | |
| 85 | - } | |
| 86 | -} | |
| 87 | -void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | |
| 88 | -{ | |
| 89 | - switch (context.request()->method()) | |
| 90 | - { | |
| 91 | - case DmpServerRequest::Method::GET_METHOD: | |
| 92 | - { | |
| 93 | - context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}"); | |
| 94 | - break; | |
| 95 | - } | |
| 96 | - case DmpServerRequest::Method::POST_METHOD: | |
| 97 | - { | |
| 98 | - std::string name; | |
| 99 | - std::string title; | |
| 100 | - int capabilities; | |
| 101 | - std::string serverType; | |
| 102 | - std::string project; | |
| 103 | - const char* data = (char*)(context.request()->GetData()); | |
| 104 | - if(data && *data != '\0') | |
| 105 | - { | |
| 106 | - try | |
| 107 | - { | |
| 108 | - std::stringstream stream(data); | |
| 109 | - boost::property_tree::ptree pt; | |
| 110 | - boost::property_tree::read_json(stream, pt); | |
| 111 | - | |
| 112 | - name = pt.get<std::string>("name"); | |
| 113 | - title = pt.get<std::string>("title"); | |
| 114 | - capabilities = pt.get<int>("capabilities"); | |
| 115 | - serverType = pt.get<std::string>("type"); | |
| 116 | - project = pt.get<std::string>("project"); | |
| 117 | - } | |
| 118 | - catch (boost::property_tree::ptree_bad_path& e) { | |
| 119 | - LOGGER_ERROR(e.what()); | |
| 120 | - context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); | |
| 121 | - return; | |
| 122 | - } | |
| 123 | - catch (boost::property_tree::ptree_bad_data& e) { | |
| 124 | - LOGGER_ERROR(e.what()); | |
| 125 | - context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); | |
| 126 | - return; | |
| 127 | - } | |
| 128 | - if(context.manager()->publish(serverType, name, title, capabilities, project)) { | |
| 129 | - LOGGER_INFO("服务发布成功"); | |
| 130 | - context.response()->write("{\"status\":\"true\",\"message\":\"Pulish service successful!\"}"); | |
| 131 | - // std::string projData; | |
| 132 | - // DmpServerUtils::Base64Decode(project, &projData); | |
| 133 | - // context.response()->removeHeader("Content-Type"); | |
| 134 | - // context.response()->setHeader("Content-Type", "text/xml;charset=utf-8"); | |
| 135 | - // context.response()->write(projData); | |
| 136 | - } | |
| 137 | - else | |
| 138 | - { | |
| 139 | - LOGGER_ERROR("服务发布失败"); | |
| 140 | - context.response()->write("{\"status\":\"false\",\"message\":\"Pulish service fail!\"}"); | |
| 141 | - } | |
| 142 | - } | |
| 143 | - else | |
| 144 | - { | |
| 145 | - LOGGER_ERROR("POST数据为空"); | |
| 146 | - context.response()->write("{\"status\":\"false\",\"message\":\"Pulish service fail!\"}"); | |
| 147 | - return; | |
| 148 | - } | |
| 149 | - break; | |
| 150 | - | |
| 151 | - } | |
| 152 | - default: | |
| 153 | - { | |
| 154 | - | |
| 155 | - } | |
| 156 | - } | |
| 157 | -} | |
| 158 | - | |
| 159 | -void DmpManagerApiHandler::startService(const DmpServerApiContext &context) const | |
| 160 | -{ | |
| 161 | - switch (context.request()->method()) | |
| 162 | - { | |
| 163 | - case DmpServerRequest::Method::GET_METHOD: | |
| 164 | - { | |
| 165 | - DmpServerParameters params = context.request()->serverParameters(); | |
| 166 | - std::string serverName; | |
| 167 | - params.getValue("servername", serverName); | |
| 168 | - std::string serviceName; | |
| 169 | - params.getValue("servicename",serviceName); | |
| 170 | - context.manager()->startService(serverName, serviceName); | |
| 171 | - break; | |
| 172 | - } | |
| 173 | - case DmpServerRequest::Method::POST_METHOD: | |
| 174 | - { | |
| 175 | - context.response()->write("{\"status\":\"true\",\"message\":\"服务删除——————POST\"}"); | |
| 176 | - break; | |
| 177 | - } | |
| 178 | - default: | |
| 179 | - { | |
| 180 | - | |
| 181 | - } | |
| 182 | - } | |
| 183 | -} | |
| 184 | -void DmpManagerApiHandler::stopService(const DmpServerApiContext &context) const | |
| 185 | -{ | |
| 186 | - switch (context.request()->method()) | |
| 187 | - { | |
| 188 | - case DmpServerRequest::Method::GET_METHOD: | |
| 189 | - { | |
| 190 | - DmpServerParameters params = context.request()->serverParameters(); | |
| 191 | - std::string serverName; | |
| 192 | - params.getValue("servername", serverName); | |
| 193 | - std::string serviceName; | |
| 194 | - params.getValue("servicename",serviceName); | |
| 195 | - context.manager()->stopService(serverName, serviceName); | |
| 196 | - break; | |
| 197 | - } | |
| 198 | - case DmpServerRequest::Method::POST_METHOD: | |
| 199 | - { | |
| 200 | - context.response()->write("{\"status\":\"true\",\"message\":\"服务删除——————POST\"}"); | |
| 201 | - break; | |
| 202 | - } | |
| 203 | - default: | |
| 204 | - { | |
| 205 | - | |
| 206 | - } | |
| 207 | - } | |
| 208 | -} | |
| 209 | -void DmpManagerApiHandler::RegTileService(const DmpServerApiContext &context) const | |
| 210 | -{ | |
| 211 | - switch (context.request()->method()) | |
| 212 | - { | |
| 213 | - case DmpServerRequest::Method::GET_METHOD: | |
| 214 | - { | |
| 215 | - context.response()->write("{\"status\":\"true\",\"message\":\"切片服务发布测试——————GET\"}"); | |
| 216 | - break; | |
| 217 | - } | |
| 218 | - case DmpServerRequest::Method::POST_METHOD: | |
| 219 | - { | |
| 220 | - context.response()->write("{\"status\":\"true\",\"message\":\"切片服务发布测试——————POST\"}"); | |
| 221 | - break; | |
| 222 | - } | |
| 223 | - default: | |
| 224 | - { | |
| 225 | - | |
| 226 | - } | |
| 227 | - } | |
| 228 | -} | |
| 229 | -void DmpManagerApiHandler::GetServiceList(const DmpServerApiContext &context) const | |
| 230 | -{ | |
| 231 | -} | |
| 232 | - | |
| 233 | -void DmpManagerApiHandler::GetServiceDetail(const DmpServerApiContext &context) const | |
| 234 | -{ | |
| 235 | -} | |
| 236 | - | |
| 237 | -void DmpManagerApiHandler::UpdateService(const DmpServerApiContext &context) const | |
| 238 | -{ | |
| 239 | - switch (context.request()->method()) | |
| 240 | - { | |
| 241 | - case DmpServerRequest::Method::GET_METHOD: | |
| 242 | - { | |
| 243 | - context.response()->write("{\"status\":\"true\",\"message\":\"更新服务信息——————GET\"}"); | |
| 244 | - break; | |
| 245 | - } | |
| 246 | - case DmpServerRequest::Method::POST_METHOD: | |
| 247 | - { | |
| 248 | - context.response()->write("{\"status\":\"true\",\"message\":\"更新服务信息——————POST\"}"); | |
| 249 | - break; | |
| 250 | - } | |
| 251 | - default: | |
| 252 | - { | |
| 253 | - | |
| 254 | - } | |
| 255 | - } | |
| 256 | -} | |
| 257 | - | |
| 258 | -void DmpManagerApiHandler::deleteService(const DmpServerApiContext &context) const | |
| 259 | -{ | |
| 260 | - switch (context.request()->method()) | |
| 261 | - { | |
| 262 | - case DmpServerRequest::Method::GET_METHOD: | |
| 263 | - { | |
| 264 | - DmpServerParameters params = context.request()->serverParameters(); | |
| 265 | - std::string serverName; | |
| 266 | - params.getValue("servername", serverName); | |
| 267 | - std::string serviceName; | |
| 268 | - params.getValue("servicename",serviceName); | |
| 269 | - if(context.manager()->deleteService(serverName, serviceName)) { | |
| 270 | - context.response()->write("{\"status\":\"true\",\"message\":\"删除服务成功\"}"); | |
| 271 | - }else{ | |
| 272 | - context.response()->write("{\"status\":\"false\",\"message\":\"删除服务失败\"}"); | |
| 273 | - } | |
| 274 | - break; | |
| 275 | - } | |
| 276 | - case DmpServerRequest::Method::POST_METHOD: | |
| 277 | - { | |
| 278 | - context.response()->write("{\"status\":\"true\",\"message\":\"服务删除——————POST\"}"); | |
| 279 | - break; | |
| 280 | - } | |
| 281 | - default: | |
| 282 | - { | |
| 283 | - | |
| 284 | - } | |
| 285 | - } | |
| 286 | -} | |
| 287 | - | |
| 288 | -//获取配置文件切片信息 | |
| 289 | -void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context) const | |
| 290 | -{ | |
| 291 | - switch (context.request()->method()) | |
| 292 | - { | |
| 293 | - case DmpServerRequest::Method::GET_METHOD: | |
| 294 | - { | |
| 295 | - context.response()->write("{\"status\":\"true\",\"message\":\"获取切片配置信息——————GET\"}"); | |
| 296 | - break; | |
| 297 | - } | |
| 298 | - case DmpServerRequest::Method::POST_METHOD: | |
| 299 | - { | |
| 300 | - std::string path; | |
| 301 | - std::string strExtent; | |
| 302 | - const char* data = (char*)(context.request()->GetData()); | |
| 303 | - if(data && *data != '\0') | |
| 304 | - { | |
| 305 | - try | |
| 306 | - { | |
| 307 | - std::stringstream stream(data); | |
| 308 | - boost::property_tree::ptree pt; | |
| 309 | - boost::property_tree::ptree pt_json; | |
| 310 | - std::string confcdipath; | |
| 311 | - std::string confxmlpath; | |
| 312 | - | |
| 313 | - boost::property_tree::read_json(stream, pt); | |
| 314 | - path= pt.get<std::string>("projectlayers.maplayer.datasource"); | |
| 315 | - confcdipath=path+"/conf.cdi"; | |
| 316 | - confxmlpath=path+"/conf.xml"; | |
| 317 | - //读取切片配置文件conf.cdi | |
| 318 | - boost::property_tree::ptree pt_confcdi; | |
| 319 | - boost::property_tree::read_xml(confcdipath,pt_confcdi); | |
| 320 | - //boost::property_tree::ptree pt_base=pt.get_child("base"); | |
| 321 | - std::string xmin=pt_confcdi.get<std::string>("EnvelopeN.XMin"); | |
| 322 | - std::string ymin=pt_confcdi.get<std::string>("EnvelopeN.YMin"); | |
| 323 | - std::string xmax=pt_confcdi.get<std::string>("EnvelopeN.XMax"); | |
| 324 | - std::string ymax=pt_confcdi.get<std::string>("EnvelopeN.YMax"); | |
| 325 | - pt.put("projectlayers.maplayer.extent.xmin",xmin); | |
| 326 | - pt.put("projectlayers.maplayer.extent.ymin",ymin); | |
| 327 | - pt.put("projectlayers.maplayer.extent.xmax",xmax); | |
| 328 | - pt.put("projectlayers.maplayer.extent.ymax",ymax); | |
| 329 | - //读取配置文件conf.xml | |
| 330 | - boost::property_tree::ptree pt_confxml; | |
| 331 | - boost::property_tree::read_xml(confxmlpath,pt_confxml); | |
| 332 | - std::string strWKT=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKT"); | |
| 333 | - std::string wkid=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKID"); | |
| 334 | - std::string top=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.X"); | |
| 335 | - std::string left=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.Y"); | |
| 336 | - std::string tileCols=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileCols"); | |
| 337 | - std::string tileRows=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileRows"); | |
| 338 | - std::string dpi=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.DPI"); | |
| 339 | - pt.put("projectCrs.spatialrefsys.wkt",strWKT); | |
| 340 | - pt.put("projectCrs.spatialrefsys.srid",wkid); | |
| 341 | - | |
| 342 | - boost::property_tree::ptree pt_tileMatrixSets=pt.get_child("tileMatrixSets"); | |
| 343 | - BOOST_FOREACH(boost::property_tree::ptree::value_type &v1,pt_tileMatrixSets) | |
| 344 | - { | |
| 345 | - //conf.xml中读取tileinfo | |
| 346 | - boost::property_tree::ptree pt_levels,pt_tileMatrixSet; | |
| 347 | - boost::property_tree::ptree pt_tileArry=pt_confxml.get_child("CacheInfo.TileCacheInfo.LODInfos"); | |
| 348 | - BOOST_FOREACH(boost::property_tree::ptree::value_type &v2,pt_tileArry) | |
| 349 | - { | |
| 350 | - boost::property_tree::ptree pt_level; | |
| 351 | - if(v2.first=="LODInfo") | |
| 352 | - { | |
| 353 | - std::string level=v2.second.get<std::string>("LevelID"); | |
| 354 | - std::string scale=v2.second.get<std::string>("Scale"); | |
| 355 | - std::string resolution=v2.second.get<std::string>("Resolution"); | |
| 356 | - pt_level.add("level.id",level); | |
| 357 | - pt_level.add("level.scaleDenominator",scale); | |
| 358 | - pt_level.add("level.resolution",resolution); | |
| 359 | - pt_levels.push_back(std::make_pair("", pt_level)); | |
| 360 | - } | |
| 361 | - } | |
| 362 | - std::string id_=v1.second.get<std::string>("tileMatrixSet.id"); | |
| 363 | - pt_tileMatrixSet.add("id",id_); | |
| 364 | - pt_tileMatrixSet.add("crs","EPSG::"+wkid); | |
| 365 | - pt_tileMatrixSet.add("tileCols",tileCols); | |
| 366 | - pt_tileMatrixSet.add("tileRows",tileRows); | |
| 367 | - pt_tileMatrixSet.add("dpi",dpi); | |
| 368 | - pt_tileMatrixSet.add("tileOrigin.X",top); | |
| 369 | - pt_tileMatrixSet.add("tileOrigin.Y",left); | |
| 370 | - pt_tileMatrixSet.add_child("levels",pt_levels); | |
| 371 | - //pt_tilelist.add_child("tileMatrixList",pt_tiles); | |
| 372 | - v1.second.put_child("tileMatrixSet",pt_tileMatrixSet); | |
| 373 | - //v1.second.put("id","EPSG::"+wkid); | |
| 374 | - } | |
| 375 | - | |
| 376 | - pt.put_child("tileMatrixSets",pt_tileMatrixSets); | |
| 377 | - std::stringstream ss; | |
| 378 | - boost::property_tree::write_json(ss,pt); | |
| 379 | - strExtent=ss.str(); | |
| 380 | - } | |
| 381 | - catch (boost::property_tree::ptree_bad_path& e) { | |
| 382 | - LOGGER_ERROR(e.what()); | |
| 383 | - context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | |
| 384 | - return; | |
| 385 | - } | |
| 386 | - catch (boost::property_tree::ptree_bad_data& e) { | |
| 387 | - LOGGER_ERROR(e.what()); | |
| 388 | - context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | |
| 389 | - return; | |
| 390 | - } | |
| 391 | - context.response()->write(strExtent); | |
| 392 | - } | |
| 393 | - break; | |
| 394 | - } | |
| 395 | - default: | |
| 396 | - { | |
| 397 | - | |
| 398 | - } | |
| 399 | - } | |
| 400 | -} | |
| 401 | - | |
| 402 | -//判断服务是否存在 | |
| 403 | -void DmpManagerApiHandler::IsExistServiceName(const DmpServerApiContext &context) const | |
| 404 | -{ | |
| 405 | - switch (context.request()->method()) | |
| 406 | - { | |
| 407 | - case DmpServerRequest::Method::GET_METHOD: | |
| 408 | - { | |
| 409 | - context.response()->write("{\"status\":\"true\",\"message\":\"——————GET\"}"); | |
| 410 | - break; | |
| 411 | - } | |
| 412 | - case DmpServerRequest::Method::POST_METHOD: | |
| 413 | - { | |
| 414 | - context.response()->write("{\"status\":\"true\",\"message\":\"——————POST\"}"); | |
| 415 | - break; | |
| 416 | - } | |
| 417 | - default: | |
| 418 | - { | |
| 419 | - | |
| 420 | - } | |
| 421 | - } | |
| 422 | -} | |
| 423 | - | |
| 424 | -//新增目录 | |
| 425 | -void DmpManagerApiHandler::AddCatalog(const DmpServerApiContext &context) const | |
| 426 | -{ | |
| 427 | - switch (context.request()->method()) | |
| 428 | - { | |
| 429 | - case DmpServerRequest::Method::GET_METHOD: | |
| 430 | - { | |
| 431 | - context.response()->write("{\"status\":\"true\",\"message\":\"新增目录——————GET\"}"); | |
| 432 | - break; | |
| 433 | - } | |
| 434 | - case DmpServerRequest::Method::POST_METHOD: | |
| 435 | - { | |
| 436 | - context.response()->write("{\"status\":\"true\",\"message\":\"新增目录——————POST\"}"); | |
| 437 | - break; | |
| 438 | - } | |
| 439 | - default: | |
| 440 | - { | |
| 441 | - | |
| 442 | - } | |
| 443 | - } | |
| 444 | -} | |
| 445 | - | |
| 446 | -//删除目录 | |
| 447 | -void DmpManagerApiHandler::DeleteCatalog(const DmpServerApiContext &context) const | |
| 448 | -{ | |
| 449 | - switch (context.request()->method()) | |
| 450 | - { | |
| 451 | - case DmpServerRequest::Method::GET_METHOD: | |
| 452 | - { | |
| 453 | - context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————GET\"}"); | |
| 454 | - break; | |
| 455 | - } | |
| 456 | - case DmpServerRequest::Method::POST_METHOD: | |
| 457 | - { | |
| 458 | - context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————POST\"}"); | |
| 459 | - break; | |
| 460 | - } | |
| 461 | - default: | |
| 462 | - { | |
| 463 | - | |
| 464 | - } | |
| 465 | - } | |
| 466 | -} | |
| 467 | - | |
| 468 | -void DmpManagerApiHandler::GetServicesMatrixSets(const DmpServerApiContext &context) const | |
| 469 | -{ | |
| 470 | - switch (context.request()->method()) | |
| 471 | - { | |
| 472 | - case DmpServerRequest::Method::GET_METHOD: | |
| 473 | - { | |
| 474 | - context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————GET\"}"); | |
| 475 | - break; | |
| 476 | - } | |
| 477 | - case DmpServerRequest::Method::POST_METHOD: | |
| 478 | - { | |
| 479 | - context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————POST\"}"); | |
| 480 | - break; | |
| 481 | - } | |
| 482 | - default: | |
| 483 | - { | |
| 484 | - | |
| 485 | - } | |
| 486 | - } | |
| 487 | -} | |
| 488 | -void DmpManagerApiHandler::GetCatalogList(const DmpServerApiContext &context) const | |
| 489 | -{ | |
| 490 | - switch (context.request()->method()) | |
| 491 | - { | |
| 492 | - case DmpServerRequest::Method::GET_METHOD: | |
| 493 | - { | |
| 494 | - context.response()->write("{\"status\":\"true\",\"message\":\"获取目录列表——————GET\"}"); | |
| 495 | - break; | |
| 496 | - } | |
| 497 | - case DmpServerRequest::Method::POST_METHOD: | |
| 498 | - { | |
| 499 | - context.response()->write("{\"status\":\"true\",\"message\":\"获取目录列表——————POST\"}"); | |
| 500 | - break; | |
| 501 | - } | |
| 502 | - default: | |
| 503 | - { | |
| 504 | - | |
| 505 | - } | |
| 506 | - } | |
| 507 | -} | |
| 508 | -void DmpManagerApiHandler::UpdateCache(const DmpServerApiContext &context)const | |
| 509 | -{ | |
| 510 | - switch (context.request()->method()) | |
| 511 | - { | |
| 512 | - case DmpServerRequest::Method::GET_METHOD: | |
| 513 | - { | |
| 514 | - std::string serviceName_; | |
| 515 | - const DmpServerParameters params_ (context.request()->serverParameters()); | |
| 516 | - CIMap paramsMap=params_.parameters(); | |
| 517 | - std::map<std::string, std::string>::const_iterator iter; | |
| 518 | - iter =paramsMap.find("SERVICENAME"); | |
| 519 | - if (iter != paramsMap.end()) | |
| 520 | - { | |
| 521 | - try | |
| 522 | - { | |
| 523 | - serviceName_ = boost::lexical_cast<std::string>(iter->second); | |
| 524 | - } | |
| 525 | - catch (boost::bad_lexical_cast &e) | |
| 526 | - { | |
| 527 | - LOGGER_ERROR(e.what()); | |
| 528 | - context.response()->write("{\"status\":\"true\",\"message\":\"获取参数信息错误——————GET\"}"); | |
| 529 | - return; | |
| 530 | - } | |
| 531 | - } | |
| 532 | - | |
| 533 | - break; | |
| 534 | - } | |
| 535 | - case DmpServerRequest::Method::POST_METHOD: | |
| 536 | - { | |
| 537 | - context.response()->write("{\"status\":\"true\",\"message\":\"更新缓存——————POST\"}"); | |
| 538 | - break; | |
| 539 | - } | |
| 540 | - default: | |
| 541 | - { | |
| 542 | - | |
| 543 | - } | |
| 544 | - } | |
| 545 | -} | |
| 546 | -void DmpManagerApiHandler::DeleteCache(const DmpServerApiContext &context)const | |
| 547 | -{ | |
| 548 | - switch (context.request()->method()) | |
| 549 | - { | |
| 550 | - case DmpServerRequest::Method::GET_METHOD: | |
| 551 | - { | |
| 552 | - std::string serviceName_; | |
| 553 | - const DmpServerParameters params_ (context.request()->serverParameters()); | |
| 554 | - CIMap paramsMap=params_.parameters(); | |
| 555 | - std::map<std::string, std::string>::const_iterator iter; | |
| 556 | - iter =paramsMap.find("SERVICENAME"); | |
| 557 | - if (iter != paramsMap.end()) | |
| 558 | - { | |
| 559 | - try | |
| 560 | - { | |
| 561 | - serviceName_ = boost::lexical_cast<std::string>(iter->second); | |
| 562 | - } | |
| 563 | - catch (boost::bad_lexical_cast &e) | |
| 564 | - { | |
| 565 | - LOGGER_ERROR(e.what()); | |
| 566 | - context.response()->write("{\"status\":\"true\",\"message\":\"获取参数信息错误——————GET\"}"); | |
| 567 | - return; | |
| 568 | - } | |
| 569 | - } | |
| 570 | - | |
| 571 | - break; | |
| 572 | - } | |
| 573 | - case DmpServerRequest::Method::POST_METHOD: | |
| 574 | - { | |
| 575 | - context.response()->write("{\"status\":\"true\",\"message\":\"删除缓存——————POST\"}"); | |
| 576 | - break; | |
| 577 | - } | |
| 578 | - default: | |
| 579 | - { | |
| 580 | - | |
| 581 | - } | |
| 582 | - } | |
| 583 | -} | |
| 584 | - | |
| 585 | -void DmpManagerApiHandler::getCapabilities(const DmpServerApiContext &context) const | |
| 586 | -{ | |
| 587 | - std::string strJson = context.manager()->getCapabilities(); | |
| 588 | - context.response()->write(strJson); | |
| 589 | -} | |
| 590 | -void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) const | |
| 591 | -{ | |
| 592 | - switch (context.request()->method()) | |
| 593 | - { | |
| 594 | - case DmpServerRequest::Method::GET_METHOD: | |
| 595 | - { | |
| 596 | - if(context.manager()->loadServices()) { | |
| 597 | - context.response()->write("{\"status\":\"true\",\"message\":\"重载服务成功\"}"); | |
| 598 | - }else{ | |
| 599 | - context.response()->write("{\"status\":\"false\",\"message\":\"重载服务失败\"}"); | |
| 600 | - } | |
| 601 | - break; | |
| 602 | - | |
| 603 | - } | |
| 604 | - case DmpServerRequest::Method::POST_METHOD: | |
| 605 | - { | |
| 606 | - context.response()->write("{\"status\":\"true\",\"message\":\"服务重载——————POST\"}"); | |
| 607 | - break; | |
| 608 | - } | |
| 609 | - default: | |
| 610 | - { | |
| 611 | - | |
| 612 | - } | |
| 613 | - } | |
| 614 | -} | |
| \ No newline at end of file |
| ... | ... | @@ -102,8 +102,38 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const |
| 102 | 102 | LOGGER_INFO("服务发布成功"); |
| 103 | 103 | std::string url; |
| 104 | 104 | std::string http="http://"+context.request()->domain()+":"+context.request()->port(); |
| 105 | + switch (capabilities) | |
| 106 | + { | |
| 107 | + case 1: | |
| 108 | + { | |
| 109 | + url=http+"/DMap/Services/"+name+"/"+serverType+"/WmtsService?REQUEST=GetThumbnail"; | |
| 110 | + break; | |
| 111 | + } | |
| 112 | + case 2: | |
| 113 | + { | |
| 114 | + url=http+"/DMap/Services/"+name+"/"+serverType+"/WmsService?REQUEST=GetThumbnail"; | |
| 115 | + break; | |
| 116 | + } | |
| 117 | + case 4: | |
| 118 | + { | |
| 119 | + url=http+"/DMap/Services/"+name+"/"+serverType+"/WfsService?REQUEST=GetThumbnail"; | |
| 120 | + break; | |
| 121 | + } | |
| 122 | + case 8: | |
| 123 | + { | |
| 124 | + url=http+"/DMap/Services/"+name+"/"+serverType+"/WpsService?REQUEST=GetThumbnail"; | |
| 125 | + break; | |
| 126 | + } | |
| 127 | + case 16: | |
| 128 | + { | |
| 129 | + url=http+"/DMap/Services/"+name+"/"+serverType+"/tmsService?REQUEST=GetThumbnail"; | |
| 130 | + break; | |
| 131 | + } | |
| 132 | + | |
| 133 | + default: | |
| 134 | + break; | |
| 135 | + } | |
| 105 | 136 | |
| 106 | - url=http+"/DMap/Services/"+name+"/"+serverType+"/tmsService?REQUEST=GetThumbnail"; | |
| 107 | 137 | context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}"); |
| 108 | 138 | // std::string projData; |
| 109 | 139 | // DmpServerUtils::Base64Decode(project, &projData); | ... | ... |
请
注册
或
登录
后发表评论