GridServiceConnector.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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.Services.Interfaces;
  36. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  37. using OpenSim.Server.Base;
  38. using OpenMetaverse;
  39. namespace OpenSim.Services.Connectors
  40. {
  41. public class GridServicesConnector : IGridService
  42. {
  43. private static readonly ILog m_log =
  44. LogManager.GetLogger(
  45. MethodBase.GetCurrentMethod().DeclaringType);
  46. private string m_ServerURI = String.Empty;
  47. public GridServicesConnector()
  48. {
  49. }
  50. public GridServicesConnector(string serverURI)
  51. {
  52. m_ServerURI = serverURI.TrimEnd('/');
  53. }
  54. public GridServicesConnector(IConfigSource source)
  55. {
  56. Initialise(source);
  57. }
  58. public virtual void Initialise(IConfigSource source)
  59. {
  60. IConfig gridConfig = source.Configs["GridService"];
  61. if (gridConfig == null)
  62. {
  63. m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
  64. throw new Exception("Grid connector init error");
  65. }
  66. string serviceURI = gridConfig.GetString("GridServerURI",
  67. String.Empty);
  68. if (serviceURI == String.Empty)
  69. {
  70. m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
  71. throw new Exception("Grid connector init error");
  72. }
  73. m_ServerURI = serviceURI;
  74. }
  75. #region IGridService
  76. public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
  77. {
  78. Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
  79. Dictionary<string, object> sendData = new Dictionary<string,object>();
  80. foreach (KeyValuePair<string, object> kvp in rinfo)
  81. sendData[kvp.Key] = (string)kvp.Value;
  82. sendData["SCOPEID"] = scopeID.ToString();
  83. sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
  84. sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
  85. sendData["METHOD"] = "register";
  86. string reqString = ServerUtils.BuildQueryString(sendData);
  87. // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
  88. try
  89. {
  90. string reply = SynchronousRestFormsRequester.MakeRequest("POST",
  91. m_ServerURI + "/grid",
  92. reqString);
  93. if (reply != string.Empty)
  94. {
  95. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  96. if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
  97. {
  98. return String.Empty;
  99. }
  100. else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
  101. {
  102. m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
  103. return replyData["Message"].ToString();
  104. }
  105. else if (!replyData.ContainsKey("Result"))
  106. {
  107. m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
  108. }
  109. else
  110. {
  111. m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
  112. return "Unexpected result "+replyData["Result"].ToString();
  113. }
  114. }
  115. else
  116. m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
  117. }
  118. catch (Exception e)
  119. {
  120. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  121. }
  122. return "Error communicating with grid service";
  123. }
  124. public bool DeregisterRegion(UUID regionID)
  125. {
  126. Dictionary<string, object> sendData = new Dictionary<string, object>();
  127. sendData["REGIONID"] = regionID.ToString();
  128. sendData["METHOD"] = "deregister";
  129. try
  130. {
  131. string reply = SynchronousRestFormsRequester.MakeRequest("POST",
  132. m_ServerURI + "/grid",
  133. ServerUtils.BuildQueryString(sendData));
  134. if (reply != string.Empty)
  135. {
  136. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  137. if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
  138. return true;
  139. }
  140. else
  141. m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
  142. }
  143. catch (Exception e)
  144. {
  145. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  146. }
  147. return false;
  148. }
  149. public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
  150. {
  151. Dictionary<string, object> sendData = new Dictionary<string, object>();
  152. sendData["SCOPEID"] = scopeID.ToString();
  153. sendData["REGIONID"] = regionID.ToString();
  154. sendData["METHOD"] = "get_neighbours";
  155. List<GridRegion> rinfos = new List<GridRegion>();
  156. string reqString = ServerUtils.BuildQueryString(sendData);
  157. string reply = string.Empty;
  158. try
  159. {
  160. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  161. m_ServerURI + "/grid",
  162. reqString);
  163. }
  164. catch (Exception e)
  165. {
  166. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  167. return rinfos;
  168. }
  169. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  170. if (replyData != null)
  171. {
  172. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  173. //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
  174. foreach (object r in rinfosList)
  175. {
  176. if (r is Dictionary<string, object>)
  177. {
  178. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  179. rinfos.Add(rinfo);
  180. }
  181. }
  182. }
  183. else
  184. m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
  185. scopeID, regionID);
  186. return rinfos;
  187. }
  188. public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
  189. {
  190. Dictionary<string, object> sendData = new Dictionary<string, object>();
  191. sendData["SCOPEID"] = scopeID.ToString();
  192. sendData["REGIONID"] = regionID.ToString();
  193. sendData["METHOD"] = "get_region_by_uuid";
  194. string reply = string.Empty;
  195. try
  196. {
  197. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  198. m_ServerURI + "/grid",
  199. ServerUtils.BuildQueryString(sendData));
  200. }
  201. catch (Exception e)
  202. {
  203. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  204. return null;
  205. }
  206. GridRegion rinfo = null;
  207. if (reply != string.Empty)
  208. {
  209. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  210. if ((replyData != null) && (replyData["result"] != null))
  211. {
  212. if (replyData["result"] is Dictionary<string, object>)
  213. rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
  214. //else
  215. // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
  216. // scopeID, regionID);
  217. }
  218. else
  219. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
  220. scopeID, regionID);
  221. }
  222. else
  223. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
  224. return rinfo;
  225. }
  226. public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
  227. {
  228. Dictionary<string, object> sendData = new Dictionary<string, object>();
  229. sendData["SCOPEID"] = scopeID.ToString();
  230. sendData["X"] = x.ToString();
  231. sendData["Y"] = y.ToString();
  232. sendData["METHOD"] = "get_region_by_position";
  233. string reply = string.Empty;
  234. try
  235. {
  236. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  237. m_ServerURI + "/grid",
  238. ServerUtils.BuildQueryString(sendData));
  239. }
  240. catch (Exception e)
  241. {
  242. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  243. return null;
  244. }
  245. GridRegion rinfo = null;
  246. if (reply != string.Empty)
  247. {
  248. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  249. if ((replyData != null) && (replyData["result"] != null))
  250. {
  251. if (replyData["result"] is Dictionary<string, object>)
  252. rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
  253. //else
  254. // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
  255. // scopeID, x, y);
  256. }
  257. else
  258. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
  259. scopeID, x, y);
  260. }
  261. else
  262. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
  263. return rinfo;
  264. }
  265. public GridRegion GetRegionByName(UUID scopeID, string regionName)
  266. {
  267. Dictionary<string, object> sendData = new Dictionary<string, object>();
  268. sendData["SCOPEID"] = scopeID.ToString();
  269. sendData["NAME"] = regionName;
  270. sendData["METHOD"] = "get_region_by_name";
  271. string reply = string.Empty;
  272. try
  273. {
  274. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  275. m_ServerURI + "/grid",
  276. ServerUtils.BuildQueryString(sendData));
  277. }
  278. catch (Exception e)
  279. {
  280. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  281. return null;
  282. }
  283. GridRegion rinfo = null;
  284. if (reply != string.Empty)
  285. {
  286. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  287. if ((replyData != null) && (replyData["result"] != null))
  288. {
  289. if (replyData["result"] is Dictionary<string, object>)
  290. rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
  291. }
  292. else
  293. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
  294. scopeID, regionName);
  295. }
  296. else
  297. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
  298. return rinfo;
  299. }
  300. public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
  301. {
  302. Dictionary<string, object> sendData = new Dictionary<string, object>();
  303. sendData["SCOPEID"] = scopeID.ToString();
  304. sendData["NAME"] = name;
  305. sendData["MAX"] = maxNumber.ToString();
  306. sendData["METHOD"] = "get_regions_by_name";
  307. List<GridRegion> rinfos = new List<GridRegion>();
  308. string reply = string.Empty;
  309. try
  310. {
  311. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  312. m_ServerURI + "/grid",
  313. ServerUtils.BuildQueryString(sendData));
  314. }
  315. catch (Exception e)
  316. {
  317. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  318. return rinfos;
  319. }
  320. if (reply != string.Empty)
  321. {
  322. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  323. if (replyData != null)
  324. {
  325. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  326. foreach (object r in rinfosList)
  327. {
  328. if (r is Dictionary<string, object>)
  329. {
  330. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  331. rinfos.Add(rinfo);
  332. }
  333. }
  334. }
  335. else
  336. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
  337. scopeID, name, maxNumber);
  338. }
  339. else
  340. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
  341. return rinfos;
  342. }
  343. public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
  344. {
  345. Dictionary<string, object> sendData = new Dictionary<string, object>();
  346. sendData["SCOPEID"] = scopeID.ToString();
  347. sendData["XMIN"] = xmin.ToString();
  348. sendData["XMAX"] = xmax.ToString();
  349. sendData["YMIN"] = ymin.ToString();
  350. sendData["YMAX"] = ymax.ToString();
  351. sendData["METHOD"] = "get_region_range";
  352. List<GridRegion> rinfos = new List<GridRegion>();
  353. string reply = string.Empty;
  354. try
  355. {
  356. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  357. m_ServerURI + "/grid",
  358. ServerUtils.BuildQueryString(sendData));
  359. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  360. }
  361. catch (Exception e)
  362. {
  363. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  364. return rinfos;
  365. }
  366. if (reply != string.Empty)
  367. {
  368. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  369. if (replyData != null)
  370. {
  371. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  372. foreach (object r in rinfosList)
  373. {
  374. if (r is Dictionary<string, object>)
  375. {
  376. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  377. rinfos.Add(rinfo);
  378. }
  379. }
  380. }
  381. else
  382. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
  383. scopeID, xmin, xmax, ymin, ymax);
  384. }
  385. else
  386. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
  387. return rinfos;
  388. }
  389. public List<GridRegion> GetDefaultRegions(UUID scopeID)
  390. {
  391. Dictionary<string, object> sendData = new Dictionary<string, object>();
  392. sendData["SCOPEID"] = scopeID.ToString();
  393. sendData["METHOD"] = "get_default_regions";
  394. List<GridRegion> rinfos = new List<GridRegion>();
  395. string reply = string.Empty;
  396. try
  397. {
  398. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  399. m_ServerURI + "/grid",
  400. ServerUtils.BuildQueryString(sendData));
  401. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  402. }
  403. catch (Exception e)
  404. {
  405. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  406. return rinfos;
  407. }
  408. if (reply != string.Empty)
  409. {
  410. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  411. if (replyData != null)
  412. {
  413. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  414. foreach (object r in rinfosList)
  415. {
  416. if (r is Dictionary<string, object>)
  417. {
  418. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  419. rinfos.Add(rinfo);
  420. }
  421. }
  422. }
  423. else
  424. m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions {0} received null response",
  425. scopeID);
  426. }
  427. else
  428. m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions received null reply");
  429. return rinfos;
  430. }
  431. public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
  432. {
  433. Dictionary<string, object> sendData = new Dictionary<string, object>();
  434. sendData["SCOPEID"] = scopeID.ToString();
  435. sendData["X"] = x.ToString();
  436. sendData["Y"] = y.ToString();
  437. sendData["METHOD"] = "get_fallback_regions";
  438. List<GridRegion> rinfos = new List<GridRegion>();
  439. string reply = string.Empty;
  440. try
  441. {
  442. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  443. m_ServerURI + "/grid",
  444. ServerUtils.BuildQueryString(sendData));
  445. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  446. }
  447. catch (Exception e)
  448. {
  449. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  450. return rinfos;
  451. }
  452. if (reply != string.Empty)
  453. {
  454. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  455. if (replyData != null)
  456. {
  457. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  458. foreach (object r in rinfosList)
  459. {
  460. if (r is Dictionary<string, object>)
  461. {
  462. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  463. rinfos.Add(rinfo);
  464. }
  465. }
  466. }
  467. else
  468. m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions {0}, {1}-{2} received null response",
  469. scopeID, x, y);
  470. }
  471. else
  472. m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions received null reply");
  473. return rinfos;
  474. }
  475. public List<GridRegion> GetHyperlinks(UUID scopeID)
  476. {
  477. Dictionary<string, object> sendData = new Dictionary<string, object>();
  478. sendData["SCOPEID"] = scopeID.ToString();
  479. sendData["METHOD"] = "get_hyperlinks";
  480. List<GridRegion> rinfos = new List<GridRegion>();
  481. string reply = string.Empty;
  482. try
  483. {
  484. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  485. m_ServerURI + "/grid",
  486. ServerUtils.BuildQueryString(sendData));
  487. //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
  488. }
  489. catch (Exception e)
  490. {
  491. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  492. return rinfos;
  493. }
  494. if (reply != string.Empty)
  495. {
  496. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  497. if (replyData != null)
  498. {
  499. Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
  500. foreach (object r in rinfosList)
  501. {
  502. if (r is Dictionary<string, object>)
  503. {
  504. GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
  505. rinfos.Add(rinfo);
  506. }
  507. }
  508. }
  509. else
  510. m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response",
  511. scopeID);
  512. }
  513. else
  514. m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply");
  515. return rinfos;
  516. }
  517. public int GetRegionFlags(UUID scopeID, UUID regionID)
  518. {
  519. Dictionary<string, object> sendData = new Dictionary<string, object>();
  520. sendData["SCOPEID"] = scopeID.ToString();
  521. sendData["REGIONID"] = regionID.ToString();
  522. sendData["METHOD"] = "get_region_flags";
  523. string reply = string.Empty;
  524. try
  525. {
  526. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  527. m_ServerURI + "/grid",
  528. ServerUtils.BuildQueryString(sendData));
  529. }
  530. catch (Exception e)
  531. {
  532. m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
  533. return -1;
  534. }
  535. int flags = -1;
  536. if (reply != string.Empty)
  537. {
  538. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
  539. if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
  540. {
  541. Int32.TryParse((string)replyData["result"], out flags);
  542. //else
  543. // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received wrong type {2}",
  544. // scopeID, regionID, replyData["result"].GetType());
  545. }
  546. else
  547. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received null response",
  548. scopeID, regionID);
  549. }
  550. else
  551. m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags received null reply");
  552. return flags;
  553. }
  554. #endregion
  555. }
  556. }