OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
GridServerPostHandler.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 Nini.Config;
29 using log4net;
30 using System;
31 using System.Reflection;
32 using System.IO;
33 using System.Net;
34 using System.Text;
35 using System.Text.RegularExpressions;
36 using System.Xml;
37 using System.Xml.Serialization;
38 using System.Collections.Generic;
39 using OpenSim.Server.Base;
40 using OpenSim.Services.Interfaces;
42 using OpenSim.Framework;
43 using OpenSim.Framework.ServiceAuth;
44 using OpenSim.Framework.Servers.HttpServer;
45 using OpenMetaverse;
46 
47 namespace OpenSim.Server.Handlers.Grid
48 {
50  {
51  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 
53 #pragma warning disable 414
54  private static string LogHeader = "[GRID HANDLER]";
55 #pragma warning restore 414
56 
57  private IGridService m_GridService;
58 
60  base("POST", "/grid", auth)
61  {
62  m_GridService = service;
63  }
64 
65  protected override byte[] ProcessRequest(string path, Stream requestData,
66  IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
67  {
68  StreamReader sr = new StreamReader(requestData);
69  string body = sr.ReadToEnd();
70  sr.Close();
71  body = body.Trim();
72 
73  //m_log.DebugFormat("[XXX]: query String: {0}", body);
74 
75  try
76  {
77  Dictionary<string, object> request =
78  ServerUtils.ParseQueryString(body);
79 
80  if (!request.ContainsKey("METHOD"))
81  return FailureResult();
82 
83  string method = request["METHOD"].ToString();
84 
85  switch (method)
86  {
87  case "register":
88  return Register(request);
89 
90  case "deregister":
91  return Deregister(request);
92 
93  case "get_neighbours":
94  return GetNeighbours(request);
95 
96  case "get_region_by_uuid":
97  return GetRegionByUUID(request);
98 
99  case "get_region_by_position":
100  return GetRegionByPosition(request);
101 
102  case "get_region_by_name":
103  return GetRegionByName(request);
104 
105  case "get_regions_by_name":
106  return GetRegionsByName(request);
107 
108  case "get_region_range":
109  return GetRegionRange(request);
110 
111  case "get_default_regions":
112  return GetDefaultRegions(request);
113 
114  case "get_default_hypergrid_regions":
115  return GetDefaultHypergridRegions(request);
116 
117  case "get_fallback_regions":
118  return GetFallbackRegions(request);
119 
120  case "get_hyperlinks":
121  return GetHyperlinks(request);
122 
123  case "get_region_flags":
124  return GetRegionFlags(request);
125 
126  case "get_grid_extra_features":
127  return GetGridExtraFeatures(request);
128  }
129 
130  m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method);
131  }
132  catch (Exception e)
133  {
134  m_log.ErrorFormat("[GRID HANDLER]: Exception {0} {1}", e.Message, e.StackTrace);
135  }
136 
137  return FailureResult();
138  }
139 
140  #region Method-specific handlers
141 
142  byte[] Register(Dictionary<string, object> request)
143  {
144  UUID scopeID = UUID.Zero;
145  if (request.ContainsKey("SCOPEID"))
146  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
147  else
148  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
149 
150  int versionNumberMin = 0, versionNumberMax = 0;
151  if (request.ContainsKey("VERSIONMIN"))
152  Int32.TryParse(request["VERSIONMIN"].ToString(), out versionNumberMin);
153  else
154  m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region");
155 
156  if (request.ContainsKey("VERSIONMAX"))
157  Int32.TryParse(request["VERSIONMAX"].ToString(), out versionNumberMax);
158  else
159  m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region");
160 
161  // Check the protocol version
162  // This is how it works:
163  // Example 1:
164  // Client: [0 0]
165  // Server: [1 1]
166  // ==> fail
167  // Example 2:
168  // Client: [1 1]
169  // Server: [0 0]
170  // ==> fail
171  // Example 3:
172  // Client: [0 1]
173  // Server: [1 1]
174  // ==> success
175  // Example 4:
176  // Client: [1 1]
177  // Server: [0 1]
178  // ==> success
179  if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax || versionNumberMax < ProtocolVersions.ServerProtocolVersionMin))
180  {
181  // Can't do, there is no overlap in the acceptable ranges
182  return FailureResult();
183  }
184 
185  Dictionary<string, object> rinfoData = new Dictionary<string, object>();
186  GridRegion rinfo = null;
187  try
188  {
189  foreach (KeyValuePair<string, object> kvp in request)
190  rinfoData[kvp.Key] = kvp.Value.ToString();
191  rinfo = new GridRegion(rinfoData);
192  }
193  catch (Exception e)
194  {
195  m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e);
196  }
197 
198  string result = "Error communicating with grid service";
199  if (rinfo != null)
200  result = m_GridService.RegisterRegion(scopeID, rinfo);
201 
202  if (result == String.Empty)
203  return SuccessResult();
204  else
205  return FailureResult(result);
206  }
207 
208  byte[] Deregister(Dictionary<string, object> request)
209  {
210  UUID regionID = UUID.Zero;
211  if (request.ContainsKey("REGIONID"))
212  UUID.TryParse(request["REGIONID"].ToString(), out regionID);
213  else
214  m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region");
215 
216  bool result = m_GridService.DeregisterRegion(regionID);
217 
218  if (result)
219  return SuccessResult();
220  else
221  return FailureResult();
222 
223  }
224 
225  byte[] GetNeighbours(Dictionary<string, object> request)
226  {
227  UUID scopeID = UUID.Zero;
228  if (request.ContainsKey("SCOPEID"))
229  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
230  else
231  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
232 
233  UUID regionID = UUID.Zero;
234  if (request.ContainsKey("REGIONID"))
235  UUID.TryParse(request["REGIONID"].ToString(), out regionID);
236  else
237  m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
238 
239  List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
240  //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
241 
242  Dictionary<string, object> result = new Dictionary<string, object>();
243  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
244  result["result"] = "null";
245  else
246  {
247  int i = 0;
248  foreach (GridRegion rinfo in rinfos)
249  {
250  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
251  result["region" + i] = rinfoDict;
252  i++;
253  }
254  }
255 
256  string xmlString = ServerUtils.BuildXmlResponse(result);
257 
258  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
259  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
260  }
261 
262  byte[] GetRegionByUUID(Dictionary<string, object> request)
263  {
264  UUID scopeID = UUID.Zero;
265  if (request.ContainsKey("SCOPEID"))
266  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
267  else
268  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
269 
270  UUID regionID = UUID.Zero;
271  if (request.ContainsKey("REGIONID"))
272  UUID.TryParse(request["REGIONID"].ToString(), out regionID);
273  else
274  m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
275 
276  GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
277  //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
278 
279  Dictionary<string, object> result = new Dictionary<string, object>();
280  if (rinfo == null)
281  result["result"] = "null";
282  else
283  result["result"] = rinfo.ToKeyValuePairs();
284 
285  string xmlString = ServerUtils.BuildXmlResponse(result);
286 
287  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
288  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
289  }
290 
291  byte[] GetRegionByPosition(Dictionary<string, object> request)
292  {
293  UUID scopeID = UUID.Zero;
294  if (request.ContainsKey("SCOPEID"))
295  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
296  else
297  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
298 
299  int x = 0, y = 0;
300  if (request.ContainsKey("X"))
301  Int32.TryParse(request["X"].ToString(), out x);
302  else
303  m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
304  if (request.ContainsKey("Y"))
305  Int32.TryParse(request["Y"].ToString(), out y);
306  else
307  m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
308 
309  // m_log.DebugFormat("{0} GetRegionByPosition: loc=<{1},{2}>", LogHeader, x, y);
310  GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
311 
312  Dictionary<string, object> result = new Dictionary<string, object>();
313  if (rinfo == null)
314  result["result"] = "null";
315  else
316  result["result"] = rinfo.ToKeyValuePairs();
317 
318  string xmlString = ServerUtils.BuildXmlResponse(result);
319 
320  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
321  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
322  }
323 
324  byte[] GetRegionByName(Dictionary<string, object> request)
325  {
326  UUID scopeID = UUID.Zero;
327  if (request.ContainsKey("SCOPEID"))
328  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
329  else
330  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
331 
332  string regionName = string.Empty;
333  if (request.ContainsKey("NAME"))
334  regionName = request["NAME"].ToString();
335  else
336  m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
337 
338  GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
339  //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
340 
341  Dictionary<string, object> result = new Dictionary<string, object>();
342  if (rinfo == null)
343  result["result"] = "null";
344  else
345  result["result"] = rinfo.ToKeyValuePairs();
346 
347  string xmlString = ServerUtils.BuildXmlResponse(result);
348 
349  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
350  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
351  }
352 
353  byte[] GetRegionsByName(Dictionary<string, object> request)
354  {
355  UUID scopeID = UUID.Zero;
356  if (request.ContainsKey("SCOPEID"))
357  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
358  else
359  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
360 
361  string regionName = string.Empty;
362  if (request.ContainsKey("NAME"))
363  regionName = request["NAME"].ToString();
364  else
365  m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
366 
367  int max = 0;
368  if (request.ContainsKey("MAX"))
369  Int32.TryParse(request["MAX"].ToString(), out max);
370  else
371  m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
372 
373  List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
374  //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
375 
376  Dictionary<string, object> result = new Dictionary<string, object>();
377  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
378  result["result"] = "null";
379  else
380  {
381  int i = 0;
382  foreach (GridRegion rinfo in rinfos)
383  {
384  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
385  result["region" + i] = rinfoDict;
386  i++;
387  }
388  }
389 
390  string xmlString = ServerUtils.BuildXmlResponse(result);
391 
392  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
393  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
394  }
395 
396  byte[] GetRegionRange(Dictionary<string, object> request)
397  {
398  //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
399  UUID scopeID = UUID.Zero;
400  if (request.ContainsKey("SCOPEID"))
401  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
402  else
403  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
404 
405  int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
406  if (request.ContainsKey("XMIN"))
407  Int32.TryParse(request["XMIN"].ToString(), out xmin);
408  else
409  m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
410  if (request.ContainsKey("XMAX"))
411  Int32.TryParse(request["XMAX"].ToString(), out xmax);
412  else
413  m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
414  if (request.ContainsKey("YMIN"))
415  Int32.TryParse(request["YMIN"].ToString(), out ymin);
416  else
417  m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
418  if (request.ContainsKey("YMAX"))
419  Int32.TryParse(request["YMAX"].ToString(), out ymax);
420  else
421  m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
422 
423 
424  List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
425 
426  Dictionary<string, object> result = new Dictionary<string, object>();
427  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
428  result["result"] = "null";
429  else
430  {
431  int i = 0;
432  foreach (GridRegion rinfo in rinfos)
433  {
434  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
435  result["region" + i] = rinfoDict;
436  i++;
437  }
438  }
439  string xmlString = ServerUtils.BuildXmlResponse(result);
440 
441  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
442  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
443  }
444 
445  byte[] GetDefaultRegions(Dictionary<string, object> request)
446  {
447  //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions");
448  UUID scopeID = UUID.Zero;
449  if (request.ContainsKey("SCOPEID"))
450  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
451  else
452  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
453 
454  List<GridRegion> rinfos = m_GridService.GetDefaultRegions(scopeID);
455 
456  Dictionary<string, object> result = new Dictionary<string, object>();
457  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
458  result["result"] = "null";
459  else
460  {
461  int i = 0;
462  foreach (GridRegion rinfo in rinfos)
463  {
464  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
465  result["region" + i] = rinfoDict;
466  i++;
467  }
468  }
469  string xmlString = ServerUtils.BuildXmlResponse(result);
470 
471  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
472  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
473  }
474 
475  byte[] GetDefaultHypergridRegions(Dictionary<string, object> request)
476  {
477  //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions");
478  UUID scopeID = UUID.Zero;
479  if (request.ContainsKey("SCOPEID"))
480  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
481  else
482  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
483 
484  List<GridRegion> rinfos = m_GridService.GetDefaultHypergridRegions(scopeID);
485 
486  Dictionary<string, object> result = new Dictionary<string, object>();
487  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
488  result["result"] = "null";
489  else
490  {
491  int i = 0;
492  foreach (GridRegion rinfo in rinfos)
493  {
494  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
495  result["region" + i] = rinfoDict;
496  i++;
497  }
498  }
499  string xmlString = ServerUtils.BuildXmlResponse(result);
500 
501  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
502  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
503  }
504 
505  byte[] GetFallbackRegions(Dictionary<string, object> request)
506  {
507  //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
508  UUID scopeID = UUID.Zero;
509  if (request.ContainsKey("SCOPEID"))
510  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
511  else
512  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get fallback regions");
513 
514  int x = 0, y = 0;
515  if (request.ContainsKey("X"))
516  Int32.TryParse(request["X"].ToString(), out x);
517  else
518  m_log.WarnFormat("[GRID HANDLER]: no X in request to get fallback regions");
519  if (request.ContainsKey("Y"))
520  Int32.TryParse(request["Y"].ToString(), out y);
521  else
522  m_log.WarnFormat("[GRID HANDLER]: no Y in request to get fallback regions");
523 
524 
525  List<GridRegion> rinfos = m_GridService.GetFallbackRegions(scopeID, x, y);
526 
527  Dictionary<string, object> result = new Dictionary<string, object>();
528  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
529  result["result"] = "null";
530  else
531  {
532  int i = 0;
533  foreach (GridRegion rinfo in rinfos)
534  {
535  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
536  result["region" + i] = rinfoDict;
537  i++;
538  }
539  }
540  string xmlString = ServerUtils.BuildXmlResponse(result);
541 
542  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
543  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
544  }
545 
546  byte[] GetHyperlinks(Dictionary<string, object> request)
547  {
548  //m_log.DebugFormat("[GRID HANDLER]: GetHyperlinks");
549  UUID scopeID = UUID.Zero;
550  if (request.ContainsKey("SCOPEID"))
551  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
552  else
553  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get linked regions");
554 
555  List<GridRegion> rinfos = m_GridService.GetHyperlinks(scopeID);
556 
557  Dictionary<string, object> result = new Dictionary<string, object>();
558  if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
559  result["result"] = "null";
560  else
561  {
562  int i = 0;
563  foreach (GridRegion rinfo in rinfos)
564  {
565  Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
566  result["region" + i] = rinfoDict;
567  i++;
568  }
569  }
570  string xmlString = ServerUtils.BuildXmlResponse(result);
571 
572  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
573  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
574  }
575 
576  byte[] GetRegionFlags(Dictionary<string, object> request)
577  {
578  UUID scopeID = UUID.Zero;
579  if (request.ContainsKey("SCOPEID"))
580  UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
581  else
582  m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
583 
584  UUID regionID = UUID.Zero;
585  if (request.ContainsKey("REGIONID"))
586  UUID.TryParse(request["REGIONID"].ToString(), out regionID);
587  else
588  m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
589 
590  int flags = m_GridService.GetRegionFlags(scopeID, regionID);
591  // m_log.DebugFormat("[GRID HANDLER]: flags for region {0}: {1}", regionID, flags);
592 
593  Dictionary<string, object> result = new Dictionary<string, object>();
594  result["result"] = flags.ToString();
595 
596  string xmlString = ServerUtils.BuildXmlResponse(result);
597 
598  //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
599  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
600  }
601 
602  byte[] GetGridExtraFeatures(Dictionary<string, object> request)
603  {
604 
605  Dictionary<string, object> result = new Dictionary<string, object> ();
606  Dictionary<string, object> extraFeatures = m_GridService.GetExtraFeatures ();
607 
608  foreach (string key in extraFeatures.Keys)
609  {
610  result [key] = extraFeatures [key];
611  }
612 
613  string xmlString = ServerUtils.BuildXmlResponse(result);
614 
615  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
616  }
617 
618  #endregion
619 
620  #region Misc
621 
622  private byte[] SuccessResult()
623  {
624  XmlDocument doc = new XmlDocument();
625 
626  XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
627  "", "");
628 
629  doc.AppendChild(xmlnode);
630 
631  XmlElement rootElement = doc.CreateElement("", "ServerResponse",
632  "");
633 
634  doc.AppendChild(rootElement);
635 
636  XmlElement result = doc.CreateElement("", "Result", "");
637  result.AppendChild(doc.CreateTextNode("Success"));
638 
639  rootElement.AppendChild(result);
640 
641  return Util.DocToBytes(doc);
642  }
643 
644  private byte[] FailureResult()
645  {
646  return FailureResult(String.Empty);
647  }
648 
649  private byte[] FailureResult(string msg)
650  {
651  XmlDocument doc = new XmlDocument();
652 
653  XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
654  "", "");
655 
656  doc.AppendChild(xmlnode);
657 
658  XmlElement rootElement = doc.CreateElement("", "ServerResponse",
659  "");
660 
661  doc.AppendChild(rootElement);
662 
663  XmlElement result = doc.CreateElement("", "Result", "");
664  result.AppendChild(doc.CreateTextNode("Failure"));
665 
666  rootElement.AppendChild(result);
667 
668  XmlElement message = doc.CreateElement("", "Message", "");
669  message.AppendChild(doc.CreateTextNode(msg));
670 
671  rootElement.AppendChild(message);
672 
673  return Util.DocToBytes(doc);
674  }
675 
676  #endregion
677  }
678 }
override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
OpenSim.Services.Interfaces.GridRegion GridRegion
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
Definition: ICM_Api.cs:31
static readonly int ServerProtocolVersionMax
GridServerPostHandler(IGridService service, IServiceAuth auth)
static readonly int ServerProtocolVersionMin