Пример #1
0
        private IDataReader GetForeignInventory(UUID AgentID, UUID folder_id, string serverURL)
        {
            FakeDataReader        d             = new FakeDataReader();
            IConfigurationService configService = m_registry.RequestModuleInterface <IConfigurationService>();

            if (serverURL == "" && configService != null)
            {
                List <string> urls = configService.FindValueOf("InventoryServerURI");
                if (urls.Count > 0)
                {
                    serverURL = urls[0];
                }
                else
                {
                    return(null);
                }
            }
            XInventoryServicesConnector xinv = new XInventoryServicesConnector(serverURL + "xinventory");
            InventoryCollection         c    = xinv.GetFolderContent(AgentID, folder_id);

            if (c != null)
            {
                foreach (InventoryItemBase item in c.Items)
                {
                    d.items.Add(item);
                }
            }
            return(d);
        }
Пример #2
0
        public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
        {
            InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);

            Util.FireAndForget(delegate
            {
                if (UserManager != null)
                {
                    foreach (InventoryItemBase item in invCol.Items)
                    {
                        UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
                    }
                }
            });

            return(invCol);
        }
        public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
        {
            InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);

            if (UserManager != null)
            {
                // Protect ourselves against the caller subsequently modifying the items list
                List <InventoryItemBase> items = new List <InventoryItemBase>(invCol.Items);

                Util.FireAndForget(delegate
                {
                    foreach (InventoryItemBase item in items)
                    {
                        UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
                    }
                });
            }

            return(invCol);
        }
        public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
        {
            InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);

            // Commenting this for now, because it's causing more grief than good
            //if (invCol != null && UserManager != null)
            //{
            //    // Protect ourselves against the caller subsequently modifying the items list
            //    List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);

            //    if (items != null && items.Count > 0)
            //        //Util.FireAndForget(delegate
            //        //{
            //            foreach (InventoryItemBase item in items)
            //                if (!string.IsNullOrEmpty(item.CreatorData))
            //                    UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
            //        //});
            //}

            return(invCol);
        }
Пример #5
0
        public void Inventory_001_CreateInventory()
        {
            TestHelpers.InMethod();
            XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address);

            // Create an inventory that looks like this:
            //
            // /My Inventory
            //   <other system folders>
            //   /Objects
            //      Some Object
            //   /Notecards
            //      Notecard 1
            //      Notecard 2
            //   /Test Folder
            //      Link to notecard  -> /Notecards/Notecard 2
            //      Link to Objects folder -> /Objects

            bool success = m_Connector.CreateUserInventory(m_userID);

            Assert.IsTrue(success, "Failed to create user inventory");

            m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID;
            Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero");

            InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, FolderType.Object);

            Assert.IsNotNull(of, "Failed to retrieve Objects folder");
            m_objectsFolder = of.ID;
            Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero");

            // Add an object
            InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID);

            item.AssetID     = UUID.Random();
            item.AssetType   = (int)AssetType.Object;
            item.Folder      = m_objectsFolder;
            item.Name        = "Some Object";
            item.Description = string.Empty;
            success          = m_Connector.AddItem(item);
            Assert.IsTrue(success, "Failed to add object to inventory");

            InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, FolderType.Notecard);

            Assert.IsNotNull(of, "Failed to retrieve Notecards folder");
            m_notecardsFolder = ncf.ID;
            Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero");
            m_notecardsFolder = ncf.ID;

            // Add a notecard
            item             = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID);
            item.AssetID     = UUID.Random();
            item.AssetType   = (int)AssetType.Notecard;
            item.Folder      = m_notecardsFolder;
            item.Name        = "Test Notecard 1";
            item.Description = string.Empty;
            success          = m_Connector.AddItem(item);
            Assert.IsTrue(success, "Failed to add Notecard 1 to inventory");
            // Add another notecard
            item.ID          = new UUID("20000000-0000-0000-0000-000000000002");
            item.AssetID     = new UUID("a0000000-0000-0000-0000-00000000000a");
            item.Name        = "Test Notecard 2";
            item.Description = string.Empty;
            success          = m_Connector.AddItem(item);
            Assert.IsTrue(success, "Failed to add Notecard 2 to inventory");

            // Add a folder
            InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID);

            folder.Type = (int)FolderType.None;
            success     = m_Connector.AddFolder(folder);
            Assert.IsTrue(success, "Failed to add Test Folder to inventory");

            // Add a link to notecard 2 in Test Folder
            item.AssetID     = item.ID; // use item ID of notecard 2
            item.ID          = new UUID("40000000-0000-0000-0000-000000000004");
            item.AssetType   = (int)AssetType.Link;
            item.Folder      = folder.ID;
            item.Name        = "Link to notecard";
            item.Description = string.Empty;
            success          = m_Connector.AddItem(item);
            Assert.IsTrue(success, "Failed to add link to notecard to inventory");

            // Add a link to the Objects folder in Test Folder
            item.AssetID     = m_Connector.GetFolderForType(m_userID, FolderType.Object).ID; // use item ID of Objects folder
            item.ID          = new UUID("50000000-0000-0000-0000-000000000005");
            item.AssetType   = (int)AssetType.LinkFolder;
            item.Folder      = folder.ID;
            item.Name        = "Link to Objects folder";
            item.Description = string.Empty;
            success          = m_Connector.AddItem(item);
            Assert.IsTrue(success, "Failed to add link to objects folder to inventory");

            InventoryCollection coll = m_Connector.GetFolderContent(m_userID, m_rootFolderID);

            Assert.IsNotNull(coll, "Failed to retrieve contents of root folder");
            Assert.Greater(coll.Folders.Count, 0, "Root folder does not have any subfolders");

            coll = m_Connector.GetFolderContent(m_userID, folder.ID);
            Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder");
            Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside");
        }
 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
 {
     return(m_RemoteConnector.GetFolderContent(userID, folderID));
 }
Пример #7
0
 public override List<InventoryItemBase> GetItems(UUID avatarID, string[] fields, string[] vals)
 {
     IUserFinder userFinder = m_registry.RequestModuleInterface<IUserFinder>();
     if (userFinder != null && !userFinder.IsLocalGridUser(avatarID))
     {
         string serverURL = userFinder.GetUserServerURL(avatarID, "InventoryServerURI") + "xinventory";
         UUID id = UUID.Parse(vals[0]);
         XInventoryServicesConnector xinv = new XInventoryServicesConnector(serverURL);
         if(fields[0] == "parentFolderID")
         {
             return xinv.GetFolderContent(avatarID, id).Items;
         }
         else
         {
             return new List<InventoryItemBase> { xinv.GetItem(new InventoryItemBase(id)) };
         }
     }
     return base.GetItems(avatarID, fields, vals);
 }
Пример #8
0
 private IDataReader GetForeignInventory(UUID AgentID, UUID folder_id, string serverURL)
 {
     FakeDataReader d = new FakeDataReader();
     IConfigurationService configService = m_registry.RequestModuleInterface<IConfigurationService>();
     if (serverURL == "" && configService != null)
     {
         List<string> urls = configService.FindValueOf("InventoryServerURI");
         if (urls.Count > 0)
             serverURL = urls[0];
         else
             return null;
     }
     XInventoryServicesConnector xinv = new XInventoryServicesConnector(serverURL + "xinventory");
     InventoryCollection c = xinv.GetFolderContent(AgentID, folder_id);
     if (c != null)
     {
         foreach (InventoryItemBase item in c.Items)
         {
             d.items.Add(item);
         }
     }
     return d;
 }