OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
XInventoryInConnector.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 System;
29 using System.Reflection;
30 using System.Text;
31 using System.Xml;
32 using System.Collections.Generic;
33 using System.IO;
34 using Nini.Config;
35 using OpenSim.Framework;
36 using OpenSim.Framework.ServiceAuth;
37 using OpenSim.Server.Base;
38 using OpenSim.Services.Interfaces;
39 using OpenSim.Framework.Servers.HttpServer;
40 using OpenSim.Server.Handlers.Base;
41 using log4net;
42 using OpenMetaverse;
43 
44 using System.Threading;
45 
46 namespace OpenSim.Server.Handlers.Inventory
47 {
49  {
50  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 
52  private IInventoryService m_InventoryService;
53  private string m_ConfigName = "InventoryService";
54 
55  public XInventoryInConnector(IConfigSource config, IHttpServer server, string configName) :
56  base(config, server, configName)
57  {
58  if (configName != String.Empty)
59  m_ConfigName = configName;
60 
61  m_log.DebugFormat("[XInventoryInConnector]: Starting with config name {0}", m_ConfigName);
62 
63  IConfig serverConfig = config.Configs[m_ConfigName];
64  if (serverConfig == null)
65  throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
66 
67  string inventoryService = serverConfig.GetString("LocalServiceModule",
68  String.Empty);
69 
70  if (inventoryService == String.Empty)
71  throw new Exception("No InventoryService in config file");
72 
73  Object[] args = new Object[] { config, m_ConfigName };
74  m_InventoryService =
75  ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);
76 
77  IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
78 
79  server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth));
80  }
81  }
82 
84  {
85  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
86 
87  private IInventoryService m_InventoryService;
88 
90  base("POST", "/xinventory", auth)
91  {
92  m_InventoryService = service;
93  }
94 
95  protected override byte[] ProcessRequest(string path, Stream requestData,
96  IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
97  {
98  StreamReader sr = new StreamReader(requestData);
99  string body = sr.ReadToEnd();
100  sr.Close();
101  body = body.Trim();
102 
103  //m_log.DebugFormat("[XXX]: query String: {0}", body);
104 
105  try
106  {
107  Dictionary<string, object> request =
108  ServerUtils.ParseQueryString(body);
109 
110  if (!request.ContainsKey("METHOD"))
111  return FailureResult();
112 
113  string method = request["METHOD"].ToString();
114  request.Remove("METHOD");
115 
116  switch (method)
117  {
118  case "CREATEUSERINVENTORY":
119  return HandleCreateUserInventory(request);
120  case "GETINVENTORYSKELETON":
121  return HandleGetInventorySkeleton(request);
122  case "GETROOTFOLDER":
123  return HandleGetRootFolder(request);
124  case "GETFOLDERFORTYPE":
125  return HandleGetFolderForType(request);
126  case "GETFOLDERCONTENT":
127  return HandleGetFolderContent(request);
128  case "GETMULTIPLEFOLDERSCONTENT":
129  return HandleGetMultipleFoldersContent(request);
130  case "GETFOLDERITEMS":
131  return HandleGetFolderItems(request);
132  case "ADDFOLDER":
133  return HandleAddFolder(request);
134  case "UPDATEFOLDER":
135  return HandleUpdateFolder(request);
136  case "MOVEFOLDER":
137  return HandleMoveFolder(request);
138  case "DELETEFOLDERS":
139  return HandleDeleteFolders(request);
140  case "PURGEFOLDER":
141  return HandlePurgeFolder(request);
142  case "ADDITEM":
143  return HandleAddItem(request);
144  case "UPDATEITEM":
145  return HandleUpdateItem(request);
146  case "MOVEITEMS":
147  return HandleMoveItems(request);
148  case "DELETEITEMS":
149  return HandleDeleteItems(request);
150  case "GETITEM":
151  return HandleGetItem(request);
152  case "GETMULTIPLEITEMS":
153  return HandleGetMultipleItems(request);
154  case "GETFOLDER":
155  return HandleGetFolder(request);
156  case "GETACTIVEGESTURES":
157  return HandleGetActiveGestures(request);
158  case "GETASSETPERMISSIONS":
159  return HandleGetAssetPermissions(request);
160  }
161  m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method);
162  }
163  catch (Exception e)
164  {
165  m_log.Error(string.Format("[XINVENTORY HANDLER]: Exception {0} ", e.Message), e);
166  }
167 
168  return FailureResult();
169  }
170 
171  private byte[] FailureResult()
172  {
173  return BoolResult(false);
174  }
175 
176  private byte[] SuccessResult()
177  {
178  return BoolResult(true);
179  }
180 
181  private byte[] BoolResult(bool value)
182  {
183  XmlDocument doc = new XmlDocument();
184 
185  XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
186  "", "");
187 
188  doc.AppendChild(xmlnode);
189 
190  XmlElement rootElement = doc.CreateElement("", "ServerResponse",
191  "");
192 
193  doc.AppendChild(rootElement);
194 
195  XmlElement result = doc.CreateElement("", "RESULT", "");
196  result.AppendChild(doc.CreateTextNode(value.ToString()));
197 
198  rootElement.AppendChild(result);
199 
200  return Util.DocToBytes(doc);
201  }
202 
203  byte[] HandleCreateUserInventory(Dictionary<string,object> request)
204  {
205  Dictionary<string,object> result = new Dictionary<string,object>();
206 
207  if (!request.ContainsKey("PRINCIPAL"))
208  return FailureResult();
209 
210  if (m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString())))
211  result["RESULT"] = "True";
212  else
213  result["RESULT"] = "False";
214 
215  string xmlString = ServerUtils.BuildXmlResponse(result);
216 
217  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
218  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
219  }
220 
221  byte[] HandleGetInventorySkeleton(Dictionary<string,object> request)
222  {
223  Dictionary<string,object> result = new Dictionary<string,object>();
224 
225  if (!request.ContainsKey("PRINCIPAL"))
226  return FailureResult();
227 
228 
229  List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString()));
230 
231  Dictionary<string, object> sfolders = new Dictionary<string, object>();
232  if (folders != null)
233  {
234  int i = 0;
235  foreach (InventoryFolderBase f in folders)
236  {
237  sfolders["folder_" + i.ToString()] = EncodeFolder(f);
238  i++;
239  }
240  }
241  result["FOLDERS"] = sfolders;
242 
243  string xmlString = ServerUtils.BuildXmlResponse(result);
244 
245  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
246  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
247  }
248 
249  byte[] HandleGetRootFolder(Dictionary<string,object> request)
250  {
251  Dictionary<string,object> result = new Dictionary<string,object>();
252 
253  UUID principal = UUID.Zero;
254  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
255  InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal);
256  if (rfolder != null)
257  result["folder"] = EncodeFolder(rfolder);
258 
259  string xmlString = ServerUtils.BuildXmlResponse(result);
260 
261  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
262  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
263  }
264 
265  byte[] HandleGetFolderForType(Dictionary<string,object> request)
266  {
267  Dictionary<string,object> result = new Dictionary<string,object>();
268  UUID principal = UUID.Zero;
269  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
270  int type = 0;
271  Int32.TryParse(request["TYPE"].ToString(), out type);
272  InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (FolderType)type);
273  if (folder != null)
274  result["folder"] = EncodeFolder(folder);
275 
276  string xmlString = ServerUtils.BuildXmlResponse(result);
277 
278  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
279  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
280  }
281 
282  byte[] HandleGetFolderContent(Dictionary<string,object> request)
283  {
284  Dictionary<string,object> result = new Dictionary<string,object>();
285  UUID principal = UUID.Zero;
286  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
287  UUID folderID = UUID.Zero;
288  UUID.TryParse(request["FOLDER"].ToString(), out folderID);
289 
290  InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);
291  if (icoll != null)
292  {
293  result["FID"] = icoll.FolderID.ToString();
294  result["VERSION"] = icoll.Version.ToString();
295  Dictionary<string, object> folders = new Dictionary<string, object>();
296  int i = 0;
297  if (icoll.Folders != null)
298  {
299  foreach (InventoryFolderBase f in icoll.Folders)
300  {
301  folders["folder_" + i.ToString()] = EncodeFolder(f);
302  i++;
303  }
304  result["FOLDERS"] = folders;
305  }
306  if (icoll.Items != null)
307  {
308  i = 0;
309  Dictionary<string, object> items = new Dictionary<string, object>();
310  foreach (InventoryItemBase it in icoll.Items)
311  {
312  items["item_" + i.ToString()] = EncodeItem(it);
313  i++;
314  }
315  result["ITEMS"] = items;
316  }
317  }
318 
319  string xmlString = ServerUtils.BuildXmlResponse(result);
320 
321  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
322  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
323  }
324 
325  byte[] HandleGetMultipleFoldersContent(Dictionary<string, object> request)
326  {
327  Dictionary<string, object> resultSet = new Dictionary<string, object>();
328  UUID principal = UUID.Zero;
329  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
330  string folderIDstr = request["FOLDERS"].ToString();
331  int count = 0;
332  Int32.TryParse(request["COUNT"].ToString(), out count);
333 
334  UUID[] fids = new UUID[count];
335  string[] uuids = folderIDstr.Split(',');
336  int i = 0;
337  foreach (string id in uuids)
338  {
339  UUID fid = UUID.Zero;
340  if (UUID.TryParse(id, out fid))
341  fids[i] = fid;
342  i += 1;
343  }
344 
345  count = 0;
346  InventoryCollection[] icollList = m_InventoryService.GetMultipleFoldersContent(principal, fids);
347  if (icollList != null && icollList.Length > 0)
348  {
349  foreach (InventoryCollection icoll in icollList)
350  {
351  Dictionary<string, object> result = new Dictionary<string, object>();
352  result["FID"] = icoll.FolderID.ToString();
353  result["VERSION"] = icoll.Version.ToString();
354  result["OWNER"] = icoll.OwnerID.ToString();
355  Dictionary<string, object> folders = new Dictionary<string, object>();
356  i = 0;
357  if (icoll.Folders != null)
358  {
359  foreach (InventoryFolderBase f in icoll.Folders)
360  {
361  folders["folder_" + i.ToString()] = EncodeFolder(f);
362  i++;
363  }
364  result["FOLDERS"] = folders;
365  }
366  i = 0;
367  if (icoll.Items != null)
368  {
369  Dictionary<string, object> items = new Dictionary<string, object>();
370  foreach (InventoryItemBase it in icoll.Items)
371  {
372  items["item_" + i.ToString()] = EncodeItem(it);
373  i++;
374  }
375  result["ITEMS"] = items;
376  }
377 
378  resultSet["F_" + fids[count++]] = result;
379  //m_log.DebugFormat("[XXX]: Sending {0} {1}", fids[count-1], icoll.FolderID);
380  }
381  }
382 
383  string xmlString = ServerUtils.BuildXmlResponse(resultSet);
384 
385  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
386  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
387  }
388 
389  byte[] HandleGetFolderItems(Dictionary<string, object> request)
390  {
391  Dictionary<string,object> result = new Dictionary<string,object>();
392  UUID principal = UUID.Zero;
393  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
394  UUID folderID = UUID.Zero;
395  UUID.TryParse(request["FOLDER"].ToString(), out folderID);
396 
397  List<InventoryItemBase> items = m_InventoryService.GetFolderItems(principal, folderID);
398  Dictionary<string, object> sitems = new Dictionary<string, object>();
399 
400  if (items != null)
401  {
402  int i = 0;
403  foreach (InventoryItemBase item in items)
404  {
405  sitems["item_" + i.ToString()] = EncodeItem(item);
406  i++;
407  }
408  }
409  result["ITEMS"] = sitems;
410 
411  string xmlString = ServerUtils.BuildXmlResponse(result);
412 
413  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
414  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
415  }
416 
417  byte[] HandleAddFolder(Dictionary<string,object> request)
418  {
419  InventoryFolderBase folder = BuildFolder(request);
420 
421  if (m_InventoryService.AddFolder(folder))
422  return SuccessResult();
423  else
424  return FailureResult();
425  }
426 
427  byte[] HandleUpdateFolder(Dictionary<string,object> request)
428  {
429  InventoryFolderBase folder = BuildFolder(request);
430 
431  if (m_InventoryService.UpdateFolder(folder))
432  return SuccessResult();
433  else
434  return FailureResult();
435  }
436 
437  byte[] HandleMoveFolder(Dictionary<string,object> request)
438  {
439  UUID parentID = UUID.Zero;
440  UUID.TryParse(request["ParentID"].ToString(), out parentID);
441  UUID folderID = UUID.Zero;
442  UUID.TryParse(request["ID"].ToString(), out folderID);
443  UUID principal = UUID.Zero;
444  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
445 
446  InventoryFolderBase folder = new InventoryFolderBase(folderID, "", principal, parentID);
447  if (m_InventoryService.MoveFolder(folder))
448  return SuccessResult();
449  else
450  return FailureResult();
451 
452  }
453 
454  byte[] HandleDeleteFolders(Dictionary<string,object> request)
455  {
456  UUID principal = UUID.Zero;
457  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
458  List<string> slist = (List<string>)request["FOLDERS"];
459  List<UUID> uuids = new List<UUID>();
460  foreach (string s in slist)
461  {
462  UUID u = UUID.Zero;
463  if (UUID.TryParse(s, out u))
464  uuids.Add(u);
465  }
466 
467  if (m_InventoryService.DeleteFolders(principal, uuids))
468  return SuccessResult();
469  else
470  return
471  FailureResult();
472  }
473 
474  byte[] HandlePurgeFolder(Dictionary<string,object> request)
475  {
476  UUID folderID = UUID.Zero;
477  UUID.TryParse(request["ID"].ToString(), out folderID);
478 
479  InventoryFolderBase folder = new InventoryFolderBase(folderID);
480  if (m_InventoryService.PurgeFolder(folder))
481  return SuccessResult();
482  else
483  return FailureResult();
484  }
485 
486  byte[] HandleAddItem(Dictionary<string,object> request)
487  {
488  InventoryItemBase item = BuildItem(request);
489 
490  if (m_InventoryService.AddItem(item))
491  return SuccessResult();
492  else
493  return FailureResult();
494  }
495 
496  byte[] HandleUpdateItem(Dictionary<string,object> request)
497  {
498  InventoryItemBase item = BuildItem(request);
499 
500  if (m_InventoryService.UpdateItem(item))
501  return SuccessResult();
502  else
503  return FailureResult();
504  }
505 
506  byte[] HandleMoveItems(Dictionary<string,object> request)
507  {
508  List<string> idlist = (List<string>)request["IDLIST"];
509  List<string> destlist = (List<string>)request["DESTLIST"];
510  UUID principal = UUID.Zero;
511  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
512 
513  List<InventoryItemBase> items = new List<InventoryItemBase>();
514  int n = 0;
515  try
516  {
517  foreach (string s in idlist)
518  {
519  UUID u = UUID.Zero;
520  if (UUID.TryParse(s, out u))
521  {
522  UUID fid = UUID.Zero;
523  if (UUID.TryParse(destlist[n++], out fid))
524  {
525  InventoryItemBase item = new InventoryItemBase(u, principal);
526  item.Folder = fid;
527  items.Add(item);
528  }
529  }
530  }
531  }
532  catch (Exception e)
533  {
534  m_log.DebugFormat("[XINVENTORY IN CONNECTOR]: Exception in HandleMoveItems: {0}", e.Message);
535  return FailureResult();
536  }
537 
538  if (m_InventoryService.MoveItems(principal, items))
539  return SuccessResult();
540  else
541  return FailureResult();
542  }
543 
544  byte[] HandleDeleteItems(Dictionary<string,object> request)
545  {
546  UUID principal = UUID.Zero;
547  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
548  List<string> slist = (List<string>)request["ITEMS"];
549  List<UUID> uuids = new List<UUID>();
550  foreach (string s in slist)
551  {
552  UUID u = UUID.Zero;
553  if (UUID.TryParse(s, out u))
554  uuids.Add(u);
555  }
556 
557  if (m_InventoryService.DeleteItems(principal, uuids))
558  return SuccessResult();
559  else
560  return
561  FailureResult();
562  }
563 
564  byte[] HandleGetItem(Dictionary<string,object> request)
565  {
566  Dictionary<string,object> result = new Dictionary<string,object>();
567  UUID id = UUID.Zero;
568  UUID.TryParse(request["ID"].ToString(), out id);
569 
570  InventoryItemBase item = new InventoryItemBase(id);
571  item = m_InventoryService.GetItem(item);
572  if (item != null)
573  result["item"] = EncodeItem(item);
574 
575  string xmlString = ServerUtils.BuildXmlResponse(result);
576 
577  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
578  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
579  }
580 
581  byte[] HandleGetMultipleItems(Dictionary<string, object> request)
582  {
583  Dictionary<string, object> resultSet = new Dictionary<string, object>();
584  UUID principal = UUID.Zero;
585  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
586  string itemIDstr = request["ITEMS"].ToString();
587  int count = 0;
588  Int32.TryParse(request["COUNT"].ToString(), out count);
589 
590  UUID[] fids = new UUID[count];
591  string[] uuids = itemIDstr.Split(',');
592  int i = 0;
593  foreach (string id in uuids)
594  {
595  UUID fid = UUID.Zero;
596  if (UUID.TryParse(id, out fid))
597  fids[i] = fid;
598  i += 1;
599  }
600 
601  InventoryItemBase[] itemsList = m_InventoryService.GetMultipleItems(principal, fids);
602  if (itemsList != null && itemsList.Length > 0)
603  {
604  count = 0;
605  foreach (InventoryItemBase item in itemsList)
606  resultSet["item_" + count++] = (item == null) ? (object)"NULL" : EncodeItem(item);
607  }
608 
609  string xmlString = ServerUtils.BuildXmlResponse(resultSet);
610 
611  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
612  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
613  }
614 
615  byte[] HandleGetFolder(Dictionary<string,object> request)
616  {
617  Dictionary<string, object> result = new Dictionary<string, object>();
618  UUID id = UUID.Zero;
619  UUID.TryParse(request["ID"].ToString(), out id);
620 
621  InventoryFolderBase folder = new InventoryFolderBase(id);
622  folder = m_InventoryService.GetFolder(folder);
623  if (folder != null)
624  result["folder"] = EncodeFolder(folder);
625 
626  string xmlString = ServerUtils.BuildXmlResponse(result);
627 
628  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
629  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
630  }
631 
632  byte[] HandleGetActiveGestures(Dictionary<string,object> request)
633  {
634  Dictionary<string,object> result = new Dictionary<string,object>();
635  UUID principal = UUID.Zero;
636  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
637 
638  List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(principal);
639  Dictionary<string, object> items = new Dictionary<string, object>();
640  if (gestures != null)
641  {
642  int i = 0;
643  foreach (InventoryItemBase item in gestures)
644  {
645  items["item_" + i.ToString()] = EncodeItem(item);
646  i++;
647  }
648  }
649  result["ITEMS"] = items;
650 
651  string xmlString = ServerUtils.BuildXmlResponse(result);
652 
653  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
654  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
655  }
656 
657  byte[] HandleGetAssetPermissions(Dictionary<string,object> request)
658  {
659  Dictionary<string,object> result = new Dictionary<string,object>();
660  UUID principal = UUID.Zero;
661  UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
662  UUID assetID = UUID.Zero;
663  UUID.TryParse(request["ASSET"].ToString(), out assetID);
664 
665  int perms = m_InventoryService.GetAssetPermissions(principal, assetID);
666 
667  result["RESULT"] = perms.ToString();
668  string xmlString = ServerUtils.BuildXmlResponse(result);
669 
670  //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
671  return Util.UTF8NoBomEncoding.GetBytes(xmlString);
672  }
673 
674  private Dictionary<string, object> EncodeFolder(InventoryFolderBase f)
675  {
676  Dictionary<string, object> ret = new Dictionary<string, object>();
677 
678  ret["ParentID"] = f.ParentID.ToString();
679  ret["Type"] = f.Type.ToString();
680  ret["Version"] = f.Version.ToString();
681  ret["Name"] = f.Name;
682  ret["Owner"] = f.Owner.ToString();
683  ret["ID"] = f.ID.ToString();
684 
685  return ret;
686  }
687 
688  private Dictionary<string, object> EncodeItem(InventoryItemBase item)
689  {
690  Dictionary<string, object> ret = new Dictionary<string, object>();
691 
692  ret["AssetID"] = item.AssetID.ToString();
693  ret["AssetType"] = item.AssetType.ToString();
694  ret["BasePermissions"] = item.BasePermissions.ToString();
695  ret["CreationDate"] = item.CreationDate.ToString();
696  if (item.CreatorId != null)
697  ret["CreatorId"] = item.CreatorId.ToString();
698  else
699  ret["CreatorId"] = String.Empty;
700  if (item.CreatorData != null)
701  ret["CreatorData"] = item.CreatorData;
702  else
703  ret["CreatorData"] = String.Empty;
704  ret["CurrentPermissions"] = item.CurrentPermissions.ToString();
705  ret["Description"] = item.Description.ToString();
706  ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString();
707  ret["Flags"] = item.Flags.ToString();
708  ret["Folder"] = item.Folder.ToString();
709  ret["GroupID"] = item.GroupID.ToString();
710  ret["GroupOwned"] = item.GroupOwned.ToString();
711  ret["GroupPermissions"] = item.GroupPermissions.ToString();
712  ret["ID"] = item.ID.ToString();
713  ret["InvType"] = item.InvType.ToString();
714  ret["Name"] = item.Name.ToString();
715  ret["NextPermissions"] = item.NextPermissions.ToString();
716  ret["Owner"] = item.Owner.ToString();
717  ret["SalePrice"] = item.SalePrice.ToString();
718  ret["SaleType"] = item.SaleType.ToString();
719 
720  return ret;
721  }
722 
723  private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
724  {
726 
727  folder.ParentID = new UUID(data["ParentID"].ToString());
728  folder.Type = short.Parse(data["Type"].ToString());
729  folder.Version = ushort.Parse(data["Version"].ToString());
730  folder.Name = data["Name"].ToString();
731  folder.Owner = new UUID(data["Owner"].ToString());
732  folder.ID = new UUID(data["ID"].ToString());
733 
734  return folder;
735  }
736 
737  private InventoryItemBase BuildItem(Dictionary<string,object> data)
738  {
740 
741  item.AssetID = new UUID(data["AssetID"].ToString());
742  item.AssetType = int.Parse(data["AssetType"].ToString());
743  item.Name = data["Name"].ToString();
744  item.Owner = new UUID(data["Owner"].ToString());
745  item.ID = new UUID(data["ID"].ToString());
746  item.InvType = int.Parse(data["InvType"].ToString());
747  item.Folder = new UUID(data["Folder"].ToString());
748  item.CreatorId = data["CreatorId"].ToString();
749  item.CreatorData = data["CreatorData"].ToString();
750  item.Description = data["Description"].ToString();
751  item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
752  item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());
753  item.BasePermissions = uint.Parse(data["BasePermissions"].ToString());
754  item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString());
755  item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString());
756  item.GroupID = new UUID(data["GroupID"].ToString());
757  item.GroupOwned = bool.Parse(data["GroupOwned"].ToString());
758  item.SalePrice = int.Parse(data["SalePrice"].ToString());
759  item.SaleType = byte.Parse(data["SaleType"].ToString());
760  item.Flags = uint.Parse(data["Flags"].ToString());
761  item.CreationDate = int.Parse(data["CreationDate"].ToString());
762 
763  return item;
764  }
765 
766  }
767 }
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
Definition: IHttpServer.cs:36
Inventory Item - contains all the properties associated with an individual inventory piece...
string CreatorData
Extended creator information of the form <profile url>="">;<name>
override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
XInventoryConnectorPostHandler(IInventoryService service, IServiceAuth auth)
XInventoryInConnector(IConfigSource config, IHttpServer server, string configName)
List< InventoryFolderBase > Folders
Used to serialize a whole inventory for transfer over the network.