OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
GridServicesConnector.cs
Go to the documentation of this file.
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 
28 using log4net;
29 using System;
30 using System.Collections.Generic;
31 using System.IO;
32 using System.Reflection;
33 using Nini.Config;
34 using OpenSim.Framework;
35 
36 using OpenSim.Framework.ServiceAuth;
37 using OpenSim.Services.Interfaces;
39 using OpenSim.Server.Base;
40 using OpenMetaverse;
41 
42 namespace OpenSim.Services.Connectors
43 {
45  {
46  private static readonly ILog m_log =
47  LogManager.GetLogger(
48  MethodBase.GetCurrentMethod().DeclaringType);
49 
50  private string m_ServerURI = String.Empty;
51 
52  private ExpiringCache<ulong, GridRegion> m_regionCache =
53  new ExpiringCache<ulong, GridRegion>();
54 
56  {
57  }
58 
59  public GridServicesConnector(string serverURI)
60  {
61  m_ServerURI = serverURI.TrimEnd('/');
62  }
63 
64  public GridServicesConnector(IConfigSource source)
65  {
66  Initialise(source);
67  }
68 
69  public virtual void Initialise(IConfigSource source)
70  {
71  IConfig gridConfig = source.Configs["GridService"];
72  if (gridConfig == null)
73  {
74  m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
75  throw new Exception("Grid connector init error");
76  }
77 
78  string serviceURI = gridConfig.GetString("GridServerURI",
79  String.Empty);
80 
81  if (serviceURI == String.Empty)
82  {
83  m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
84  throw new Exception("Grid connector init error");
85  }
86  m_ServerURI = serviceURI;
87 
88  base.Initialise(source, "GridService");
89  }
90 
91 
92  #region IGridService
93 
94  public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
95  {
96  Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
97  Dictionary<string, object> sendData = new Dictionary<string,object>();
98  foreach (KeyValuePair<string, object> kvp in rinfo)
99  sendData[kvp.Key] = (string)kvp.Value;
100 
101  sendData["SCOPEID"] = scopeID.ToString();
102  sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
103  sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
104  sendData["METHOD"] = "register";
105 
106  string reqString = ServerUtils.BuildQueryString(sendData);
107  string uri = m_ServerURI + "/grid";
108  // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
109  try
110  {
111  string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
112  if (reply != string.Empty)
113  {
114  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
115 
116  if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
117  {
118  return String.Empty;
119  }
120  else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
121  {
122  m_log.ErrorFormat(
123  "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);
124 
125  return replyData["Message"].ToString();
126  }
127  else if (!replyData.ContainsKey("Result"))
128  {
129  m_log.ErrorFormat(
130  "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
131  }
132  else
133  {
134  m_log.ErrorFormat(
135  "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);
136 
137  return "Unexpected result " + replyData["Result"].ToString();
138  }
139  }
140  else
141  {
142  m_log.ErrorFormat(
143  "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
144  }
145  }
146  catch (Exception e)
147  {
148  m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
149  }
150 
151  return string.Format("Error communicating with the grid service at {0}", uri);
152  }
153 
154  public bool DeregisterRegion(UUID regionID)
155  {
156  Dictionary<string, object> sendData = new Dictionary<string, object>();
157 
158  sendData["REGIONID"] = regionID.ToString();
159 
160  sendData["METHOD"] = "deregister";
161 
162  string uri = m_ServerURI + "/grid";
163 
164  try
165  {
166  string reply
167  = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
168 
169  if (reply != string.Empty)
170  {
171  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
172 
173  if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
174  return true;
175  }
176  else
177  m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
178  }
179  catch (Exception e)
180  {
181  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
182  }
183 
184  return false;
185  }
186 
187  public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
188  {
189  Dictionary<string, object> sendData = new Dictionary<string, object>();
190 
191  sendData["SCOPEID"] = scopeID.ToString();
192  sendData["REGIONID"] = regionID.ToString();
193 
194  sendData["METHOD"] = "get_neighbours";
195 
196  List<GridRegion> rinfos = new List<GridRegion>();
197 
198  string reqString = ServerUtils.BuildQueryString(sendData);
199  string reply = string.Empty;
200  string uri = m_ServerURI + "/grid";
201 
202  try
203  {
204  reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
205  }
206  catch (Exception e)
207  {
208  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
209  return rinfos;
210  }
211 
212  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
213 
214  if (replyData != null)
215  {
216  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
217  //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
218  foreach (object r in rinfosList)
219  {
220  if (r is Dictionary<string, object>)
221  {
222  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
223  rinfos.Add(rinfo);
224  }
225  }
226  }
227  else
228  m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
229  scopeID, regionID);
230 
231  return rinfos;
232  }
233 
234  public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
235  {
236  Dictionary<string, object> sendData = new Dictionary<string, object>();
237 
238  sendData["SCOPEID"] = scopeID.ToString();
239  sendData["REGIONID"] = regionID.ToString();
240 
241  sendData["METHOD"] = "get_region_by_uuid";
242 
243  string reply = string.Empty;
244  string uri = m_ServerURI + "/grid";
245  try
246  {
247  reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
248  }
249  catch (Exception e)
250  {
251  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
252  return null;
253  }
254 
255  GridRegion rinfo = null;
256 
257  if (reply != string.Empty)
258  {
259  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
260 
261  if ((replyData != null) && (replyData["result"] != null))
262  {
263  if (replyData["result"] is Dictionary<string, object>)
264  rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
265  //else
266  // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
267  // scopeID, regionID);
268  }
269  else
270  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
271  scopeID, regionID);
272  }
273  else
274  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
275 
276  return rinfo;
277  }
278 
279  public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
280  {
281  ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y);
282 
283  if (m_regionCache.Contains(regionHandle))
284  return (GridRegion)m_regionCache[regionHandle];
285 
286  Dictionary<string, object> sendData = new Dictionary<string, object>();
287 
288  sendData["SCOPEID"] = scopeID.ToString();
289  sendData["X"] = x.ToString();
290  sendData["Y"] = y.ToString();
291 
292  sendData["METHOD"] = "get_region_by_position";
293  string reply = string.Empty;
294  string uri = m_ServerURI + "/grid";
295  try
296  {
297  reply = SynchronousRestFormsRequester.MakeRequest("POST",
298  uri,
299  ServerUtils.BuildQueryString(sendData), m_Auth);
300  }
301  catch (Exception e)
302  {
303  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
304  return null;
305  }
306 
307  GridRegion rinfo = null;
308  if (reply != string.Empty)
309  {
310  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
311 
312  if ((replyData != null) && (replyData["result"] != null))
313  {
314  if (replyData["result"] is Dictionary<string, object>)
315  rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
316  //else
317  // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
318  // scopeID, x, y);
319  }
320  else
321  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
322  scopeID, x, y);
323  }
324  else
325  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
326 
327  m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600));
328 
329  return rinfo;
330  }
331 
332  public GridRegion GetRegionByName(UUID scopeID, string regionName)
333  {
334  Dictionary<string, object> sendData = new Dictionary<string, object>();
335 
336  sendData["SCOPEID"] = scopeID.ToString();
337  sendData["NAME"] = regionName;
338 
339  sendData["METHOD"] = "get_region_by_name";
340  string reply = string.Empty;
341  string uri = m_ServerURI + "/grid";
342  try
343  {
344  reply = SynchronousRestFormsRequester.MakeRequest("POST",
345  uri,
346  ServerUtils.BuildQueryString(sendData), m_Auth);
347  }
348  catch (Exception e)
349  {
350  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
351  return null;
352  }
353 
354  GridRegion rinfo = null;
355  if (reply != string.Empty)
356  {
357  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
358 
359  if ((replyData != null) && (replyData["result"] != null))
360  {
361  if (replyData["result"] is Dictionary<string, object>)
362  rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
363  }
364  else
365  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
366  scopeID, regionName);
367  }
368  else
369  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
370 
371  return rinfo;
372  }
373 
374  public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
375  {
376  Dictionary<string, object> sendData = new Dictionary<string, object>();
377 
378  sendData["SCOPEID"] = scopeID.ToString();
379  sendData["NAME"] = name;
380  sendData["MAX"] = maxNumber.ToString();
381 
382  sendData["METHOD"] = "get_regions_by_name";
383  List<GridRegion> rinfos = new List<GridRegion>();
384  string reply = string.Empty;
385  string uri = m_ServerURI + "/grid";
386  try
387  {
388  reply = SynchronousRestFormsRequester.MakeRequest("POST",
389  uri,
390  ServerUtils.BuildQueryString(sendData), m_Auth);
391  }
392  catch (Exception e)
393  {
394  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
395  return rinfos;
396  }
397 
398  if (reply != string.Empty)
399  {
400  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
401 
402  if (replyData != null)
403  {
404  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
405  foreach (object r in rinfosList)
406  {
407  if (r is Dictionary<string, object>)
408  {
409  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
410  rinfos.Add(rinfo);
411  }
412  }
413  }
414  else
415  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
416  scopeID, name, maxNumber);
417  }
418  else
419  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
420 
421  return rinfos;
422  }
423 
424  public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
425  {
426  Dictionary<string, object> sendData = new Dictionary<string, object>();
427 
428  sendData["SCOPEID"] = scopeID.ToString();
429  sendData["XMIN"] = xmin.ToString();
430  sendData["XMAX"] = xmax.ToString();
431  sendData["YMIN"] = ymin.ToString();
432  sendData["YMAX"] = ymax.ToString();
433 
434  sendData["METHOD"] = "get_region_range";
435 
436  List<GridRegion> rinfos = new List<GridRegion>();
437  string reply = string.Empty;
438  string uri = m_ServerURI + "/grid";
439 
440  try
441  {
442  reply = SynchronousRestFormsRequester.MakeRequest("POST",
443  uri,
444  ServerUtils.BuildQueryString(sendData), m_Auth);
445 
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 at {0}: {1}", uri, e.Message);
451  return rinfos;
452  }
453 
454  if (reply != string.Empty)
455  {
456  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
457 
458  if (replyData != null)
459  {
460  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
461  foreach (object r in rinfosList)
462  {
463  if (r is Dictionary<string, object>)
464  {
465  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
466  rinfos.Add(rinfo);
467  }
468  }
469  }
470  else
471  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
472  scopeID, xmin, xmax, ymin, ymax);
473  }
474  else
475  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
476 
477  return rinfos;
478  }
479 
480  public List<GridRegion> GetDefaultRegions(UUID scopeID)
481  {
482  Dictionary<string, object> sendData = new Dictionary<string, object>();
483 
484  sendData["SCOPEID"] = scopeID.ToString();
485 
486  sendData["METHOD"] = "get_default_regions";
487 
488  List<GridRegion> rinfos = new List<GridRegion>();
489  string reply = string.Empty;
490  string uri = m_ServerURI + "/grid";
491  try
492  {
493  reply = SynchronousRestFormsRequester.MakeRequest("POST",
494  uri,
495  ServerUtils.BuildQueryString(sendData), m_Auth);
496 
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 
505  if (reply != string.Empty)
506  {
507  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
508 
509  if (replyData != null)
510  {
511  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
512  foreach (object r in rinfosList)
513  {
514  if (r is Dictionary<string, object>)
515  {
516  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
517  rinfos.Add(rinfo);
518  }
519  }
520  }
521  else
522  m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions {0} received null response",
523  scopeID);
524  }
525  else
526  m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions received null reply");
527 
528  return rinfos;
529  }
530 
531  public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
532  {
533  Dictionary<string, object> sendData = new Dictionary<string, object>();
534 
535  sendData["SCOPEID"] = scopeID.ToString();
536 
537  sendData["METHOD"] = "get_default_hypergrid_regions";
538 
539  List<GridRegion> rinfos = new List<GridRegion>();
540  string reply = string.Empty;
541  string uri = m_ServerURI + "/grid";
542  try
543  {
544  reply = SynchronousRestFormsRequester.MakeRequest("POST",
545  uri,
546  ServerUtils.BuildQueryString(sendData), m_Auth);
547 
548  //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
549  }
550  catch (Exception e)
551  {
552  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
553  return rinfos;
554  }
555 
556  if (reply != string.Empty)
557  {
558  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
559 
560  if (replyData != null)
561  {
562  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
563  foreach (object r in rinfosList)
564  {
565  if (r is Dictionary<string, object>)
566  {
567  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
568  rinfos.Add(rinfo);
569  }
570  }
571  }
572  else
573  m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions {0} received null response",
574  scopeID);
575  }
576  else
577  m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions received null reply");
578 
579  return rinfos;
580  }
581 
582  public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
583  {
584  Dictionary<string, object> sendData = new Dictionary<string, object>();
585 
586  sendData["SCOPEID"] = scopeID.ToString();
587  sendData["X"] = x.ToString();
588  sendData["Y"] = y.ToString();
589 
590  sendData["METHOD"] = "get_fallback_regions";
591 
592  List<GridRegion> rinfos = new List<GridRegion>();
593  string reply = string.Empty;
594  string uri = m_ServerURI + "/grid";
595  try
596  {
597  reply = SynchronousRestFormsRequester.MakeRequest("POST",
598  uri,
599  ServerUtils.BuildQueryString(sendData), m_Auth);
600 
601  //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
602  }
603  catch (Exception e)
604  {
605  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
606  return rinfos;
607  }
608 
609  if (reply != string.Empty)
610  {
611  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
612 
613  if (replyData != null)
614  {
615  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
616  foreach (object r in rinfosList)
617  {
618  if (r is Dictionary<string, object>)
619  {
620  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
621  rinfos.Add(rinfo);
622  }
623  }
624  }
625  else
626  m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions {0}, {1}-{2} received null response",
627  scopeID, x, y);
628  }
629  else
630  m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions received null reply");
631 
632  return rinfos;
633  }
634 
635  public List<GridRegion> GetHyperlinks(UUID scopeID)
636  {
637  Dictionary<string, object> sendData = new Dictionary<string, object>();
638 
639  sendData["SCOPEID"] = scopeID.ToString();
640 
641  sendData["METHOD"] = "get_hyperlinks";
642 
643  List<GridRegion> rinfos = new List<GridRegion>();
644  string reply = string.Empty;
645  string uri = m_ServerURI + "/grid";
646  try
647  {
648  reply = SynchronousRestFormsRequester.MakeRequest("POST",
649  uri,
650  ServerUtils.BuildQueryString(sendData), m_Auth);
651 
652  //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
653  }
654  catch (Exception e)
655  {
656  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
657  return rinfos;
658  }
659 
660  if (reply != string.Empty)
661  {
662  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
663 
664  if (replyData != null)
665  {
666  Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
667  foreach (object r in rinfosList)
668  {
669  if (r is Dictionary<string, object>)
670  {
671  GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
672  rinfos.Add(rinfo);
673  }
674  }
675  }
676  else
677  m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response",
678  scopeID);
679  }
680  else
681  m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply");
682 
683  return rinfos;
684  }
685 
686  public int GetRegionFlags(UUID scopeID, UUID regionID)
687  {
688  Dictionary<string, object> sendData = new Dictionary<string, object>();
689 
690  sendData["SCOPEID"] = scopeID.ToString();
691  sendData["REGIONID"] = regionID.ToString();
692 
693  sendData["METHOD"] = "get_region_flags";
694 
695  string reply = string.Empty;
696  string uri = m_ServerURI + "/grid";
697  try
698  {
699  reply = SynchronousRestFormsRequester.MakeRequest("POST",
700  uri,
701  ServerUtils.BuildQueryString(sendData), m_Auth);
702  }
703  catch (Exception e)
704  {
705  m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
706  return -1;
707  }
708 
709  int flags = -1;
710 
711  if (reply != string.Empty)
712  {
713  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
714 
715  if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
716  {
717  Int32.TryParse((string)replyData["result"], out flags);
718  //else
719  // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received wrong type {2}",
720  // scopeID, regionID, replyData["result"].GetType());
721  }
722  else
723  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received null response",
724  scopeID, regionID);
725  }
726  else
727  m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags received null reply");
728 
729  return flags;
730  }
731 
732  public Dictionary<string, object> GetExtraFeatures()
733  {
734  Dictionary<string, object> sendData = new Dictionary<string, object>();
735  Dictionary<string, object> extraFeatures = new Dictionary<string, object>();
736 
737  sendData["METHOD"] = "get_grid_extra_features";
738 
739  string reply = string.Empty;
740  string uri = m_ServerURI + "/grid";
741 
742  try
743  {
744  reply = SynchronousRestFormsRequester.MakeRequest("POST",
745  uri,
746  ServerUtils.BuildQueryString(sendData), m_Auth);
747  }
748  catch (Exception e)
749  {
750  m_log.DebugFormat("[GRID CONNECTOR]: GetExtraFeatures - Exception when contacting grid server at {0}: {1}", uri, e.Message);
751  return extraFeatures;
752  }
753 
754  if (reply != string.Empty)
755  {
756  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
757 
758  if ((replyData != null) && replyData.Count > 0)
759  {
760  foreach (string key in replyData.Keys)
761  {
762  extraFeatures[key] = replyData[key].ToString();
763  }
764  }
765  }
766  else
767  m_log.DebugFormat("[GRID CONNECTOR]: GetExtraServiceURLs received null reply");
768 
769  return extraFeatures;
770  }
771  #endregion
772 
773  }
774 }
List< GridRegion > GetDefaultHypergridRegions(UUID scopeID)
bool DeregisterRegion(UUID regionID)
Deregister a region with the grid service.
List< GridRegion > GetFallbackRegions(UUID scopeID, int x, int y)
OpenSim.Services.Interfaces.GridRegion GridRegion
string RegisterRegion(UUID scopeID, GridRegion regionInfo)
Register a region with the grid service.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
Definition: ICM_Api.cs:31
List< GridRegion > GetNeighbours(UUID scopeID, UUID regionID)
Get information about the regions neighbouring the given co-ordinates (in meters).
int GetRegionFlags(UUID scopeID, UUID regionID)
Get internal OpenSimulator region flags.
List< GridRegion > GetRegionsByName(UUID scopeID, string name, int maxNumber)
Get information about regions starting with the provided name.
List< GridRegion > GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
Get the region at the given position (in meters)
GridRegion GetRegionByName(UUID scopeID, string regionName)
Get information about a region which exactly matches the name given.
GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)