public void TestAddScript()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID userId = TestHelpers.ParseTail(0x1);
//            UUID itemId = TestHelpers.ParseTail(0x2);
            string itemName = "Test Script Item";

            Scene scene = new SceneHelpers().SetupScene();
            SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
            scene.AddNewSceneObject(so, true);

            InventoryItemBase itemTemplate = new InventoryItemBase();
            itemTemplate.Name = itemName;
            itemTemplate.Folder = so.UUID;
            itemTemplate.InvType = (int)InventoryType.LSL;

            SceneObjectPart partWhereScriptAdded = scene.RezNewScript(userId, itemTemplate);

            Assert.That(partWhereScriptAdded, Is.Not.Null);

            IEntityInventory primInventory = partWhereScriptAdded.Inventory;
            Assert.That(primInventory.GetInventoryList().Count, Is.EqualTo(1));
            Assert.That(primInventory.ContainsScripts(), Is.True);

            IList<TaskInventoryItem> primItems = primInventory.GetInventoryItems(itemName);
            Assert.That(primItems.Count, Is.EqualTo(1));
        }
Exemple #2
0
        public static void enforceItemPermitions(InventoryItemBase it, bool IsCreator)
        {
            if (it == null)
                return;

            uint bp;
            uint np;

            if (IsCreator)
            {
                bp = createBasePermitions;
                np = createNextPermitions;
            }
            else
            {
                bp = allowedBasePermitions;
                np = allowedNextPermitions;
            }

            it.BasePermissions &= bp;
            it.CurrentPermissions &= bp;
            //            it.GroupPermissions &= allowedPermitions;
            it.NextPermissions &= np;
            //            it.EveryOnePermissions &= allowedPermitions;
            it.GroupPermissions = 0;
            it.EveryOnePermissions = 0;
        }
 public void ApplyToOther(InventoryItemBase other)
 {
     other.BasePermissions = this.BasePermissions;
     other.NextPermissions = this.NextPermissions;
     other.EveryOnePermissions = this.EveryOnePermissions;
     other.GroupPermissions = this.GroupPermissions;
     other.CurrentPermissions = this.CurrentPermissions;
 }
Exemple #4
0
        public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
        {
            IMoneyModule money=RequestModuleInterface<IMoneyModule>();
            if (money != null)
            {
                money.ApplyUploadCharge(agentID);
            }

            AddInventoryItem(agentID, item);
        }
        public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);

            OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["items"];

            string reply;
            LLSDFetchInventory llsdReply = new LLSDFetchInventory();

            UUID[] itemIDs = new UUID[itemsRequested.Count];
            int i = 0;

            foreach (OSDMap osdItemId in itemsRequested)
            {
                itemIDs[i++] = osdItemId["item_id"].AsUUID();
            }

            InventoryItemBase[] items = null;

            if (m_agentID != UUID.Zero)
            {
                items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);

                if (items == null)
                {
                    // OMG!!! One by one!!! This is fallback code, in case the backend isn't updated
                    m_log.WarnFormat("[FETCH INVENTORY HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one.");
                    items = new InventoryItemBase[itemsRequested.Count];                   
                    foreach (UUID id in itemIDs)
                        items[i++] = m_inventoryService.GetItem(m_agentID, id);
                }
            }
            else
            {
                items = new InventoryItemBase[itemsRequested.Count];
                foreach (UUID id in itemIDs)
                    items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
            }

            foreach (InventoryItemBase item in items)
            {
                if (item != null)
                {
                    // We don't know the agent that this request belongs to so we'll use the agent id of the item
                    // which will be the same for all items.
                    llsdReply.agent_id = item.Owner;
                    llsdReply.items.Array.Add(ConvertInventoryItem(item));
                }
            }

            reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);

            return reply;
        }
        private void Init()
        {
            // Create an inventory that looks like this:
            //
            // /My Inventory
            //   <other system folders>
            //   /Objects
            //      Object 1
            //      Object 2
            //      Object 3
            //   /Notecards
            //      Notecard 1
            //      Notecard 2
            //      Notecard 3
            //      Notecard 4
            //      Notecard 5

            m_scene = new SceneHelpers().SetupScene();

            m_scene.InventoryService.CreateUserInventory(m_userID);

            m_rootFolderID = m_scene.InventoryService.GetRootFolder(m_userID).ID;

            InventoryFolderBase of = m_scene.InventoryService.GetFolderForType(m_userID, AssetType.Object);
            m_objectsFolder = of.ID;

            // Add 3 objects
            InventoryItemBase item;
            for (int i = 1; i <= 3; i++)
            {
                item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-0000000000b" + i), m_userID);
                item.AssetID = UUID.Random();
                item.AssetType = (int)AssetType.Object;
                item.Folder = m_objectsFolder;
                item.Name = "Object " + i;
                m_scene.InventoryService.AddItem(item);
            }

            InventoryFolderBase ncf = m_scene.InventoryService.GetFolderForType(m_userID, AssetType.Notecard);
            m_notecardsFolder = ncf.ID;

            // Add 5 notecards
            for (int i = 1; i <= 5; i++)
            {
                item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-00000000000" + i), m_userID);
                item.AssetID = UUID.Random();
                item.AssetType = (int)AssetType.Notecard;
                item.Folder = m_notecardsFolder;
                item.Name = "Notecard " + i;
                m_scene.InventoryService.AddItem(item);
            }

        }
        public bool AddInventoryItemReturned(UUID AgentId, InventoryItemBase item)
        {
            if (AddInventoryItem(item))
                return true;
            else
            {
                m_log.WarnFormat(
                    "[AGENT INVENTORY]: Unable to add item {1} to agent {2} inventory", item.Name, AgentId);

                return false;
            }
        }
Exemple #8
0
        public static void setCreateItemPermitions(InventoryItemBase it)
        {
            if (it == null)
                return;

            it.BasePermissions = createBasePermitions;
            it.CurrentPermissions = createBasePermitions;
            //            it.GroupPermissions &= allowedPermitions;
            it.NextPermissions = createNextPermitions;
            //            it.EveryOnePermissions &= allowedPermitions;
            it.GroupPermissions = 0;
            it.EveryOnePermissions = 0;
        }
        public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
        {
            item = null;
            BackendResponse ret;

            InventoryCollection collection;
            if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item))
                ret = BackendResponse.Success;
            else
                ret = BackendResponse.NotFound;

            server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
            return ret;
        }
        public virtual void DeactivateGesture(IClientAPI client, UUID gestureId)
        {
            IInventoryService invService = m_scene.InventoryService;

            InventoryItemBase item = new InventoryItemBase(gestureId, client.AgentId);
            item = invService.GetItem(item);
            if (item != null)
            {
                item.Flags = 0;
                invService.UpdateItem(item);
            }
            else 
                m_log.ErrorFormat(
                    "[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name);
        }
        public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
        {
            IMoneyModule money = RequestModuleInterface<IMoneyModule>();
            if (money != null)
            {
                if (!money.AmountCovered(GetScenePresence(agentID).ControllingClient, money.UploadCharge))
                {
                    GetScenePresence(agentID).ControllingClient.SendAlertMessage("You do not have enough money to complete this upload.");
                    return;
                }
                money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload");
            }

            AddInventoryItem(item);
        }
 public static InventoryItemBase CreateInventoryItem(
     Scene scene, string itemName, UUID itemId, string folderPath, UUID userId)
 {
     InventoryItemBase item = new InventoryItemBase();
     item.Name = itemName;
     item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID;
     item.ID = itemId;
     
     // Really quite bad since the objs folder could be moved in the future and confuse the tests
     InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
     
     item.Folder = objsFolder.ID;
     scene.AddInventoryItem(item);
     
     return item;
 }
        public bool AddInventoryItemReturned(UUID AgentId, InventoryItemBase item)
        {
            CachedUserInfo userInfo
                = CommsManager.UserService.GetUserDetails(AgentId);
            if (userInfo != null)
            {
                userInfo.AddItem(item);
                return true;
            }
            else
            {
                m_log.ErrorFormat(
                    "[AGENT INVENTORY]: Agent was not found for add of item {1} {2}", item.Name, item.ID);

                return false;
            }
        }
        /// <summary>
        /// Creates a notecard in the objects folder and specify an item id.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID itemId, UUID userId)
        {
            AssetBase asset = AssetHelpers.CreateAsset(scene, userId);
            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)InventoryType.Notecard;

            InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
            
            item.Folder = folder.ID;
            scene.AddInventoryItem(item);
            
            return item;
        }
        /// <summary>
        /// Deserialize item
        /// </summary>
        /// <param name="serializedSettings"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static InventoryItemBase Deserialize(byte[] serialization)
        {
            InventoryItemBase item = new InventoryItemBase();

            StringReader reader = new StringReader (Encoding.ASCII.GetString (serialization, 0, serialization.Length));
            XmlReader xtr = XmlTextReader.Create (reader);
            //Uses byte[] directly... should be used once issues with it are fixed
            //MemoryStream mr = new MemoryStream (serialization);
            //StreamReader sr = new StreamReader (mr, Encoding.ASCII);
            //XmlReader xtr = XmlTextReader.Create (sr);
            xtr.ReadStartElement ("InventoryItem");
            
            item.Name = xtr.ReadElementString("Name");
            item.ID = UUID.Parse(xtr.ReadElementString("ID"));
            item.InvType = Convert.ToInt32(xtr.ReadElementString("InvType"));
            item.CreatorId = xtr.ReadElementString ("CreatorUUID");
            try
            {
                item.CreatorData = xtr.ReadElementString ("CreatorData");
            }
            catch
            {
            }
            item.CreationDate = Convert.ToInt32 (xtr.ReadElementString ("CreationDate"));
            item.Owner = UUID.Parse(xtr.ReadElementString("Owner"));
            item.Description = xtr.ReadElementString("Description");
            item.AssetType = Convert.ToInt32(xtr.ReadElementString("AssetType"));
            item.AssetID = UUID.Parse(xtr.ReadElementString("AssetID"));
            item.SaleType = Convert.ToByte(xtr.ReadElementString("SaleType"));
            item.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice"));
            item.BasePermissions = Convert.ToUInt32(xtr.ReadElementString("BasePermissions"));
            item.CurrentPermissions = Convert.ToUInt32(xtr.ReadElementString("CurrentPermissions"));
            item.EveryOnePermissions = Convert.ToUInt32(xtr.ReadElementString("EveryOnePermissions"));
            item.NextPermissions = Convert.ToUInt32(xtr.ReadElementString("NextPermissions"));
            item.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags"));
            item.GroupID = UUID.Parse(xtr.ReadElementString("GroupID"));
            item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned"));

            xtr.ReadEndElement();

            xtr.Close();

            return item;
        }
        /// <summary>
        /// Creates a notecard in the objects folder and specify an item id.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="itemType"></param>
        /// <param name="asset">The serialized asset for this item</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        private static InventoryItemBase AddInventoryItem(
            Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
        {
            scene.AssetService.Store(asset);

            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)itemType;

            InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);

            item.Folder = folder.ID;
            scene.AddInventoryItem(item);

            return item;
        }
Exemple #17
0
        public void RequestAsset(InventoryItemBase item, bool isTexture)
        {
            bool fetch = true;
            lock (pendingRequests)
            {
                if (!pendingRequests.ContainsKey(item.AssetID))
                {
                    pendingRequests.Add(item.AssetID, isTexture);
                    Console.WriteLine("    >>> RequestAsset Added " + item.AssetID);
                }
                else
                    fetch = false;
            }

            if (fetch)
            {
                string uri = URL + "/GetAsset/" + item.ID + "/";
                if (!OpenSimComms.RequestAsset(uri, item, AssetCallback))
                    receiver.AssetNotFound(item.AssetID, isTexture);
            }
        }
        // These are copied from the Inventory Item tests 

        private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
        {
            InventoryItemBase i = new InventoryItemBase();
            i.ID = id;
            i.Folder = parent;
            i.Owner = owner;
            i.CreatorId = owner.ToString();
            i.Name = name;
            i.Description = name;
            i.AssetID = asset;
            return i;
        }
 public void T025_PrimInventoryPersistency()
 {
     InventoryItemBase i = new InventoryItemBase();
     UUID id = UUID.Random();
     i.ID = id;
     UUID folder = UUID.Random();
     i.Folder = folder;
     UUID owner = UUID.Random();
     i.Owner = owner;
     UUID creator = UUID.Random();
     i.CreatorId = creator.ToString();
     string name = RandomName();
     i.Name = name;
     i.Description = name;
     UUID assetid = UUID.Random();
     i.AssetID = assetid;
     int invtype = random.Next();
     i.InvType = invtype;
     uint nextperm = (uint) random.Next();
     i.NextPermissions = nextperm;
     uint curperm = (uint) random.Next();
     i.CurrentPermissions = curperm;
     uint baseperm = (uint) random.Next();
     i.BasePermissions = baseperm;
     uint eoperm = (uint) random.Next();
     i.EveryOnePermissions = eoperm;
     int assettype = random.Next();
     i.AssetType = assettype;
     UUID groupid = UUID.Random();
     i.GroupID = groupid;
     bool groupown = true;
     i.GroupOwned = groupown;
     int saleprice = random.Next();
     i.SalePrice = saleprice;
     byte saletype = (byte) random.Next(127);
     i.SaleType = saletype;
     uint flags = (uint) random.Next();
     i.Flags = flags;
     int creationd = random.Next();
     i.CreationDate = creationd;
     
     SceneObjectGroup sog = FindSOG("object1", region1);
     Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
     TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
     
     Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))");
     Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))");
     Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))");
     Assert.That(t.CreationDate,Is.EqualTo(creationd), "Assert.That(t.CreationDate,Is.EqualTo(creationd))");
     Assert.That(t.CreatorID,Is.EqualTo(creator), "Assert.That(t.CreatorID,Is.EqualTo(creator))");
     Assert.That(t.Description,Is.EqualTo(name), "Assert.That(t.Description,Is.EqualTo(name))");
     Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm), "Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm))");
     Assert.That(t.Flags,Is.EqualTo(flags), "Assert.That(t.Flags,Is.EqualTo(flags))");
     Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID), "Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID))");
     // Where is this group permissions??
     // Assert.That(t.GroupPermissions,Is.EqualTo(), "Assert.That(t.GroupPermissions,Is.EqualTo())");
     Assert.That(t.Type,Is.EqualTo(assettype), "Assert.That(t.Type,Is.EqualTo(assettype))");
     Assert.That(t.InvType, Is.EqualTo(invtype), "Assert.That(t.InvType, Is.EqualTo(invtype))");
     Assert.That(t.ItemID, Is.EqualTo(id), "Assert.That(t.ItemID, Is.EqualTo(id))");
     Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID), "Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID))");
     Assert.That(t.NextPermissions, Is.EqualTo(nextperm), "Assert.That(t.NextPermissions, Is.EqualTo(nextperm))");
     // Ownership changes when you drop an object into an object
     // owned by someone else
     Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))");
     Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))");
     Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))");
     Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))");
 }
Exemple #20
0
        /// <summary>
        /// Apply next owner permissions.
        /// </summary>

        private void ApplyNextOwnerPermissions(InventoryItemBase item)
        {
            if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
            {
                if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
                    item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
                if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
                    item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
                if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
                    item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
            }
            item.CurrentPermissions &= item.NextPermissions;
            item.BasePermissions &= item.NextPermissions;
            item.EveryOnePermissions &= item.NextPermissions;
            // item.OwnerChanged = true;
            // item.PermsMask = 0;
            // item.PermsGranter = UUID.Zero;
        }
Exemple #21
0
        /// <summary>
        /// This method is called if a given model avatar name can not be found. If the external
        /// file has already been loaded once, then control returns immediately. If not, then it
        /// looks for a default appearance file. This file contains XML definitions of zero or more named
        /// avatars, each avatar can specify zero or more "outfits". Each outfit is a collection
        /// of items that together, define a particular ensemble for the avatar. Each avatar should
        /// indicate which outfit is the default, and this outfit will be automatically worn. The
        /// other outfits are provided to allow "real" avatars a way to easily change their outfits.
        /// </summary>
        private bool CreateDefaultAvatars()
        {
            // Only load once
            if (m_defaultAvatarsLoaded)
            {
                return false;
            }

            m_log.DebugFormat("[RADMIN]: Creating default avatar entries");

            m_defaultAvatarsLoaded = true;

            // Load processing starts here...

            try
            {
                string defaultAppearanceFileName = null;

                //m_config may be null if RemoteAdmin configuration secition is missing or disabled in OpenSim.ini
                if (m_config != null)
                {
                    defaultAppearanceFileName = m_config.GetString("default_appearance", "default_appearance.xml");
                }

                if (File.Exists(defaultAppearanceFileName))
                {
                    XmlDocument doc = new XmlDocument();
                    string name     = "*unknown*";
                    string email    = "anon@anon";
                    uint   regionXLocation     = 1000;
                    uint   regionYLocation     = 1000;
                    string password   = UUID.Random().ToString(); // No requirement to sign-in.
                    UUID ID = UUID.Zero;
                    AvatarAppearance avatarAppearance;
                    XmlNodeList avatars;
                    XmlNodeList assets;
                    XmlNode perms = null;
                    bool include = false;
                    bool select  = false;

                    Scene scene = m_application.SceneManager.CurrentOrFirstScene;
                    IInventoryService inventoryService = scene.InventoryService;
                    IAssetService assetService = scene.AssetService;

                    doc.LoadXml(File.ReadAllText(defaultAppearanceFileName));

                    // Load up any included assets. Duplicates will be ignored
                    assets = doc.GetElementsByTagName("RequiredAsset");
                    foreach (XmlNode assetNode in assets)
                    {
                        AssetBase asset = new AssetBase(UUID.Random(), GetStringAttribute(assetNode, "name", ""), SByte.Parse(GetStringAttribute(assetNode, "type", "")), UUID.Zero.ToString());
                        asset.Description = GetStringAttribute(assetNode,"desc","");
                        asset.Local       = Boolean.Parse(GetStringAttribute(assetNode,"local",""));
                        asset.Temporary   = Boolean.Parse(GetStringAttribute(assetNode,"temporary",""));
                        asset.Data        = Convert.FromBase64String(assetNode.InnerText);
                        assetService.Store(asset);
                    }

                    avatars = doc.GetElementsByTagName("Avatar");

                    // The document may contain multiple avatars

                    foreach (XmlElement avatar in avatars)
                    {
                        m_log.DebugFormat("[RADMIN]: Loading appearance for {0}, gender = {1}",
                            GetStringAttribute(avatar,"name","?"), GetStringAttribute(avatar,"gender","?"));

                        // Create the user identified by the avatar entry

                        try
                        {
                            // Only the name value is mandatory
                            name   = GetStringAttribute(avatar,"name",name);
                            email  = GetStringAttribute(avatar,"email",email);
                            regionXLocation   = GetUnsignedAttribute(avatar,"regx",regionXLocation);
                            regionYLocation   = GetUnsignedAttribute(avatar,"regy",regionYLocation);
                            password = GetStringAttribute(avatar,"password",password);

                            string[] names = name.Split();
                            UUID scopeID = scene.RegionInfo.ScopeID;
                            UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, names[0], names[1]);
                            if (null == account)
                            {
                                account = CreateUser(scopeID, names[0], names[1], password, email);
                                if (null == account)
                                {
                                    m_log.ErrorFormat("[RADMIN]: Avatar {0} {1} was not created", names[0], names[1]);
                                    return false;
                                }
                            }

                            // Set home position

                            GridRegion home = scene.GridService.GetRegionByPosition(scopeID, 
                                (int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
                            if (null == home) {
                                m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", names[0], names[1]);
                            } else {
                                scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
                                m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, names[0], names[1]);
                            }

                            ID = account.PrincipalID;

                            m_log.DebugFormat("[RADMIN]: User {0}[{1}] created or retrieved", name, ID);
                            include = true;
                        }
                        catch (Exception e)
                        {
                            m_log.DebugFormat("[RADMIN]: Error creating user {0} : {1}", name, e.Message);
                            include = false;
                        }

                        // OK, User has been created OK, now we can install the inventory.
                        // First retrieve the current inventory (the user may already exist)
                        // Note that althought he inventory is retrieved, the hierarchy has
                        // not been interpreted at all.

                        if (include)
                        {
                            // Setup for appearance processing
                            avatarAppearance = scene.AvatarService.GetAppearance(ID);
                            if (avatarAppearance == null)
                                avatarAppearance = new AvatarAppearance();

                            AvatarWearable[] wearables = avatarAppearance.Wearables;
                            for (int i=0; i<wearables.Length; i++)
                            {
                                wearables[i] = new AvatarWearable();
                            }

                            try
                            {
                                // m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory",
                                //   uic.folders.Count, uic.items.Count);

                                InventoryFolderBase clothingFolder = inventoryService.GetFolderForType(ID, AssetType.Clothing);

                                // This should *never* be the case
                                if (clothingFolder == null || clothingFolder.Type != (short)AssetType.Clothing)
                                {
                                    clothingFolder = new InventoryFolderBase();
                                    clothingFolder.ID       = UUID.Random();
                                    clothingFolder.Name     = "Clothing";
                                    clothingFolder.Owner    = ID;
                                    clothingFolder.Type     = (short)AssetType.Clothing;
                                    clothingFolder.ParentID = inventoryService.GetRootFolder(ID).ID;
                                    clothingFolder.Version  = 1;
                                    inventoryService.AddFolder(clothingFolder);     // store base record
                                    m_log.ErrorFormat("[RADMIN]: Created clothing folder for {0}/{1}", name, ID);
                                }

                                // OK, now we have an inventory for the user, read in the outfits from the
                                // default appearance XMl file.

                                XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble");
                                InventoryFolderBase extraFolder;
                                string outfitName;
                                UUID assetid;

                                foreach (XmlElement outfit in outfits)
                                {
                                    m_log.DebugFormat("[RADMIN]: Loading outfit {0} for {1}",
                                        GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?"));

                                    outfitName   = GetStringAttribute(outfit,"name","");
                                    select  = (GetStringAttribute(outfit,"default","no") == "yes");

                                    // If the folder already exists, re-use it. The defaults may
                                    // change over time. Augment only.

                                    List<InventoryFolderBase> folders = inventoryService.GetFolderContent(ID, clothingFolder.ID).Folders;
                                    extraFolder = null;

                                    foreach (InventoryFolderBase folder in folders)
                                    {
                                    if (folder.Name == outfitName)
                                        {
                                            extraFolder = folder;
                                            break;
                                        }
                                    }

                                    // Otherwise, we must create the folder.
                                    if (extraFolder == null)
                                    {
                                        m_log.DebugFormat("[RADMIN]: Creating outfit folder {0} for {1}", outfitName, name);
                                        extraFolder          = new InventoryFolderBase();
                                        extraFolder.ID       = UUID.Random();
                                        extraFolder.Name     = outfitName;
                                        extraFolder.Owner    = ID;
                                        extraFolder.Type     = (short)AssetType.Clothing;
                                        extraFolder.Version  = 1;
                                        extraFolder.ParentID = clothingFolder.ID;
                                        inventoryService.AddFolder(extraFolder);
                                        m_log.DebugFormat("[RADMIN]: Adding outfile folder {0} to folder {1}", extraFolder.ID, clothingFolder.ID);
                                    }

                                    // Now get the pieces that make up the outfit
                                    XmlNodeList items = outfit.GetElementsByTagName("Item");

                                    foreach (XmlElement item in items)
                                    {
                                        assetid = UUID.Zero;
                                        XmlNodeList children = item.ChildNodes;
                                        foreach (XmlNode child in children)
                                        {
                                            switch (child.Name)
                                            {
                                                case "Permissions" :
                                                    m_log.DebugFormat("[RADMIN]: Permissions specified");
                                                    perms = child;
                                                    break;
                                                case "Asset" :
                                                    assetid = new UUID(child.InnerText);
                                                    break;
                                            }
                                        }

                                        InventoryItemBase inventoryItem = null;

                                        // Check if asset is in inventory already
                                        inventoryItem = null;
                                        List<InventoryItemBase> inventoryItems = inventoryService.GetFolderContent(ID, extraFolder.ID).Items;

                                        foreach (InventoryItemBase listItem in inventoryItems)
                                        {
                                            if (listItem.AssetID == assetid)
                                            {
                                                inventoryItem = listItem;
                                                break;
                                            }
                                        }

                                        // Create inventory item
                                        if (inventoryItem == null)
                                        {
                                            inventoryItem = new InventoryItemBase(UUID.Random(), ID);
                                            inventoryItem.Name = GetStringAttribute(item,"name","");
                                            inventoryItem.Description = GetStringAttribute(item,"desc","");
                                            inventoryItem.InvType = GetIntegerAttribute(item,"invtype",-1);
                                            inventoryItem.CreatorId = GetStringAttribute(item,"creatorid","");
                                            inventoryItem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid","");
                                            inventoryItem.CreatorData = GetStringAttribute(item, "creatordata", "");
                                            inventoryItem.NextPermissions = GetUnsignedAttribute(perms, "next", 0x7fffffff);
                                            inventoryItem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff);
                                            inventoryItem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff);
                                            inventoryItem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff);
                                            inventoryItem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff);
                                            inventoryItem.AssetType = GetIntegerAttribute(item,"assettype",-1);
                                            inventoryItem.AssetID = assetid; // associated asset
                                            inventoryItem.GroupID = (UUID)GetStringAttribute(item,"groupid","");
                                            inventoryItem.GroupOwned = (GetStringAttribute(item,"groupowned","false") == "true");
                                            inventoryItem.SalePrice = GetIntegerAttribute(item,"saleprice",0);
                                            inventoryItem.SaleType = (byte)GetIntegerAttribute(item,"saletype",0);
                                            inventoryItem.Flags = GetUnsignedAttribute(item,"flags",0);
                                            inventoryItem.CreationDate = GetIntegerAttribute(item,"creationdate",Util.UnixTimeSinceEpoch());
                                            inventoryItem.Folder = extraFolder.ID; // Parent folder

                                            m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(inventoryItem);
                                            m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", inventoryItem.ID, extraFolder.ID);
                                        }

                                        // Attach item, if attachpoint is specified
                                        int attachpoint = GetIntegerAttribute(item,"attachpoint",0);
                                        if (attachpoint != 0)
                                        {
                                            avatarAppearance.SetAttachment(attachpoint, inventoryItem.ID, inventoryItem.AssetID);
                                            m_log.DebugFormat("[RADMIN]: Attached {0}", inventoryItem.ID);
                                        }

                                        // Record whether or not the item is to be initially worn
                                        try
                                        {
                                        if (select && (GetStringAttribute(item, "wear", "false") == "true"))
                                            {
                                                avatarAppearance.Wearables[inventoryItem.Flags].Wear(inventoryItem.ID, inventoryItem.AssetID);
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                            m_log.WarnFormat("[RADMIN]: Error wearing item {0} : {1}", inventoryItem.ID, e.Message);
                                        }
                                    } // foreach item in outfit
                                    m_log.DebugFormat("[RADMIN]: Outfit {0} load completed", outfitName);
                                } // foreach outfit
                                m_log.DebugFormat("[RADMIN]: Inventory update complete for {0}", name);
                                scene.AvatarService.SetAppearance(ID, avatarAppearance);
                            }
                            catch (Exception e)
                            {
                                m_log.WarnFormat("[RADMIN]: Inventory processing incomplete for user {0} : {1}",
                                    name, e.Message);
                            }
                        } // End of include
                    }
                    m_log.DebugFormat("[RADMIN]: Default avatar loading complete");
                }
                else
                {
                    m_log.DebugFormat("[RADMIN]: No default avatar information available");
                    return false;
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[RADMIN]: Exception whilst loading default avatars ; {0}", e.Message);
                return false;
            }

            return true;
        }
Exemple #22
0
        /// <summary>
        /// This method is called by establishAppearance to do a copy all inventory items
        /// worn or attached to the Clothing inventory folder of the receiving avatar.
        /// In parallel the avatar wearables and attachments are updated.
        /// </summary>

        private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
        {
            IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService;

            // Get Clothing folder of receiver
            InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, AssetType.Clothing);

            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // Missing destination folder? This should *never* be the case
            if (destinationFolder.Type != (short)AssetType.Clothing)
            {
                destinationFolder = new InventoryFolderBase();
                
                destinationFolder.ID       = UUID.Random();
                destinationFolder.Name     = "Clothing";
                destinationFolder.Owner    = destination;
                destinationFolder.Type     = (short)AssetType.Clothing;
                destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID;
                destinationFolder.Version  = 1;
                inventoryService.AddFolder(destinationFolder);     // store base record
                m_log.ErrorFormat("[RADMIN]: Created folder for destination {0}", source);
            }

            // Wearables
            AvatarWearable[] wearables = avatarAppearance.Wearables;
            AvatarWearable wearable;

            for (int i=0; i<wearables.Length; i++)
            {
                wearable = wearables[i];
                if (wearable[0].ItemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = new InventoryItemBase(wearable[0].ItemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
                        destinationItem.Name = item.Name;
                        destinationItem.Owner = destination;
                        destinationItem.Description = item.Description;
                        destinationItem.InvType = item.InvType;
                        destinationItem.CreatorId = item.CreatorId;
                        destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
                        destinationItem.CreatorData = item.CreatorData;
                        destinationItem.NextPermissions = item.NextPermissions;
                        destinationItem.CurrentPermissions = item.CurrentPermissions;
                        destinationItem.BasePermissions = item.BasePermissions;
                        destinationItem.EveryOnePermissions = item.EveryOnePermissions;
                        destinationItem.GroupPermissions = item.GroupPermissions;
                        destinationItem.AssetType = item.AssetType;
                        destinationItem.AssetID = item.AssetID;
                        destinationItem.GroupID = item.GroupID;
                        destinationItem.GroupOwned = item.GroupOwned;
                        destinationItem.SalePrice = item.SalePrice;
                        destinationItem.SaleType = item.SaleType;
                        destinationItem.Flags = item.Flags;
                        destinationItem.CreationDate = item.CreationDate;
                        destinationItem.Folder = destinationFolder.ID;
                        ApplyNextOwnerPermissions(destinationItem);

                        m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
                        m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);

                        // Wear item
                        AvatarWearable newWearable = new AvatarWearable();
                        newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
                        avatarAppearance.SetWearable(i, newWearable);
                    }
                    else
                    {
                        m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
                    }
                }
            }

            // Attachments
            List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();

            foreach (AvatarAttachment attachment in attachments)
            {
                int attachpoint = attachment.AttachPoint;
                UUID itemID = attachment.ItemID;

                if (itemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = new InventoryItemBase(itemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
                        destinationItem.Name = item.Name;
                        destinationItem.Owner = destination;
                        destinationItem.Description = item.Description;
                        destinationItem.InvType = item.InvType;
                        destinationItem.CreatorId = item.CreatorId;
                        destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
                        destinationItem.CreatorData = item.CreatorData;
                        destinationItem.NextPermissions = item.NextPermissions;
                        destinationItem.CurrentPermissions = item.CurrentPermissions;
                        destinationItem.BasePermissions = item.BasePermissions;
                        destinationItem.EveryOnePermissions = item.EveryOnePermissions;
                        destinationItem.GroupPermissions = item.GroupPermissions;
                        destinationItem.AssetType = item.AssetType;
                        destinationItem.AssetID = item.AssetID;
                        destinationItem.GroupID = item.GroupID;
                        destinationItem.GroupOwned = item.GroupOwned;
                        destinationItem.SalePrice = item.SalePrice;
                        destinationItem.SaleType = item.SaleType;
                        destinationItem.Flags = item.Flags;
                        destinationItem.CreationDate = item.CreationDate;
                        destinationItem.Folder = destinationFolder.ID;
                        ApplyNextOwnerPermissions(destinationItem);

                        m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
                        m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);

                        // Attach item
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        m_log.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                    else
                    {
                        m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID);
                    }
                }
            }


        }
Exemple #23
0
        /// <summary>
        /// This method is called by establishAppearance to copy inventory folders to make
        /// copies of Clothing and Bodyparts inventory folders and attaches worn attachments
        /// </summary>

        private void CopyInventoryFolders(UUID destination, UUID source, AssetType assetType, Dictionary<UUID,UUID> inventoryMap,
                                          AvatarAppearance avatarAppearance)
        {
            IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService;

            InventoryFolderBase sourceFolder = inventoryService.GetFolderForType(source, assetType);
            InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, assetType);

            if (sourceFolder == null || destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // Missing source folder? This should *never* be the case
            if (sourceFolder.Type != (short)assetType)
            {
                sourceFolder = new InventoryFolderBase();
                sourceFolder.ID       = UUID.Random();
                if (assetType == AssetType.Clothing) {
                    sourceFolder.Name     = "Clothing";
                } else {
                    sourceFolder.Name     = "Body Parts";
                }
                sourceFolder.Owner    = source;
                sourceFolder.Type     = (short)assetType;
                sourceFolder.ParentID = inventoryService.GetRootFolder(source).ID;
                sourceFolder.Version  = 1;
                inventoryService.AddFolder(sourceFolder);     // store base record
                m_log.ErrorFormat("[RADMIN] Created folder for source {0}", source);
            }

            // Missing destination folder? This should *never* be the case
            if (destinationFolder.Type != (short)assetType)
            {
                destinationFolder = new InventoryFolderBase();
                destinationFolder.ID       = UUID.Random();
                if (assetType == AssetType.Clothing) {
                    destinationFolder.Name  = "Clothing";
                } else {
                    destinationFolder.Name  = "Body Parts";
                }
                destinationFolder.Owner    = destination;
                destinationFolder.Type     = (short)assetType;
                destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID;
                destinationFolder.Version  = 1;
                inventoryService.AddFolder(destinationFolder);     // store base record
                m_log.ErrorFormat("[RADMIN]: Created folder for destination {0}", source);
            }

            InventoryFolderBase extraFolder;
            List<InventoryFolderBase> folders = inventoryService.GetFolderContent(source, sourceFolder.ID).Folders;

            foreach (InventoryFolderBase folder in folders)
            {

                extraFolder = new InventoryFolderBase();
                extraFolder.ID = UUID.Random();
                extraFolder.Name = folder.Name;
                extraFolder.Owner = destination;
                extraFolder.Type = folder.Type;
                extraFolder.Version = folder.Version;
                extraFolder.ParentID = destinationFolder.ID;
                inventoryService.AddFolder(extraFolder);

                m_log.DebugFormat("[RADMIN]: Added folder {0} to folder {1}", extraFolder.ID, sourceFolder.ID);

                List<InventoryItemBase> items = inventoryService.GetFolderContent(source, folder.ID).Items;

                foreach (InventoryItemBase item in items)
                {
                    InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
                    destinationItem.Name = item.Name;
                    destinationItem.Owner = destination;
                    destinationItem.Description = item.Description;
                    destinationItem.InvType = item.InvType;
                    destinationItem.CreatorId = item.CreatorId;
                    destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
                    destinationItem.CreatorData = item.CreatorData;
                    destinationItem.NextPermissions = item.NextPermissions;
                    destinationItem.CurrentPermissions = item.CurrentPermissions;
                    destinationItem.BasePermissions = item.BasePermissions;
                    destinationItem.EveryOnePermissions = item.EveryOnePermissions;
                    destinationItem.GroupPermissions = item.GroupPermissions;
                    destinationItem.AssetType = item.AssetType;
                    destinationItem.AssetID = item.AssetID;
                    destinationItem.GroupID = item.GroupID;
                    destinationItem.GroupOwned = item.GroupOwned;
                    destinationItem.SalePrice = item.SalePrice;
                    destinationItem.SaleType = item.SaleType;
                    destinationItem.Flags = item.Flags;
                    destinationItem.CreationDate = item.CreationDate;
                    destinationItem.Folder = extraFolder.ID;
                    ApplyNextOwnerPermissions(destinationItem);

                    m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
                    inventoryMap.Add(item.ID, destinationItem.ID);
                    m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, extraFolder.ID);

                    // Attach item, if original is attached
                    int attachpoint = avatarAppearance.GetAttachpoint(item.ID);
                    if (attachpoint != 0)
                    {
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        m_log.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                }
            }
        }
        protected XInventoryItem ConvertFromOpenSim(InventoryItemBase item)
        {
            XInventoryItem newItem = new XInventoryItem();

            newItem.assetID = item.AssetID;
            newItem.assetType = item.AssetType;
            newItem.inventoryName = item.Name;
            newItem.avatarID = item.Owner;
            newItem.inventoryID = item.ID;
            newItem.invType = item.InvType;
            newItem.parentFolderID = item.Folder;
            newItem.creatorID = item.CreatorId;
            newItem.inventoryDescription = item.Description;
            newItem.inventoryNextPermissions = (int)item.NextPermissions;
            newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions;
            newItem.inventoryBasePermissions = (int)item.BasePermissions;
            newItem.inventoryEveryOnePermissions = (int)item.EveryOnePermissions;
            newItem.inventoryGroupPermissions = (int)item.GroupPermissions;
            newItem.groupID = item.GroupID;
            if (item.GroupOwned)
                newItem.groupOwned = 1;
            else
                newItem.groupOwned = 0;
            newItem.salePrice = item.SalePrice;
            newItem.saleType = (int)item.SaleType;
            newItem.flags = (int)item.Flags;
            newItem.creationDate = item.CreationDate;

            return newItem;
        }
        protected void ConstructDefaultIarBytesForTestLoad()
        {
//            log4net.Config.XmlConfigurator.Configure();
            
            InventoryArchiverModule archiverModule = new InventoryArchiverModule();
            Scene scene = SceneSetupHelpers.SetupScene();
            SceneSetupHelpers.SetupSceneModules(scene, archiverModule);            
            
            UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");

            MemoryStream archiveWriteStream = new MemoryStream();
            
            // Create scene object asset
            UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
            SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);         

            UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
            scene.AssetService.Store(asset1);            

            // Create scene object item
            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = m_item1Name;
            item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");            
            item1.AssetID = asset1.FullID;
            item1.GroupID = UUID.Random();
            item1.CreatorIdAsUuid = m_uaLL1.PrincipalID;
            item1.Owner = m_uaLL1.PrincipalID;
            item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;            
            scene.AddInventoryItem(item1);
            
            // Create coalesced objects asset
            SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);
            cobj1.AbsolutePosition = new Vector3(15, 30, 45);
            
            SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);
            cobj2.AbsolutePosition = new Vector3(25, 50, 75);               
            
            CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2);
            
            AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa);
            scene.AssetService.Store(coaAsset);            
            
            // Create coalesced objects inventory item
            InventoryItemBase coaItem = new InventoryItemBase();
            coaItem.Name = m_coaItemName;
            coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180");            
            coaItem.AssetID = coaAsset.FullID;
            coaItem.GroupID = UUID.Random();
            coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID;
            coaItem.Owner = m_uaLL1.PrincipalID;
            coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;            
            scene.AddInventoryItem(coaItem);            
            
            archiverModule.ArchiveInventory(
                Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream);            
            
            m_iarStreamBytes = archiveWriteStream.ToArray();
        }
        protected InventoryItemBase ConvertToOpenSim(XInventoryItem item)
        {
            InventoryItemBase newItem = new InventoryItemBase();

            newItem.AssetID = item.assetID;
            newItem.AssetType = item.assetType;
            newItem.Name = item.inventoryName;
            newItem.Owner = item.avatarID;
            newItem.ID = item.inventoryID;
            newItem.InvType = item.invType;
            newItem.Folder = item.parentFolderID;
            newItem.CreatorId = item.creatorID;
            newItem.Description = item.inventoryDescription;
            newItem.NextPermissions = (uint)item.inventoryNextPermissions;
            newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions;
            newItem.BasePermissions = (uint)item.inventoryBasePermissions;
            newItem.EveryOnePermissions = (uint)item.inventoryEveryOnePermissions;
            newItem.GroupPermissions = (uint)item.inventoryGroupPermissions;
            newItem.GroupID = item.groupID;
            if (item.groupOwned == 0)
                newItem.GroupOwned = false;
            else
                newItem.GroupOwned = true;
            newItem.SalePrice = item.salePrice;
            newItem.SaleType = (byte)item.saleType;
            newItem.Flags = (uint)item.flags;
            newItem.CreationDate = item.creationDate;

            return newItem;
        }
        public virtual InventoryItemBase GetItem(InventoryItemBase item)
        {
            XInventoryItem[] items = m_Database.GetItems(
                    new string[] { "inventoryID" },
                    new string[] { item.ID.ToString() });

            foreach (XInventoryItem xitem in items)
            {
                UUID nn;
                if (!UUID.TryParse(xitem.creatorID, out nn))
                {
                    try
                    {
                        if (xitem.creatorID != string.Empty)
                        {
                            string FullName = xitem.creatorID.Remove(0, 7);
                            string[] FirstLast = FullName.Split(' ');
                            UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, FirstLast[0], FirstLast[1]);
                            if (account == null)
                            {
                                xitem.creatorID = UUID.Zero.ToString();
                                m_Database.StoreItem(xitem);
                            }
                            else
                            {
                                xitem.creatorID = account.PrincipalID.ToString();
                                m_Database.StoreItem(xitem);
                            }
                        }
                        else
                        {
                            xitem.creatorID = UUID.Zero.ToString();
                            m_Database.StoreItem(xitem);
                        }
                    }
                    catch
                    {
                        xitem.creatorID = UUID.Zero.ToString();
                    }
                }
            }

            if (items.Length == 0)
                return null;

            return ConvertToOpenSim(items[0]);
        }
 public virtual bool UpdateItem(InventoryItemBase item)
 {
     return m_Database.StoreItem(ConvertFromOpenSim(item));
 }
        public virtual bool AddItem(InventoryItemBase item)
        {
//            m_log.DebugFormat(
//                "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner);
            
            return m_Database.StoreItem(ConvertFromOpenSim(item));
        }
 /// <summary>
 /// Create the archive name for a particular item.
 /// </summary>
 ///
 /// These names are prepended with an inventory item's UUID so that more than one item can have the
 /// same name
 /// 
 /// <param name="item"></param>
 /// <returns></returns>
 public static string CreateArchiveItemName(InventoryItemBase item)
 {
     return CreateArchiveItemName(item.Name, item.ID);
 }