HGInventoryBroker.cs 26 KB

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