Exemple #1
0
        /// <summary>
        /// Gets everything (folders and items) inside a folder
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="folderID"></param>
        /// <returns></returns>
        public InventoryCollection GetFolderContent(string userID, UUID folderID, UUID sessionID)
        {
            try
            {
                // normal case
                return(SynchronousRestSessionObjectPoster <Guid, InventoryCollection> .BeginPostObject(
                           "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString()));
            }
            catch (TimeoutException e)
            {
                m_log.ErrorFormat(
                    "[INVENTORY CONNECTOR]: GetFolderContent operation to {0} for {1} timed out {2} {3}.",
                    m_ServerURI, folderID, e.Source, e.Message);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed for {0}, {1} {2} (old server?).",
                                  folderID, e.Source, e.Message);
            }

            InventoryCollection nullCollection = new InventoryCollection();

            nullCollection.Folders = new List <InventoryFolderBase>();
            nullCollection.Items   = new List <InventoryItemBase>();
            nullCollection.UserID  = new UUID(userID);
            return(nullCollection);
        }
        protected InventoryCollection GetInventoryAsync(string url, UUID userID, UUID sessionID)
        {
            InventoryCollection icol = null;

            try
            {
                icol = SynchronousRestSessionObjectPoster <Guid, InventoryCollection> .BeginPostObject("POST", url + "/GetInventory/",
                                                                                                       userID.Guid, sessionID.ToString(), userID.ToString());
            }
            catch (Exception e)
            {
                m_log.Debug("[HGrid]: Exception getting users inventory: " + e.Message);
            }
            if (icol == null)
            {
                // Well, let's synthesize one
                icol         = new InventoryCollection();
                icol.UserID  = userID;
                icol.Items   = new List <InventoryItemBase>();
                icol.Folders = new List <InventoryFolderBase>();
                InventoryFolderBase rootFolder = new InventoryFolderBase();
                rootFolder.ID    = UUID.Random();
                rootFolder.Owner = userID;
                icol.Folders.Add(rootFolder);
            }

            return(icol);
        }
Exemple #3
0
        /// <summary>
        /// Gets the user folder for the given folder-type
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public Dictionary <AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
        {
            List <InventoryFolderBase> folders = null;
            Dictionary <AssetType, InventoryFolderBase> dFolders = new Dictionary <AssetType, InventoryFolderBase>();

            try
            {
                folders = SynchronousRestSessionObjectPoster <Guid, List <InventoryFolderBase> > .BeginPostObject(
                    "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());

                foreach (InventoryFolderBase f in folders)
                {
                    dFolders[(AssetType)f.Type] = f;
                }

                return(dFolders);
            }
            catch (Exception e)
            {
                // Maybe we're talking to an old inventory server. Try this other thing.
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1} (old sever?). Trying GetInventory.",
                                  e.Source, e.Message);

                try
                {
                    InventoryCollection inventory = SynchronousRestSessionObjectPoster <Guid, InventoryCollection> .BeginPostObject(
                        "POST", m_ServerURI + "/GetInventory/", new Guid(userID), sessionID.ToString(), userID.ToString());

                    folders = inventory.Folders;
                }
                catch (Exception ex)
                {
                    m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetInventory operation also failed, {0} {1}. Giving up.",
                                      e.Source, ex.Message);
                }

                if ((folders != null) && (folders.Count > 0))
                {
                    m_log.DebugFormat("[INVENTORY CONNECTOR]: Received entire inventory ({0} folders) for user {1}",
                                      folders.Count, userID);
                    foreach (InventoryFolderBase f in folders)
                    {
                        if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown))
                        {
                            dFolders[(AssetType)f.Type] = f;
                        }
                    }

                    UUID rootFolderID = dFolders[AssetType.Animation].ParentID;
                    InventoryFolderBase rootFolder = new InventoryFolderBase(rootFolderID, new UUID(userID));
                    rootFolder = QueryFolder(userID, rootFolder, sessionID);
                    dFolders[AssetType.Folder] = rootFolder;
                    m_log.DebugFormat("[INVENTORY CONNECTOR]: {0} system folders for user {1}", dFolders.Count, userID);
                    return(dFolders);
                }
            }

            return(new Dictionary <AssetType, InventoryFolderBase>());
        }
Exemple #4
0
        public InventoryFolderBase QueryFolder(string userID, InventoryFolderBase folder, UUID sessionID)
        {
            try
            {
                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, InventoryFolderBase> .BeginPostObject(
                           "POST", m_ServerURI + "/QueryFolder/", folder, sessionID.ToString(), userID));
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: Query inventory folder operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(null);
        }
Exemple #5
0
        public bool UpdateItem(string userID, InventoryItemBase item, UUID sessionID)
        {
            try
            {
                return(SynchronousRestSessionObjectPoster <InventoryItemBase, bool> .BeginPostObject(
                           "POST", m_ServerURI + "/NewItem/", item, sessionID.ToString(), item.Owner.ToString()));
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update new inventory item operation failed for {0} {1}, {2} {3}",
                                  item.Name, item.ID, e.Source, e.Message);
            }

            return(false);
        }
Exemple #6
0
        public bool PurgeFolder(string userID, InventoryFolderBase folder, UUID sessionID)
        {
            try
            {
                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, bool> .BeginPostObject(
                           "POST", m_ServerURI + "/PurgeFolder/", folder, sessionID.ToString(), folder.Owner.ToString()));
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: Purge inventory folder operation failed for {0} {1}, {2} {3}",
                                  folder.Name, folder.ID, e.Source, e.Message);
            }

            return(false);
        }
        public InventoryFolderBase QueryFolder(InventoryFolderBase item, UUID session_id)
        {
            try
            {
                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, InventoryFolderBase> .BeginPostObject(
                           "POST", _inventoryServerUrl + "/QueryFolder/", item, session_id.ToString(), item.Owner.ToString()));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(null);
        }
        /// <summary>
        /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        public bool DeleteItem(InventoryItemBase item, UUID session_id)
        {
            try
            {
                return(SynchronousRestSessionObjectPoster <InventoryItemBase, bool> .BeginPostObject(
                           "POST", _inventoryServerUrl + "/DeleteItem/", item, session_id.ToString(), item.Owner.ToString()));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Delete inventory item operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(false);
        }
        /// <summary>
        /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        public bool PurgeFolder(InventoryFolderBase folder, UUID session_id)
        {
            try
            {
                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, bool> .BeginPostObject(
                           "POST", _inventoryServerUrl + "/PurgeFolder/", folder, session_id.ToString(), folder.Owner.ToString()));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(false);
        }
        public InventoryItemBase GetInventoryItem(InventoryItemBase item)
        {
            System.Console.WriteLine("[HGrid] GetInventory " + item.ID + " from " + ServerURL);
            try
            {
                item = SynchronousRestSessionObjectPoster <Guid, InventoryItemBase> .BeginPostObject("POST", ServerURL + "/GetItem/", item.ID.Guid, String.Empty, String.Empty);

                return(item);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
            return(null);
        }
Exemple #11
0
        public List <InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID sessionID)
        {
            try
            {
                InventoryFolderBase folder = new InventoryFolderBase(folderID, new UUID(userID));
                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, List <InventoryItemBase> > .BeginPostObject(
                           "POST", m_ServerURI + "/GetItems/", folder, sessionID.ToString(), userID));
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed for folder {0}, {1} {2}",
                                  folderID, e.Source, e.Message);
            }

            return(null);
        }
Exemple #12
0
        public int GetAssetPermissions(string userID, UUID assetID, UUID sessionID)
        {
            try
            {
                InventoryItemBase item = new InventoryItemBase();
                item.Owner   = new UUID(userID);
                item.AssetID = assetID;
                return(SynchronousRestSessionObjectPoster <InventoryItemBase, int> .BeginPostObject(
                           "POST", m_ServerURI + "/AssetPermissions/", item, sessionID.ToString(), userID));
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: AssetPermissions operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(0);
        }
Exemple #13
0
        public bool DeleteItems(string userID, List <UUID> items, UUID sessionID)
        {
            try
            {
                List <Guid> guids = new List <Guid>();
                foreach (UUID u in items)
                {
                    guids.Add(u.Guid);
                }
                return(SynchronousRestSessionObjectPoster <List <Guid>, bool> .BeginPostObject(
                           "POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID));
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: Delete inventory items operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(false);
        }
        /// <summary>
        /// Update an item in the user's inventory
        /// </summary>
        /// <param name="item"></param>
        /// <returns>true if the item was successfully updated</returns>
        public bool UpdateItem(InventoryItemBase item, UUID session_id)
        {
            if (IsLocalStandaloneUser(item.Owner))
            {
                return(base.UpdateItem(item));
            }

            try
            {
                string invServ = GetUserInventoryURI(item.Owner);
                return(SynchronousRestSessionObjectPoster <InventoryItemBase, bool> .BeginPostObject(
                           "POST", invServ + "/NewItem/", item, session_id.ToString(), item.Owner.ToString()));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Update new inventory item operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(false);
        }
        /// <summary>
        /// Update a folder in the user's inventory
        /// </summary>
        /// <param name="folder"></param>
        /// <returns>true if the folder was successfully updated</returns>
        public bool UpdateFolder(InventoryFolderBase folder, UUID session_id)
        {
            if (IsLocalStandaloneUser(folder.Owner))
            {
                return(base.UpdateFolder(folder));
            }
            try
            {
                string invServ = GetUserInventoryURI(folder.Owner);

                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, bool> .BeginPostObject(
                           "POST", invServ + "/UpdateFolder/", folder, session_id.ToString(), folder.Owner.ToString()));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Update inventory folder operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(false);
        }
        public InventoryFolderBase QueryFolder(InventoryFolderBase item, UUID session_id)
        {
            if (IsLocalStandaloneUser(item.Owner))
            {
                return(base.QueryFolder(item));
            }

            try
            {
                string invServ = GetUserInventoryURI(item.Owner);

                return(SynchronousRestSessionObjectPoster <InventoryFolderBase, InventoryFolderBase> .BeginPostObject(
                           "POST", invServ + "/QueryFolder/", item, session_id.ToString(), item.Owner.ToString()));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(null);
        }