clockwerk-opensim-stable – Blame information for rev 1

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