HGInventoryBroker.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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 log4net;
  28. using Mono.Addins;
  29. using Nini.Config;
  30. using System;
  31. using System.Collections.Generic;
  32. using System.Reflection;
  33. using OpenSim.Framework;
  34. using OpenSim.Server.Base;
  35. using OpenSim.Region.Framework.Interfaces;
  36. using OpenSim.Region.Framework.Scenes;
  37. using OpenSim.Services.Interfaces;
  38. using OpenSim.Services.Connectors;
  39. using OpenSim.Services.Connectors.SimianGrid;
  40. using OpenMetaverse;
  41. namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
  42. {
  43. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGInventoryBroker")]
  44. public class HGInventoryBroker : ISharedRegionModule, IInventoryService
  45. {
  46. private static readonly ILog m_log =
  47. LogManager.GetLogger(
  48. MethodBase.GetCurrentMethod().DeclaringType);
  49. private static bool m_Enabled = false;
  50. private static IInventoryService m_LocalGridInventoryService;
  51. private Dictionary<string, IInventoryService> m_connectors = new Dictionary<string, IInventoryService>();
  52. // A cache of userIDs --> ServiceURLs, for HGBroker only
  53. protected Dictionary<UUID, string> m_InventoryURLs = new Dictionary<UUID,string>();
  54. private List<Scene> m_Scenes = new List<Scene>();
  55. private InventoryCache m_Cache = new InventoryCache();
  56. /// <summary>
  57. /// Used to serialize inventory requests.
  58. /// </summary>
  59. private object m_Lock = new object();
  60. protected IUserManagement m_UserManagement;
  61. protected IUserManagement UserManagementModule
  62. {
  63. get
  64. {
  65. if (m_UserManagement == null)
  66. {
  67. m_UserManagement = m_Scenes[0].RequestModuleInterface<IUserManagement>();
  68. if (m_UserManagement == null)
  69. m_log.ErrorFormat(
  70. "[HG INVENTORY CONNECTOR]: Could not retrieve IUserManagement module from {0}",
  71. m_Scenes[0].RegionInfo.RegionName);
  72. }
  73. return m_UserManagement;
  74. }
  75. }
  76. public Type ReplaceableInterface
  77. {
  78. get { return null; }
  79. }
  80. public string Name
  81. {
  82. get { return "HGInventoryBroker"; }
  83. }
  84. public void Initialise(IConfigSource source)
  85. {
  86. IConfig moduleConfig = source.Configs["Modules"];
  87. if (moduleConfig != null)
  88. {
  89. string name = moduleConfig.GetString("InventoryServices", "");
  90. if (name == Name)
  91. {
  92. IConfig inventoryConfig = source.Configs["InventoryService"];
  93. if (inventoryConfig == null)
  94. {
  95. m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
  96. return;
  97. }
  98. string localDll = inventoryConfig.GetString("LocalGridInventoryService",
  99. String.Empty);
  100. //string HGDll = inventoryConfig.GetString("HypergridInventoryService",
  101. // String.Empty);
  102. if (localDll == String.Empty)
  103. {
  104. m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService");
  105. //return;
  106. throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
  107. }
  108. Object[] args = new Object[] { source };
  109. m_LocalGridInventoryService =
  110. ServerUtils.LoadPlugin<IInventoryService>(localDll,
  111. args);
  112. if (m_LocalGridInventoryService == null)
  113. {
  114. m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service");
  115. return;
  116. }
  117. m_Enabled = true;
  118. m_log.InfoFormat("[HG INVENTORY CONNECTOR]: HG inventory broker enabled with inner connector of type {0}", m_LocalGridInventoryService.GetType());
  119. }
  120. }
  121. }
  122. public void PostInitialise()
  123. {
  124. }
  125. public void Close()
  126. {
  127. }
  128. public void AddRegion(Scene scene)
  129. {
  130. if (!m_Enabled)
  131. return;
  132. m_Scenes.Add(scene);
  133. scene.RegisterModuleInterface<IInventoryService>(this);
  134. if (m_Scenes.Count == 1)
  135. {
  136. // FIXME: The local connector needs the scene to extract the UserManager. However, it's not enabled so
  137. // we can't just add the region. But this approach is super-messy.
  138. if (m_LocalGridInventoryService is RemoteXInventoryServicesConnector)
  139. {
  140. m_log.DebugFormat(
  141. "[HG INVENTORY BROKER]: Manually setting scene in RemoteXInventoryServicesConnector to {0}",
  142. scene.RegionInfo.RegionName);
  143. ((RemoteXInventoryServicesConnector)m_LocalGridInventoryService).Scene = scene;
  144. }
  145. else if (m_LocalGridInventoryService is LocalInventoryServicesConnector)
  146. {
  147. m_log.DebugFormat(
  148. "[HG INVENTORY BROKER]: Manually setting scene in LocalInventoryServicesConnector to {0}",
  149. scene.RegionInfo.RegionName);
  150. ((LocalInventoryServicesConnector)m_LocalGridInventoryService).Scene = scene;
  151. }
  152. scene.EventManager.OnClientClosed += OnClientClosed;
  153. }
  154. }
  155. public void RemoveRegion(Scene scene)
  156. {
  157. if (!m_Enabled)
  158. return;
  159. m_Scenes.Remove(scene);
  160. }
  161. public void RegionLoaded(Scene scene)
  162. {
  163. if (!m_Enabled)
  164. return;
  165. m_log.InfoFormat("[HG INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName);
  166. }
  167. #region URL Cache
  168. void OnClientClosed(UUID clientID, Scene scene)
  169. {
  170. ScenePresence sp = null;
  171. foreach (Scene s in m_Scenes)
  172. {
  173. s.TryGetScenePresence(clientID, out sp);
  174. if ((sp != null) && !sp.IsChildAgent && (s != scene))
  175. {
  176. m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping inventoryURL in cache",
  177. scene.RegionInfo.RegionName, clientID);
  178. return;
  179. }
  180. }
  181. if (m_InventoryURLs.ContainsKey(clientID)) // if it's in cache
  182. DropInventoryServiceURL(clientID);
  183. m_Cache.RemoveAll(clientID);
  184. }
  185. /// <summary>
  186. /// Gets the user's inventory URL from its serviceURLs, if the user is foreign,
  187. /// and sticks it in the cache
  188. /// </summary>
  189. /// <param name="userID"></param>
  190. private void CacheInventoryServiceURL(UUID userID)
  191. {
  192. if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID))
  193. {
  194. // The user is not local; let's cache its service URL
  195. string inventoryURL = string.Empty;
  196. ScenePresence sp = null;
  197. foreach (Scene scene in m_Scenes)
  198. {
  199. scene.TryGetScenePresence(userID, out sp);
  200. if (sp != null)
  201. {
  202. AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
  203. if (aCircuit == null)
  204. return;
  205. if (aCircuit.ServiceURLs == null)
  206. return;
  207. if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI"))
  208. {
  209. inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString();
  210. if (inventoryURL != null && inventoryURL != string.Empty)
  211. {
  212. inventoryURL = inventoryURL.Trim(new char[] { '/' });
  213. lock (m_InventoryURLs)
  214. m_InventoryURLs[userID] = inventoryURL;
  215. m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
  216. return;
  217. }
  218. }
  219. // else
  220. // {
  221. // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID);
  222. // return;
  223. // }
  224. }
  225. }
  226. if (sp == null)
  227. {
  228. inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI");
  229. if (!string.IsNullOrEmpty(inventoryURL))
  230. {
  231. inventoryURL = inventoryURL.Trim(new char[] { '/' });
  232. lock (m_InventoryURLs)
  233. m_InventoryURLs[userID] = inventoryURL;
  234. m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
  235. }
  236. }
  237. }
  238. }
  239. private void DropInventoryServiceURL(UUID userID)
  240. {
  241. lock (m_InventoryURLs)
  242. {
  243. if (m_InventoryURLs.ContainsKey(userID))
  244. {
  245. string url = m_InventoryURLs[userID];
  246. m_InventoryURLs.Remove(userID);
  247. m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Removed {0} from the cache of inventory URLs", url);
  248. }
  249. }
  250. }
  251. public string GetInventoryServiceURL(UUID userID)
  252. {
  253. lock (m_InventoryURLs)
  254. {
  255. if (m_InventoryURLs.ContainsKey(userID))
  256. return m_InventoryURLs[userID];
  257. }
  258. CacheInventoryServiceURL(userID);
  259. lock (m_InventoryURLs)
  260. {
  261. if (m_InventoryURLs.ContainsKey(userID))
  262. return m_InventoryURLs[userID];
  263. }
  264. return null; //it means that the methods should forward to local grid's inventory
  265. }
  266. #endregion
  267. #region IInventoryService
  268. public bool CreateUserInventory(UUID userID)
  269. {
  270. lock (m_Lock)
  271. return m_LocalGridInventoryService.CreateUserInventory(userID);
  272. }
  273. public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
  274. {
  275. string invURL = GetInventoryServiceURL(userID);
  276. if (invURL == null) // not there, forward to local inventory connector to resolve
  277. lock (m_Lock)
  278. return m_LocalGridInventoryService.GetInventorySkeleton(userID);
  279. IInventoryService connector = GetConnector(invURL);
  280. return connector.GetInventorySkeleton(userID);
  281. }
  282. public InventoryFolderBase GetRootFolder(UUID userID)
  283. {
  284. //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID);
  285. InventoryFolderBase root = m_Cache.GetRootFolder(userID);
  286. if (root != null)
  287. return root;
  288. string invURL = GetInventoryServiceURL(userID);
  289. if (invURL == null) // not there, forward to local inventory connector to resolve
  290. lock (m_Lock)
  291. return m_LocalGridInventoryService.GetRootFolder(userID);
  292. IInventoryService connector = GetConnector(invURL);
  293. root = connector.GetRootFolder(userID);
  294. m_Cache.Cache(userID, root);
  295. return root;
  296. }
  297. public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
  298. {
  299. //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type);
  300. InventoryFolderBase f = m_Cache.GetFolderForType(userID, type);
  301. if (f != null)
  302. return f;
  303. string invURL = GetInventoryServiceURL(userID);
  304. if (invURL == null) // not there, forward to local inventory connector to resolve
  305. lock (m_Lock)
  306. return m_LocalGridInventoryService.GetFolderForType(userID, type);
  307. IInventoryService connector = GetConnector(invURL);
  308. f = connector.GetFolderForType(userID, type);
  309. m_Cache.Cache(userID, type, f);
  310. return f;
  311. }
  312. public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
  313. {
  314. //m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent " + folderID);
  315. string invURL = GetInventoryServiceURL(userID);
  316. if (invURL == null) // not there, forward to local inventory connector to resolve
  317. lock (m_Lock)
  318. return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
  319. InventoryCollection c = m_Cache.GetFolderContent(userID, folderID);
  320. if (c != null)
  321. {
  322. m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent found content in cache " + folderID);
  323. return c;
  324. }
  325. IInventoryService connector = GetConnector(invURL);
  326. return connector.GetFolderContent(userID, folderID);
  327. }
  328. public InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs)
  329. {
  330. string invURL = GetInventoryServiceURL(userID);
  331. if (invURL == null) // not there, forward to local inventory connector to resolve
  332. lock (m_Lock)
  333. return m_LocalGridInventoryService.GetMultipleFoldersContent(userID, folderIDs);
  334. else
  335. {
  336. InventoryCollection[] coll = new InventoryCollection[folderIDs.Length];
  337. int i = 0;
  338. foreach (UUID fid in folderIDs)
  339. coll[i++] = GetFolderContent(userID, fid);
  340. return coll;
  341. }
  342. }
  343. public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
  344. {
  345. //m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems " + folderID);
  346. string invURL = GetInventoryServiceURL(userID);
  347. if (invURL == null) // not there, forward to local inventory connector to resolve
  348. lock (m_Lock)
  349. return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
  350. List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID);
  351. if (items != null)
  352. {
  353. m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems found items in cache " + folderID);
  354. return items;
  355. }
  356. IInventoryService connector = GetConnector(invURL);
  357. return connector.GetFolderItems(userID, folderID);
  358. }
  359. public bool AddFolder(InventoryFolderBase folder)
  360. {
  361. if (folder == null)
  362. return false;
  363. //m_log.Debug("[HG INVENTORY CONNECTOR]: AddFolder " + folder.ID);
  364. string invURL = GetInventoryServiceURL(folder.Owner);
  365. if (invURL == null) // not there, forward to local inventory connector to resolve
  366. lock (m_Lock)
  367. return m_LocalGridInventoryService.AddFolder(folder);
  368. IInventoryService connector = GetConnector(invURL);
  369. return connector.AddFolder(folder);
  370. }
  371. public bool UpdateFolder(InventoryFolderBase folder)
  372. {
  373. if (folder == null)
  374. return false;
  375. //m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateFolder " + folder.ID);
  376. string invURL = GetInventoryServiceURL(folder.Owner);
  377. if (invURL == null) // not there, forward to local inventory connector to resolve
  378. lock (m_Lock)
  379. return m_LocalGridInventoryService.UpdateFolder(folder);
  380. IInventoryService connector = GetConnector(invURL);
  381. return connector.UpdateFolder(folder);
  382. }
  383. public bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
  384. {
  385. if (folderIDs == null)
  386. return false;
  387. if (folderIDs.Count == 0)
  388. return false;
  389. //m_log.Debug("[HG INVENTORY CONNECTOR]: DeleteFolders for " + ownerID);
  390. string invURL = GetInventoryServiceURL(ownerID);
  391. if (invURL == null) // not there, forward to local inventory connector to resolve
  392. lock (m_Lock)
  393. return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs);
  394. IInventoryService connector = GetConnector(invURL);
  395. return connector.DeleteFolders(ownerID, folderIDs);
  396. }
  397. public bool MoveFolder(InventoryFolderBase folder)
  398. {
  399. if (folder == null)
  400. return false;
  401. //m_log.Debug("[HG INVENTORY CONNECTOR]: MoveFolder for " + folder.Owner);
  402. string invURL = GetInventoryServiceURL(folder.Owner);
  403. if (invURL == null) // not there, forward to local inventory connector to resolve
  404. lock (m_Lock)
  405. return m_LocalGridInventoryService.MoveFolder(folder);
  406. IInventoryService connector = GetConnector(invURL);
  407. return connector.MoveFolder(folder);
  408. }
  409. public bool PurgeFolder(InventoryFolderBase folder)
  410. {
  411. if (folder == null)
  412. return false;
  413. //m_log.Debug("[HG INVENTORY CONNECTOR]: PurgeFolder for " + folder.Owner);
  414. string invURL = GetInventoryServiceURL(folder.Owner);
  415. if (invURL == null) // not there, forward to local inventory connector to resolve
  416. lock (m_Lock)
  417. return m_LocalGridInventoryService.PurgeFolder(folder);
  418. IInventoryService connector = GetConnector(invURL);
  419. return connector.PurgeFolder(folder);
  420. }
  421. public bool AddItem(InventoryItemBase item)
  422. {
  423. if (item == null)
  424. return false;
  425. //m_log.Debug("[HG INVENTORY CONNECTOR]: AddItem " + item.ID);
  426. string invURL = GetInventoryServiceURL(item.Owner);
  427. if (invURL == null) // not there, forward to local inventory connector to resolve
  428. lock (m_Lock)
  429. return m_LocalGridInventoryService.AddItem(item);
  430. IInventoryService connector = GetConnector(invURL);
  431. return connector.AddItem(item);
  432. }
  433. public bool UpdateItem(InventoryItemBase item)
  434. {
  435. if (item == null)
  436. return false;
  437. //m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateItem " + item.ID);
  438. string invURL = GetInventoryServiceURL(item.Owner);
  439. if (invURL == null) // not there, forward to local inventory connector to resolve
  440. lock (m_Lock)
  441. return m_LocalGridInventoryService.UpdateItem(item);
  442. IInventoryService connector = GetConnector(invURL);
  443. return connector.UpdateItem(item);
  444. }
  445. public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
  446. {
  447. if (items == null)
  448. return false;
  449. if (items.Count == 0)
  450. return true;
  451. //m_log.Debug("[HG INVENTORY CONNECTOR]: MoveItems for " + ownerID);
  452. string invURL = GetInventoryServiceURL(ownerID);
  453. if (invURL == null) // not there, forward to local inventory connector to resolve
  454. lock (m_Lock)
  455. return m_LocalGridInventoryService.MoveItems(ownerID, items);
  456. IInventoryService connector = GetConnector(invURL);
  457. return connector.MoveItems(ownerID, items);
  458. }
  459. public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
  460. {
  461. //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
  462. if (itemIDs == null)
  463. return false;
  464. if (itemIDs.Count == 0)
  465. return true;
  466. string invURL = GetInventoryServiceURL(ownerID);
  467. if (invURL == null) // not there, forward to local inventory connector to resolve
  468. lock (m_Lock)
  469. return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs);
  470. IInventoryService connector = GetConnector(invURL);
  471. return connector.DeleteItems(ownerID, itemIDs);
  472. }
  473. public InventoryItemBase GetItem(UUID principalID, UUID itemID)
  474. {
  475. //m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID);
  476. string invURL = GetInventoryServiceURL(principalID);
  477. if (invURL == null) // not there, forward to local inventory connector to resolve
  478. lock (m_Lock)
  479. return m_LocalGridInventoryService.GetItem(principalID, itemID);
  480. IInventoryService connector = GetConnector(invURL);
  481. return connector.GetItem(principalID, itemID);
  482. }
  483. public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs)
  484. {
  485. if (itemIDs == null)
  486. return new InventoryItemBase[0];
  487. //m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID);
  488. string invURL = GetInventoryServiceURL(userID);
  489. if (invURL == null) // not there, forward to local inventory connector to resolve
  490. lock (m_Lock)
  491. return m_LocalGridInventoryService.GetMultipleItems(userID, itemIDs);
  492. IInventoryService connector = GetConnector(invURL);
  493. return connector.GetMultipleItems(userID, itemIDs);
  494. }
  495. public InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
  496. {
  497. //m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolder " + folder.ID);
  498. string invURL = GetInventoryServiceURL(principalID);
  499. if (invURL == null) // not there, forward to local inventory connector to resolve
  500. lock (m_Lock)
  501. return m_LocalGridInventoryService.GetFolder(principalID, folderID);
  502. IInventoryService connector = GetConnector(invURL);
  503. return connector.GetFolder(principalID, folderID);
  504. }
  505. public bool HasInventoryForUser(UUID userID)
  506. {
  507. return false;
  508. }
  509. public List<InventoryItemBase> GetActiveGestures(UUID userId)
  510. {
  511. return new List<InventoryItemBase>();
  512. }
  513. public int GetAssetPermissions(UUID userID, UUID assetID)
  514. {
  515. //m_log.Debug("[HG INVENTORY CONNECTOR]: GetAssetPermissions " + assetID);
  516. string invURL = GetInventoryServiceURL(userID);
  517. if (invURL == null) // not there, forward to local inventory connector to resolve
  518. lock (m_Lock)
  519. return m_LocalGridInventoryService.GetAssetPermissions(userID, assetID);
  520. IInventoryService connector = GetConnector(invURL);
  521. return connector.GetAssetPermissions(userID, assetID);
  522. }
  523. #endregion
  524. private IInventoryService GetConnector(string url)
  525. {
  526. IInventoryService connector = null;
  527. lock (m_connectors)
  528. {
  529. if (m_connectors.ContainsKey(url))
  530. {
  531. connector = m_connectors[url];
  532. }
  533. else
  534. {
  535. // Still not as flexible as I would like this to be,
  536. // but good enough for now
  537. string connectorType = new HeloServicesConnector(url).Helo();
  538. m_log.DebugFormat("[HG INVENTORY SERVICE]: HELO returned {0}", connectorType);
  539. if (connectorType == "opensim-simian")
  540. {
  541. connector = new SimianInventoryServiceConnector(url);
  542. }
  543. else
  544. {
  545. RemoteXInventoryServicesConnector rxisc = new RemoteXInventoryServicesConnector(url);
  546. rxisc.Scene = m_Scenes[0];
  547. connector = rxisc;
  548. }
  549. m_connectors.Add(url, connector);
  550. }
  551. }
  552. return connector;
  553. }
  554. }
  555. }