public override byte[] Handle(string path, Stream request,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string body = GetBodyAsString(request);
            OSDMap map = WebUtils.GetOSDMap(Util.Decompress(body));
            IGridRegistrationService urlModule =
                m_registry.RequestModuleInterface<IGridRegistrationService>();
            if (m_SessionID != "" && urlModule != null)
                if (!urlModule.CheckThreatLevel(m_SessionID, "Asset_Update", ThreatLevel.Full))
                    return new byte[0];
            UUID newID;
            if (map.ContainsKey("Method") && map["Method"] == "UpdateContent")
                m_AssetService.UpdateContent(map["ID"].AsUUID(), map["Data"].AsBinary(), out newID);
            else
            {
                AssetBase asset = new AssetBase();
                asset = asset.Unpack(map);
                newID = m_AssetService.Store(asset);
            }

            return Encoding.UTF8.GetBytes(newID.ToString());
        }
Esempio n. 2
0
            public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
            {
                if (filePath.StartsWith("parcels/"))
                {
                    if (!m_merge)
                    {
                        //Only use if we are not merging
                        LandData parcel = new LandData();
                        OSD parcelData = OSDParser.DeserializeLLSDBinary(data);
                        parcel.FromOSD((OSDMap)parcelData);
                        m_parcels.Add(parcel);
                    }
                }
                #region New Style Terrain Loading
                else if (filePath.StartsWith ("newstyleterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylerevertterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainRevertMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylewater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainWaterMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylerevertwater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainWaterRevertMap = ReadTerrain(data, scene);
                }
                #endregion
                else if (filePath.StartsWith ("terrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("revertterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadRevertMapFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("water/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadWaterFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("revertwater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadWaterRevertMapFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("entities/"))
                {
                    MemoryStream ms = new MemoryStream (data);
                    SceneObjectGroup sceneObject = OpenSim.Region.Framework.Scenes.Serialization.SceneObjectSerializer.FromXml2Format (ref ms, scene);
                    ms.Close ();
                    ms = null;
                    data = null;
                    foreach(ISceneChildEntity part in sceneObject.ChildrenEntities())
                    {
                        if (!ResolveUserUuid (part.CreatorID))
                            part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;

                        if (!ResolveUserUuid (part.OwnerID))
                            part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;

                        if (!ResolveUserUuid (part.LastOwnerID))
                            part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;

                        // Fix ownership/creator of inventory items
                        // Not doing so results in inventory items
                        // being no copy/no mod for everyone
                        lock (part.TaskInventory)
                        {
                            TaskInventoryDictionary inv = part.TaskInventory;
                            foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
                            {
                                if (!ResolveUserUuid (kvp.Value.OwnerID))
                                {
                                    kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                                if (!ResolveUserUuid (kvp.Value.CreatorID))
                                {
                                    kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                            }
                        }
                    }

                    if(scene.SceneGraph.AddPrimToScene(sceneObject))
                    {
                        sceneObject.HasGroupChanged = true;
                        sceneObject.ScheduleGroupUpdate (PrimUpdateFlags.ForcedFullUpdate);
                        sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero);
                    }
                }
                else if(filePath.StartsWith("assets/"))
                {
                    if(m_loadAssets)
                    {
                        AssetBase asset = new AssetBase();
                        asset.Unpack(OSDParser.DeserializeJson(Encoding.UTF8.GetString(data)));
                        bool exists = scene.AssetService.Get(asset.IDString) != null;
                        if(!exists)
                            scene.AssetService.Store(asset);
                    }
                }
            }