XInventoryInConnector.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Reflection;
  29. using System.Text;
  30. using System.Xml;
  31. using System.Collections.Generic;
  32. using System.IO;
  33. using Nini.Config;
  34. using OpenSim.Framework;
  35. using OpenSim.Server.Base;
  36. using OpenSim.Services.Interfaces;
  37. using OpenSim.Framework.Servers.HttpServer;
  38. using OpenSim.Server.Handlers.Base;
  39. using log4net;
  40. using OpenMetaverse;
  41. namespace OpenSim.Server.Handlers.Asset
  42. {
  43. public class XInventoryInConnector : ServiceConnector
  44. {
  45. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  46. private IInventoryService m_InventoryService;
  47. private string m_ConfigName = "InventoryService";
  48. public XInventoryInConnector(IConfigSource config, IHttpServer server, string configName) :
  49. base(config, server, configName)
  50. {
  51. if (configName != String.Empty)
  52. m_ConfigName = configName;
  53. m_log.DebugFormat("[XInventoryInConnector]: Starting with config name {0}", m_ConfigName);
  54. IConfig serverConfig = config.Configs[m_ConfigName];
  55. if (serverConfig == null)
  56. throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
  57. string inventoryService = serverConfig.GetString("LocalServiceModule",
  58. String.Empty);
  59. if (inventoryService == String.Empty)
  60. throw new Exception("No InventoryService in config file");
  61. Object[] args = new Object[] { config };
  62. m_InventoryService =
  63. ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);
  64. server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService));
  65. }
  66. }
  67. public class XInventoryConnectorPostHandler : BaseStreamHandler
  68. {
  69. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  70. private IInventoryService m_InventoryService;
  71. public XInventoryConnectorPostHandler(IInventoryService service) :
  72. base("POST", "/xinventory")
  73. {
  74. m_InventoryService = service;
  75. }
  76. public override byte[] Handle(string path, Stream requestData,
  77. OSHttpRequest httpRequest, OSHttpResponse httpResponse)
  78. {
  79. StreamReader sr = new StreamReader(requestData);
  80. string body = sr.ReadToEnd();
  81. sr.Close();
  82. body = body.Trim();
  83. //m_log.DebugFormat("[XXX]: query String: {0}", body);
  84. try
  85. {
  86. Dictionary<string, object> request =
  87. ServerUtils.ParseQueryString(body);
  88. if (!request.ContainsKey("METHOD"))
  89. return FailureResult();
  90. string method = request["METHOD"].ToString();
  91. request.Remove("METHOD");
  92. switch (method)
  93. {
  94. case "CREATEUSERINVENTORY":
  95. return HandleCreateUserInventory(request);
  96. case "GETINVENTORYSKELETON":
  97. return HandleGetInventorySkeleton(request);
  98. case "GETROOTFOLDER":
  99. return HandleGetRootFolder(request);
  100. case "GETFOLDERFORTYPE":
  101. return HandleGetFolderForType(request);
  102. case "GETFOLDERCONTENT":
  103. return HandleGetFolderContent(request);
  104. case "GETFOLDERITEMS":
  105. return HandleGetFolderItems(request);
  106. case "ADDFOLDER":
  107. return HandleAddFolder(request);
  108. case "UPDATEFOLDER":
  109. return HandleUpdateFolder(request);
  110. case "MOVEFOLDER":
  111. return HandleMoveFolder(request);
  112. case "DELETEFOLDERS":
  113. return HandleDeleteFolders(request);
  114. case "PURGEFOLDER":
  115. return HandlePurgeFolder(request);
  116. case "ADDITEM":
  117. return HandleAddItem(request);
  118. case "UPDATEITEM":
  119. return HandleUpdateItem(request);
  120. case "MOVEITEMS":
  121. return HandleMoveItems(request);
  122. case "DELETEITEMS":
  123. return HandleDeleteItems(request);
  124. case "GETITEM":
  125. return HandleGetItem(request);
  126. case "GETFOLDER":
  127. return HandleGetFolder(request);
  128. case "GETACTIVEGESTURES":
  129. return HandleGetActiveGestures(request);
  130. case "GETASSETPERMISSIONS":
  131. return HandleGetAssetPermissions(request);
  132. }
  133. m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method);
  134. }
  135. catch (Exception e)
  136. {
  137. m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e);
  138. }
  139. return FailureResult();
  140. }
  141. private byte[] FailureResult()
  142. {
  143. return BoolResult(false);
  144. }
  145. private byte[] SuccessResult()
  146. {
  147. return BoolResult(true);
  148. }
  149. private byte[] BoolResult(bool value)
  150. {
  151. XmlDocument doc = new XmlDocument();
  152. XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
  153. "", "");
  154. doc.AppendChild(xmlnode);
  155. XmlElement rootElement = doc.CreateElement("", "ServerResponse",
  156. "");
  157. doc.AppendChild(rootElement);
  158. XmlElement result = doc.CreateElement("", "RESULT", "");
  159. result.AppendChild(doc.CreateTextNode(value.ToString()));
  160. rootElement.AppendChild(result);
  161. return DocToBytes(doc);
  162. }
  163. private byte[] DocToBytes(XmlDocument doc)
  164. {
  165. MemoryStream ms = new MemoryStream();
  166. XmlTextWriter xw = new XmlTextWriter(ms, null);
  167. xw.Formatting = Formatting.Indented;
  168. doc.WriteTo(xw);
  169. xw.Flush();
  170. return ms.ToArray();
  171. }
  172. byte[] HandleCreateUserInventory(Dictionary<string,object> request)
  173. {
  174. Dictionary<string,object> result = new Dictionary<string,object>();
  175. if (!request.ContainsKey("PRINCIPAL"))
  176. return FailureResult();
  177. if (m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString())))
  178. result["RESULT"] = "True";
  179. else
  180. result["RESULT"] = "False";
  181. string xmlString = ServerUtils.BuildXmlResponse(result);
  182. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  183. UTF8Encoding encoding = new UTF8Encoding();
  184. return encoding.GetBytes(xmlString);
  185. }
  186. byte[] HandleGetInventorySkeleton(Dictionary<string,object> request)
  187. {
  188. Dictionary<string,object> result = new Dictionary<string,object>();
  189. if (!request.ContainsKey("PRINCIPAL"))
  190. return FailureResult();
  191. List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString()));
  192. Dictionary<string, object> sfolders = new Dictionary<string, object>();
  193. if (folders != null)
  194. {
  195. int i = 0;
  196. foreach (InventoryFolderBase f in folders)
  197. {
  198. sfolders["folder_" + i.ToString()] = EncodeFolder(f);
  199. i++;
  200. }
  201. }
  202. result["FOLDERS"] = sfolders;
  203. string xmlString = ServerUtils.BuildXmlResponse(result);
  204. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  205. UTF8Encoding encoding = new UTF8Encoding();
  206. return encoding.GetBytes(xmlString);
  207. }
  208. byte[] HandleGetRootFolder(Dictionary<string,object> request)
  209. {
  210. Dictionary<string,object> result = new Dictionary<string,object>();
  211. UUID principal = UUID.Zero;
  212. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  213. InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal);
  214. if (rfolder != null)
  215. result["folder"] = EncodeFolder(rfolder);
  216. string xmlString = ServerUtils.BuildXmlResponse(result);
  217. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  218. UTF8Encoding encoding = new UTF8Encoding();
  219. return encoding.GetBytes(xmlString);
  220. }
  221. byte[] HandleGetFolderForType(Dictionary<string,object> request)
  222. {
  223. Dictionary<string,object> result = new Dictionary<string,object>();
  224. UUID principal = UUID.Zero;
  225. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  226. int type = 0;
  227. Int32.TryParse(request["TYPE"].ToString(), out type);
  228. InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type);
  229. if (folder != null)
  230. result["folder"] = EncodeFolder(folder);
  231. string xmlString = ServerUtils.BuildXmlResponse(result);
  232. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  233. UTF8Encoding encoding = new UTF8Encoding();
  234. return encoding.GetBytes(xmlString);
  235. }
  236. byte[] HandleGetFolderContent(Dictionary<string,object> request)
  237. {
  238. Dictionary<string,object> result = new Dictionary<string,object>();
  239. UUID principal = UUID.Zero;
  240. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  241. UUID folderID = UUID.Zero;
  242. UUID.TryParse(request["FOLDER"].ToString(), out folderID);
  243. InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);
  244. if (icoll != null)
  245. {
  246. Dictionary<string, object> folders = new Dictionary<string, object>();
  247. int i = 0;
  248. foreach (InventoryFolderBase f in icoll.Folders)
  249. {
  250. folders["folder_" + i.ToString()] = EncodeFolder(f);
  251. i++;
  252. }
  253. result["FOLDERS"] = folders;
  254. i = 0;
  255. Dictionary<string, object> items = new Dictionary<string, object>();
  256. foreach (InventoryItemBase it in icoll.Items)
  257. {
  258. items["item_" + i.ToString()] = EncodeItem(it);
  259. i++;
  260. }
  261. result["ITEMS"] = items;
  262. }
  263. string xmlString = ServerUtils.BuildXmlResponse(result);
  264. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  265. UTF8Encoding encoding = new UTF8Encoding();
  266. return encoding.GetBytes(xmlString);
  267. }
  268. byte[] HandleGetFolderItems(Dictionary<string,object> request)
  269. {
  270. Dictionary<string,object> result = new Dictionary<string,object>();
  271. UUID principal = UUID.Zero;
  272. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  273. UUID folderID = UUID.Zero;
  274. UUID.TryParse(request["FOLDER"].ToString(), out folderID);
  275. List<InventoryItemBase> items = m_InventoryService.GetFolderItems(principal, folderID);
  276. Dictionary<string, object> sitems = new Dictionary<string, object>();
  277. if (items != null)
  278. {
  279. int i = 0;
  280. foreach (InventoryItemBase item in items)
  281. {
  282. sitems["item_" + i.ToString()] = EncodeItem(item);
  283. i++;
  284. }
  285. }
  286. result["ITEMS"] = sitems;
  287. string xmlString = ServerUtils.BuildXmlResponse(result);
  288. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  289. UTF8Encoding encoding = new UTF8Encoding();
  290. return encoding.GetBytes(xmlString);
  291. }
  292. byte[] HandleAddFolder(Dictionary<string,object> request)
  293. {
  294. InventoryFolderBase folder = BuildFolder(request);
  295. if (m_InventoryService.AddFolder(folder))
  296. return SuccessResult();
  297. else
  298. return FailureResult();
  299. }
  300. byte[] HandleUpdateFolder(Dictionary<string,object> request)
  301. {
  302. InventoryFolderBase folder = BuildFolder(request);
  303. if (m_InventoryService.UpdateFolder(folder))
  304. return SuccessResult();
  305. else
  306. return FailureResult();
  307. }
  308. byte[] HandleMoveFolder(Dictionary<string,object> request)
  309. {
  310. UUID parentID = UUID.Zero;
  311. UUID.TryParse(request["ParentID"].ToString(), out parentID);
  312. UUID folderID = UUID.Zero;
  313. UUID.TryParse(request["ID"].ToString(), out folderID);
  314. UUID principal = UUID.Zero;
  315. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  316. InventoryFolderBase folder = new InventoryFolderBase(folderID, "", principal, parentID);
  317. if (m_InventoryService.MoveFolder(folder))
  318. return SuccessResult();
  319. else
  320. return FailureResult();
  321. }
  322. byte[] HandleDeleteFolders(Dictionary<string,object> request)
  323. {
  324. UUID principal = UUID.Zero;
  325. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  326. List<string> slist = (List<string>)request["FOLDERS"];
  327. List<UUID> uuids = new List<UUID>();
  328. foreach (string s in slist)
  329. {
  330. UUID u = UUID.Zero;
  331. if (UUID.TryParse(s, out u))
  332. uuids.Add(u);
  333. }
  334. if (m_InventoryService.DeleteFolders(principal, uuids))
  335. return SuccessResult();
  336. else
  337. return
  338. FailureResult();
  339. }
  340. byte[] HandlePurgeFolder(Dictionary<string,object> request)
  341. {
  342. UUID folderID = UUID.Zero;
  343. UUID.TryParse(request["ID"].ToString(), out folderID);
  344. InventoryFolderBase folder = new InventoryFolderBase(folderID);
  345. if (m_InventoryService.PurgeFolder(folder))
  346. return SuccessResult();
  347. else
  348. return FailureResult();
  349. }
  350. byte[] HandleAddItem(Dictionary<string,object> request)
  351. {
  352. InventoryItemBase item = BuildItem(request);
  353. if (m_InventoryService.AddItem(item))
  354. return SuccessResult();
  355. else
  356. return FailureResult();
  357. }
  358. byte[] HandleUpdateItem(Dictionary<string,object> request)
  359. {
  360. InventoryItemBase item = BuildItem(request);
  361. if (m_InventoryService.UpdateItem(item))
  362. return SuccessResult();
  363. else
  364. return FailureResult();
  365. }
  366. byte[] HandleMoveItems(Dictionary<string,object> request)
  367. {
  368. List<string> idlist = (List<string>)request["IDLIST"];
  369. List<string> destlist = (List<string>)request["DESTLIST"];
  370. UUID principal = UUID.Zero;
  371. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  372. List<InventoryItemBase> items = new List<InventoryItemBase>();
  373. int n = 0;
  374. try
  375. {
  376. foreach (string s in idlist)
  377. {
  378. UUID u = UUID.Zero;
  379. if (UUID.TryParse(s, out u))
  380. {
  381. UUID fid = UUID.Zero;
  382. if (UUID.TryParse(destlist[n++], out fid))
  383. {
  384. InventoryItemBase item = new InventoryItemBase(u, principal);
  385. item.Folder = fid;
  386. items.Add(item);
  387. }
  388. }
  389. }
  390. }
  391. catch (Exception e)
  392. {
  393. m_log.DebugFormat("[XINVENTORY IN CONNECTOR]: Exception in HandleMoveItems: {0}", e.Message);
  394. return FailureResult();
  395. }
  396. if (m_InventoryService.MoveItems(principal, items))
  397. return SuccessResult();
  398. else
  399. return FailureResult();
  400. }
  401. byte[] HandleDeleteItems(Dictionary<string,object> request)
  402. {
  403. UUID principal = UUID.Zero;
  404. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  405. List<string> slist = (List<string>)request["ITEMS"];
  406. List<UUID> uuids = new List<UUID>();
  407. foreach (string s in slist)
  408. {
  409. UUID u = UUID.Zero;
  410. if (UUID.TryParse(s, out u))
  411. uuids.Add(u);
  412. }
  413. if (m_InventoryService.DeleteItems(principal, uuids))
  414. return SuccessResult();
  415. else
  416. return
  417. FailureResult();
  418. }
  419. byte[] HandleGetItem(Dictionary<string,object> request)
  420. {
  421. Dictionary<string,object> result = new Dictionary<string,object>();
  422. UUID id = UUID.Zero;
  423. UUID.TryParse(request["ID"].ToString(), out id);
  424. InventoryItemBase item = new InventoryItemBase(id);
  425. item = m_InventoryService.GetItem(item);
  426. if (item != null)
  427. result["item"] = EncodeItem(item);
  428. string xmlString = ServerUtils.BuildXmlResponse(result);
  429. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  430. UTF8Encoding encoding = new UTF8Encoding();
  431. return encoding.GetBytes(xmlString);
  432. }
  433. byte[] HandleGetFolder(Dictionary<string,object> request)
  434. {
  435. Dictionary<string, object> result = new Dictionary<string, object>();
  436. UUID id = UUID.Zero;
  437. UUID.TryParse(request["ID"].ToString(), out id);
  438. InventoryFolderBase folder = new InventoryFolderBase(id);
  439. folder = m_InventoryService.GetFolder(folder);
  440. if (folder != null)
  441. result["folder"] = EncodeFolder(folder);
  442. string xmlString = ServerUtils.BuildXmlResponse(result);
  443. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  444. UTF8Encoding encoding = new UTF8Encoding();
  445. return encoding.GetBytes(xmlString);
  446. }
  447. byte[] HandleGetActiveGestures(Dictionary<string,object> request)
  448. {
  449. Dictionary<string,object> result = new Dictionary<string,object>();
  450. UUID principal = UUID.Zero;
  451. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  452. List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(principal);
  453. Dictionary<string, object> items = new Dictionary<string, object>();
  454. if (gestures != null)
  455. {
  456. int i = 0;
  457. foreach (InventoryItemBase item in gestures)
  458. {
  459. items["item_" + i.ToString()] = EncodeItem(item);
  460. i++;
  461. }
  462. }
  463. result["ITEMS"] = items;
  464. string xmlString = ServerUtils.BuildXmlResponse(result);
  465. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  466. UTF8Encoding encoding = new UTF8Encoding();
  467. return encoding.GetBytes(xmlString);
  468. }
  469. byte[] HandleGetAssetPermissions(Dictionary<string,object> request)
  470. {
  471. Dictionary<string,object> result = new Dictionary<string,object>();
  472. UUID principal = UUID.Zero;
  473. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  474. UUID assetID = UUID.Zero;
  475. UUID.TryParse(request["ASSET"].ToString(), out assetID);
  476. int perms = m_InventoryService.GetAssetPermissions(principal, assetID);
  477. result["RESULT"] = perms.ToString();
  478. string xmlString = ServerUtils.BuildXmlResponse(result);
  479. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  480. UTF8Encoding encoding = new UTF8Encoding();
  481. return encoding.GetBytes(xmlString);
  482. }
  483. private Dictionary<string, object> EncodeFolder(InventoryFolderBase f)
  484. {
  485. Dictionary<string, object> ret = new Dictionary<string, object>();
  486. ret["ParentID"] = f.ParentID.ToString();
  487. ret["Type"] = f.Type.ToString();
  488. ret["Version"] = f.Version.ToString();
  489. ret["Name"] = f.Name;
  490. ret["Owner"] = f.Owner.ToString();
  491. ret["ID"] = f.ID.ToString();
  492. return ret;
  493. }
  494. private Dictionary<string, object> EncodeItem(InventoryItemBase item)
  495. {
  496. Dictionary<string, object> ret = new Dictionary<string, object>();
  497. ret["AssetID"] = item.AssetID.ToString();
  498. ret["AssetType"] = item.AssetType.ToString();
  499. ret["BasePermissions"] = item.BasePermissions.ToString();
  500. ret["CreationDate"] = item.CreationDate.ToString();
  501. if (item.CreatorId != null)
  502. ret["CreatorId"] = item.CreatorId.ToString();
  503. else
  504. ret["CreatorId"] = String.Empty;
  505. if (item.CreatorData != null)
  506. ret["CreatorData"] = item.CreatorData;
  507. else
  508. ret["CreatorData"] = String.Empty;
  509. ret["CurrentPermissions"] = item.CurrentPermissions.ToString();
  510. ret["Description"] = item.Description.ToString();
  511. ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString();
  512. ret["Flags"] = item.Flags.ToString();
  513. ret["Folder"] = item.Folder.ToString();
  514. ret["GroupID"] = item.GroupID.ToString();
  515. ret["GroupOwned"] = item.GroupOwned.ToString();
  516. ret["GroupPermissions"] = item.GroupPermissions.ToString();
  517. ret["ID"] = item.ID.ToString();
  518. ret["InvType"] = item.InvType.ToString();
  519. ret["Name"] = item.Name.ToString();
  520. ret["NextPermissions"] = item.NextPermissions.ToString();
  521. ret["Owner"] = item.Owner.ToString();
  522. ret["SalePrice"] = item.SalePrice.ToString();
  523. ret["SaleType"] = item.SaleType.ToString();
  524. return ret;
  525. }
  526. private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
  527. {
  528. InventoryFolderBase folder = new InventoryFolderBase();
  529. folder.ParentID = new UUID(data["ParentID"].ToString());
  530. folder.Type = short.Parse(data["Type"].ToString());
  531. folder.Version = ushort.Parse(data["Version"].ToString());
  532. folder.Name = data["Name"].ToString();
  533. folder.Owner = new UUID(data["Owner"].ToString());
  534. folder.ID = new UUID(data["ID"].ToString());
  535. return folder;
  536. }
  537. private InventoryItemBase BuildItem(Dictionary<string,object> data)
  538. {
  539. InventoryItemBase item = new InventoryItemBase();
  540. item.AssetID = new UUID(data["AssetID"].ToString());
  541. item.AssetType = int.Parse(data["AssetType"].ToString());
  542. item.Name = data["Name"].ToString();
  543. item.Owner = new UUID(data["Owner"].ToString());
  544. item.ID = new UUID(data["ID"].ToString());
  545. item.InvType = int.Parse(data["InvType"].ToString());
  546. item.Folder = new UUID(data["Folder"].ToString());
  547. item.CreatorId = data["CreatorId"].ToString();
  548. item.CreatorData = data["CreatorData"].ToString();
  549. item.Description = data["Description"].ToString();
  550. item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
  551. item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());
  552. item.BasePermissions = uint.Parse(data["BasePermissions"].ToString());
  553. item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString());
  554. item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString());
  555. item.GroupID = new UUID(data["GroupID"].ToString());
  556. item.GroupOwned = bool.Parse(data["GroupOwned"].ToString());
  557. item.SalePrice = int.Parse(data["SalePrice"].ToString());
  558. item.SaleType = byte.Parse(data["SaleType"].ToString());
  559. item.Flags = uint.Parse(data["Flags"].ToString());
  560. item.CreationDate = int.Parse(data["CreationDate"].ToString());
  561. return item;
  562. }
  563. }
  564. }