GridServiceConnector.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using log4net;
  28. using System;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Reflection;
  32. using Nini.Config;
  33. using OpenSim.Framework;
  34. using OpenSim.Framework.Communications;
  35. using OpenSim.Framework.Servers.HttpServer;
  36. using OpenSim.Services.Interfaces;
  37. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  38. using OpenSim.Server.Base;
  39. using OpenMetaverse;
  40. namespace OpenSim.Services.Connectors
  41. {
  42. public class GridServicesConnector : IGridService
  43. {
  44. private static readonly ILog m_log =
  45. LogManager.GetLogger(
  46. MethodBase.GetCurrentMethod().DeclaringType);
  47. private string m_ServerURI = String.Empty;
  48. public GridServicesConnector()
  49. {
  50. }
  51. public GridServicesConnector(string serverURI)
  52. {
  53. m_ServerURI = serverURI.TrimEnd('/');
  54. }
  55. public GridServicesConnector(IConfigSource source)
  56. {
  57. Initialise(source);
  58. }
  59. public virtual void Initialise(IConfigSource source)
  60. {
  61. IConfig gridConfig = source.Configs["GridService"];
  62. if (gridConfig == null)
  63. {
  64. m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
  65. throw new Exception("Grid connector init error");
  66. }
  67. string serviceURI = gridConfig.GetString("GridServerURI",
  68. String.Empty);
  69. if (serviceURI == String.Empty)
  70. {
  71. m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
  72. throw new Exception("Grid connector init error");
  73. }
  74. m_ServerURI = serviceURI;
  75. }
  76. #region IGridService
  77. public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo)
  78. {
  79. Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
  80. Dictionary<string, object> sendData = new Dictionary<string,object>();
  81. foreach (KeyValuePair<string, object> kvp in rinfo)
  82. sendData[kvp.Key] = (string)kvp.Value;
  83. sendData["SCOPEID"] = scopeID.ToString();
  84. sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
  85. sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
  86. sendData["METHOD"] = "register";
  87. string reqString = ServerUtils.BuildQueryString(sendData);
  88. // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
  89. try
  90. {
  91. string reply = SynchronousRestFormsRequester.MakeRequest("POST",
  92. m_ServerURI + "/grid",
  93. reqString);
  94. if (reply != string.Empty)
  95. {
  96. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  97. if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
  98. {
  99. return String.Empty;
  100. }
  101. else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
  102. {
  103. m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
  104. return replyData["Message"].ToString();
  105. }
  106. else if (!replyData.ContainsKey("Result"))
  107. {
  108. m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
  109. }
  110. else
  111. {
  112. m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
  113. return "Unexpected result "+replyData["Result"].ToString();
  114. }
  115. }
  116. else
  117. m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
  118. }
  119. catch (Exception e)
  120. {
  121. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  122. }
  123. return "Error communicating with grid service";
  124. }
  125. public virtual bool DeregisterRegion(UUID regionID)
  126. {
  127. Dictionary<string, object> sendData = new Dictionary<string, object>();
  128. sendData["REGIONID"] = regionID.ToString();
  129. sendData["METHOD"] = "deregister";
  130. try
  131. {
  132. string reply = SynchronousRestFormsRequester.MakeRequest("POST",
  133. m_ServerURI + "/grid",
  134. ServerUtils.BuildQueryString(sendData));
  135. if (reply != string.Empty)
  136. {
  137. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  138. if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
  139. return true;
  140. }
  141. else
  142. m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
  143. }
  144. catch (Exception e)
  145. {
  146. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  147. }
  148. return false;
  149. }
  150. public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
  151. {
  152. Dictionary<string, object> sendData = new Dictionary<string, object>();
  153. sendData["SCOPEID"] = scopeID.ToString();
  154. sendData["REGIONID"] = regionID.ToString();
  155. sendData["METHOD"] = "get_neighbours";
  156. List<GridRegion> rinfos = new List<GridRegion>();
  157. string reqString = ServerUtils.BuildQueryString(sendData);
  158. string reply = string.Empty;
  159. try
  160. {
  161. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  162. m_ServerURI + "/grid",
  163. reqString);
  164. }
  165. catch (Exception e)
  166. {
  167. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  168. return rinfos;
  169. }
  170. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  171. if (replyData != null)
  172. {
  173. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  174. //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
  175. foreach (object r in rinfosList)
  176. {
  177. if (r is Dictionary<string, object>)
  178. {
  179. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  180. rinfos.Add(rinfo);
  181. }
  182. }
  183. }
  184. else
  185. m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
  186. scopeID, regionID);
  187. return rinfos;
  188. }
  189. public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
  190. {
  191. Dictionary<string, object> sendData = new Dictionary<string, object>();
  192. sendData["SCOPEID"] = scopeID.ToString();
  193. sendData["REGIONID"] = regionID.ToString();
  194. sendData["METHOD"] = "get_region_by_uuid";
  195. string reply = string.Empty;
  196. try
  197. {
  198. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  199. m_ServerURI + "/grid",
  200. ServerUtils.BuildQueryString(sendData));
  201. }
  202. catch (Exception e)
  203. {
  204. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  205. return null;
  206. }
  207. GridRegion rinfo = null;
  208. if (reply != string.Empty)
  209. {
  210. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  211. if ((replyData != null) && (replyData["result"] != null))
  212. {
  213. if (replyData["result"] is Dictionary<string, object>)
  214. rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
  215. //else
  216. // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
  217. // scopeID, regionID);
  218. }
  219. else
  220. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
  221. scopeID, regionID);
  222. }
  223. else
  224. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
  225. return rinfo;
  226. }
  227. public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
  228. {
  229. Dictionary<string, object> sendData = new Dictionary<string, object>();
  230. sendData["SCOPEID"] = scopeID.ToString();
  231. sendData["X"] = x.ToString();
  232. sendData["Y"] = y.ToString();
  233. sendData["METHOD"] = "get_region_by_position";
  234. string reply = string.Empty;
  235. try
  236. {
  237. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  238. m_ServerURI + "/grid",
  239. ServerUtils.BuildQueryString(sendData));
  240. }
  241. catch (Exception e)
  242. {
  243. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  244. return null;
  245. }
  246. GridRegion rinfo = null;
  247. if (reply != string.Empty)
  248. {
  249. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  250. if ((replyData != null) && (replyData["result"] != null))
  251. {
  252. if (replyData["result"] is Dictionary<string, object>)
  253. rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
  254. //else
  255. // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
  256. // scopeID, x, y);
  257. }
  258. else
  259. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
  260. scopeID, x, y);
  261. }
  262. else
  263. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
  264. return rinfo;
  265. }
  266. public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
  267. {
  268. Dictionary<string, object> sendData = new Dictionary<string, object>();
  269. sendData["SCOPEID"] = scopeID.ToString();
  270. sendData["NAME"] = regionName;
  271. sendData["METHOD"] = "get_region_by_name";
  272. string reply = string.Empty;
  273. try
  274. {
  275. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  276. m_ServerURI + "/grid",
  277. ServerUtils.BuildQueryString(sendData));
  278. }
  279. catch (Exception e)
  280. {
  281. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  282. return null;
  283. }
  284. GridRegion rinfo = null;
  285. if (reply != string.Empty)
  286. {
  287. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  288. if ((replyData != null) && (replyData["result"] != null))
  289. {
  290. if (replyData["result"] is Dictionary<string, object>)
  291. rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
  292. }
  293. else
  294. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
  295. scopeID, regionName);
  296. }
  297. else
  298. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
  299. return rinfo;
  300. }
  301. public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
  302. {
  303. Dictionary<string, object> sendData = new Dictionary<string, object>();
  304. sendData["SCOPEID"] = scopeID.ToString();
  305. sendData["NAME"] = name;
  306. sendData["MAX"] = maxNumber.ToString();
  307. sendData["METHOD"] = "get_regions_by_name";
  308. List<GridRegion> rinfos = new List<GridRegion>();
  309. string reply = string.Empty;
  310. try
  311. {
  312. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  313. m_ServerURI + "/grid",
  314. ServerUtils.BuildQueryString(sendData));
  315. }
  316. catch (Exception e)
  317. {
  318. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  319. return rinfos;
  320. }
  321. if (reply != string.Empty)
  322. {
  323. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  324. if (replyData != null)
  325. {
  326. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  327. foreach (object r in rinfosList)
  328. {
  329. if (r is Dictionary<string, object>)
  330. {
  331. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  332. rinfos.Add(rinfo);
  333. }
  334. }
  335. }
  336. else
  337. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
  338. scopeID, name, maxNumber);
  339. }
  340. else
  341. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
  342. return rinfos;
  343. }
  344. public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
  345. {
  346. Dictionary<string, object> sendData = new Dictionary<string, object>();
  347. sendData["SCOPEID"] = scopeID.ToString();
  348. sendData["XMIN"] = xmin.ToString();
  349. sendData["XMAX"] = xmax.ToString();
  350. sendData["YMIN"] = ymin.ToString();
  351. sendData["YMAX"] = ymax.ToString();
  352. sendData["METHOD"] = "get_region_range";
  353. List<GridRegion> rinfos = new List<GridRegion>();
  354. string reply = string.Empty;
  355. try
  356. {
  357. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  358. m_ServerURI + "/grid",
  359. ServerUtils.BuildQueryString(sendData));
  360. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  361. }
  362. catch (Exception e)
  363. {
  364. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  365. return rinfos;
  366. }
  367. if (reply != string.Empty)
  368. {
  369. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  370. if (replyData != null)
  371. {
  372. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  373. foreach (object r in rinfosList)
  374. {
  375. if (r is Dictionary<string, object>)
  376. {
  377. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  378. rinfos.Add(rinfo);
  379. }
  380. }
  381. }
  382. else
  383. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
  384. scopeID, xmin, xmax, ymin, ymax);
  385. }
  386. else
  387. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
  388. return rinfos;
  389. }
  390. public List<GridRegion> GetDefaultRegions(UUID scopeID)
  391. {
  392. Dictionary<string, object> sendData = new Dictionary<string, object>();
  393. sendData["SCOPEID"] = scopeID.ToString();
  394. sendData["METHOD"] = "get_default_regions";
  395. List<GridRegion> rinfos = new List<GridRegion>();
  396. string reply = string.Empty;
  397. try
  398. {
  399. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  400. m_ServerURI + "/grid",
  401. ServerUtils.BuildQueryString(sendData));
  402. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  403. }
  404. catch (Exception e)
  405. {
  406. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  407. return rinfos;
  408. }
  409. if (reply != string.Empty)
  410. {
  411. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  412. if (replyData != null)
  413. {
  414. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  415. foreach (object r in rinfosList)
  416. {
  417. if (r is Dictionary<string, object>)
  418. {
  419. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  420. rinfos.Add(rinfo);
  421. }
  422. }
  423. }
  424. else
  425. m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions {0} received null response",
  426. scopeID);
  427. }
  428. else
  429. m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions received null reply");
  430. return rinfos;
  431. }
  432. public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
  433. {
  434. Dictionary<string, object> sendData = new Dictionary<string, object>();
  435. sendData["SCOPEID"] = scopeID.ToString();
  436. sendData["X"] = x.ToString();
  437. sendData["Y"] = y.ToString();
  438. sendData["METHOD"] = "get_fallback_regions";
  439. List<GridRegion> rinfos = new List<GridRegion>();
  440. string reply = string.Empty;
  441. try
  442. {
  443. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  444. m_ServerURI + "/grid",
  445. ServerUtils.BuildQueryString(sendData));
  446. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  447. }
  448. catch (Exception e)
  449. {
  450. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  451. return rinfos;
  452. }
  453. if (reply != string.Empty)
  454. {
  455. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  456. if (replyData != null)
  457. {
  458. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  459. foreach (object r in rinfosList)
  460. {
  461. if (r is Dictionary<string, object>)
  462. {
  463. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  464. rinfos.Add(rinfo);
  465. }
  466. }
  467. }
  468. else
  469. m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions {0}, {1}-{2} received null response",
  470. scopeID, x, y);
  471. }
  472. else
  473. m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions received null reply");
  474. return rinfos;
  475. }
  476. public List<GridRegion> GetHyperlinks(UUID scopeID)
  477. {
  478. Dictionary<string, object> sendData = new Dictionary<string, object>();
  479. sendData["SCOPEID"] = scopeID.ToString();
  480. sendData["METHOD"] = "get_hyperlinks";
  481. List<GridRegion> rinfos = new List<GridRegion>();
  482. string reply = string.Empty;
  483. try
  484. {
  485. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  486. m_ServerURI + "/grid",
  487. ServerUtils.BuildQueryString(sendData));
  488. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  489. }
  490. catch (Exception e)
  491. {
  492. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  493. return rinfos;
  494. }
  495. if (reply != string.Empty)
  496. {
  497. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  498. if (replyData != null)
  499. {
  500. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  501. foreach (object r in rinfosList)
  502. {
  503. if (r is Dictionary<string, object>)
  504. {
  505. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  506. rinfos.Add(rinfo);
  507. }
  508. }
  509. }
  510. else
  511. m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response",
  512. scopeID);
  513. }
  514. else
  515. m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply");
  516. return rinfos;
  517. }
  518. public virtual int GetRegionFlags(UUID scopeID, UUID regionID)
  519. {
  520. Dictionary<string, object> sendData = new Dictionary<string, object>();
  521. sendData["SCOPEID"] = scopeID.ToString();
  522. sendData["REGIONID"] = regionID.ToString();
  523. sendData["METHOD"] = "get_region_flags";
  524. string reply = string.Empty;
  525. try
  526. {
  527. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  528. m_ServerURI + "/grid",
  529. ServerUtils.BuildQueryString(sendData));
  530. }
  531. catch (Exception e)
  532. {
  533. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  534. return -1;
  535. }
  536. int flags = -1;
  537. if (reply != string.Empty)
  538. {
  539. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  540. if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
  541. {
  542. Int32.TryParse((string)replyData["result"], out flags);
  543. //else
  544. // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received wrong type {2}",
  545. // scopeID, regionID, replyData["result"].GetType());
  546. }
  547. else
  548. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received null response",
  549. scopeID, regionID);
  550. }
  551. else
  552. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags received null reply");
  553. return flags;
  554. }
  555. #endregion
  556. }
  557. }