public GroupDisplayData Load(UUID userId, UUID itemId, GroupLoader.LoaderParams parms)
        {
            OpenSim.Data.IInventoryStorage inv = _invSelector.GetProvider(userId);

            InventoryItemBase item = inv.GetItem(itemId, UUID.Zero);

            if (item == null)
            {
                throw new Exceptions.PrimExporterPermissionException("The item could not be found");
            }

            var asset = _stratus.RequestAssetSync(item.AssetID);

            if (item.Owner != userId)
            {
                throw new Exceptions.PrimExporterPermissionException("You do not own that object");
            }

            if (((parms.Checks & LoaderChecks.UserMustBeCreator) != 0) && item.CreatorIdAsUuid != userId)
            {
                throw new Exceptions.PrimExporterPermissionException("You are not the creator of the base object");
            }

            //get the user name
            string userName = LookupUserName(item.CreatorIdAsUuid);

            //try thoosa first
            SceneObjectGroup sog;

            InventoryObjectSerializer engine = new InventoryObjectSerializer();

            if (engine.CanDeserialize(asset.Data))
            {
                sog = engine.DeserializeGroupFromInventoryBytes(asset.Data);
            }
            else
            {
                sog = SceneXmlLoader.DeserializeGroupFromXml2(Utils.BytesToString(asset.Data));
            }

            return(GroupDisplayDataFromSOG(userId, parms, sog, inv, userName, item));
        }
        private void RecursiveCollectFullPermTextureIds(OpenSim.Data.IInventoryStorage inv, InventoryFolderBase parentFolder, HashSet <UUID> fullPermTextures)
        {
            //depth first
            foreach (var childFolder in parentFolder.SubFolders)
            {
                InventoryFolderBase fullChild = inv.GetFolder(childFolder.ID);
                RecursiveCollectFullPermTextureIds(inv, fullChild, fullPermTextures);
            }

            foreach (var item in parentFolder.Items)
            {
                if (item.AssetType == (int)AssetType.Texture)
                {
                    if (((item.CurrentPermissions & (uint)PermissionMask.Copy) != 0) &&
                        ((item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) &&
                        ((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0))
                    {
                        fullPermTextures.Add(item.AssetID);
                    }
                }
            }
        }
        private HashSet <UUID> CollectFullPermTexturesIfNecessary(ref UUID userId, GroupLoader.LoaderParams parms, OpenSim.Data.IInventoryStorage inv)
        {
            HashSet <UUID> fullPermTextures;

            if ((parms.Checks & LoaderChecks.TexturesMustBeFullPerm) != 0)
            {
                fullPermTextures = new HashSet <UUID>();

                //check the textures folder...
                InventoryFolderBase textureFolder     = inv.FindFolderForType(userId, AssetType.Texture);
                InventoryFolderBase fullTextureFolder = inv.GetFolder(textureFolder.ID);

                if (textureFolder != null)
                {
                    RecursiveCollectFullPermTextureIds(inv, fullTextureFolder, fullPermTextures);
                }
                else
                {
                    throw new ApplicationException("Could not find texture folder");
                }

                InventoryFolderBase objFolder = inv.FindFolderForType(userId, AssetType.Object);
                InventoryFolderBase dsFolder  = null;
                foreach (InventorySubFolderBase subFolder in objFolder.SubFolders)
                {
                    if (subFolder.Name.ToLower() == "dreamshare")
                    {
                        dsFolder = inv.GetFolder(subFolder.ID);
                    }
                }

                if (dsFolder != null)
                {
                    RecursiveCollectFullPermTextureIds(inv, dsFolder, fullPermTextures);
                }

                return(fullPermTextures);
            }

            return(null);
        }