GridServicesConnector.cs 26 KB

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