ReceivedAllAssets() protected méthode

protected ReceivedAllAssets ( ICollection assetsFoundUuids, ICollection assetsNotFoundUuids ) : void
assetsFoundUuids ICollection
assetsNotFoundUuids ICollection
Résultat void
        /// <summary>
        /// Archive the region requested.
        /// </summary>
        /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
        public void ArchiveRegion(Dictionary<string, object> options)
        {
            if (options.ContainsKey("noassets") && (bool)options["noassets"])
                SaveAssets = false;

            try
            {
                Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
    
                EntityBase[] entities = m_scene.GetEntities();
                List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();

                string checkPermissions = null;
                int numObjectsSkippedPermissions = 0;
                Object temp;
                if (options.TryGetValue("checkPermissions", out temp))
                    checkPermissions = (string)temp;
         
                // Filter entities so that we only have scene objects.
                // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
                // end up having to do this
                foreach (EntityBase entity in entities)
                {
                    if (entity is SceneObjectGroup)
                    {
                        SceneObjectGroup sceneObject = (SceneObjectGroup)entity;

                        if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
                        {
                            if (!CanUserArchiveObject(m_scene.RegionInfo.EstateSettings.EstateOwner, sceneObject, checkPermissions))
                            {
                                // The user isn't allowed to copy/transfer this object, so it will not be included in the OAR.
                                ++numObjectsSkippedPermissions;
                            }
                            else
                            {
                                sceneObjects.Add(sceneObject);
                            }
                        }
                    }
                }

                if (SaveAssets)
                {
                    UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);

                    foreach (SceneObjectGroup sceneObject in sceneObjects)
                    {
                        assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
                    }

                    m_log.DebugFormat(
                        "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
                        sceneObjects.Count, assetUuids.Count);
                }
                else
                {
                    m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified");
                }

                if (numObjectsSkippedPermissions > 0)
                {
                    m_log.DebugFormat(
                        "[ARCHIVER]: {0} scene objects skipped due to lack of permissions",
                        numObjectsSkippedPermissions);
                }

                // Make sure that we also request terrain texture assets
                RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
    
                if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
                    assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
                
                if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
                    assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
                
                if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
                    assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
                
                if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
                    assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
    
                TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
                
                // Asynchronously request all the assets required to perform this archive operation
                ArchiveWriteRequestExecution awre
                    = new ArchiveWriteRequestExecution(
                        sceneObjects,
                        m_scene.RequestModuleInterface<ITerrainModule>(),
                        m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
                        m_scene,
                        archiveWriter,
                        m_requestId,
                        options);
    
                m_log.InfoFormat("[ARCHIVER]: Creating archive file.  This may take some time.");
    
                // Write out control file.  This has to be done first so that subsequent loaders will see this file first
                // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
                archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options));
                m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");

                if (SaveAssets)
                    new AssetsRequest(
                        new AssetsArchiver(archiveWriter), assetUuids,
                        m_scene.AssetService, m_scene.UserAccountService, 
                        m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute();
                else
                    awre.ReceivedAllAssets(new List<UUID>(), new List<UUID>());
            }
            catch (Exception) 
            {
                m_saveStream.Close();
                throw;
            }    
        }
Exemple #2
0
        /// <summary>
        /// Archive the region requested.
        /// </summary>
        /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
        public void ArchiveRegion(Dictionary <string, object> options)
        {
            if (options.ContainsKey("noassets") && (bool)options["noassets"])
            {
                SaveAssets = false;
            }

            try
            {
                Dictionary <UUID, AssetType> assetUuids = new Dictionary <UUID, AssetType>();

                EntityBase[]            entities     = m_scene.GetEntities();
                List <SceneObjectGroup> sceneObjects = new List <SceneObjectGroup>();

                string checkPermissions             = null;
                int    numObjectsSkippedPermissions = 0;
                Object temp;
                if (options.TryGetValue("checkPermissions", out temp))
                {
                    checkPermissions = (string)temp;
                }

                // Filter entities so that we only have scene objects.
                // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
                // end up having to do this
                foreach (EntityBase entity in entities)
                {
                    if (entity is SceneObjectGroup)
                    {
                        SceneObjectGroup sceneObject = (SceneObjectGroup)entity;

                        if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
                        {
                            if (!CanUserArchiveObject(m_scene.RegionInfo.EstateSettings.EstateOwner, sceneObject, checkPermissions))
                            {
                                // The user isn't allowed to copy/transfer this object, so it will not be included in the OAR.
                                ++numObjectsSkippedPermissions;
                            }
                            else
                            {
                                sceneObjects.Add(sceneObject);
                            }
                        }
                    }
                }

                if (SaveAssets)
                {
                    UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);

                    foreach (SceneObjectGroup sceneObject in sceneObjects)
                    {
                        assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
                    }

                    m_log.DebugFormat(
                        "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
                        sceneObjects.Count, assetUuids.Count);
                }
                else
                {
                    m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified");
                }

                if (numObjectsSkippedPermissions > 0)
                {
                    m_log.DebugFormat(
                        "[ARCHIVER]: {0} scene objects skipped due to lack of permissions",
                        numObjectsSkippedPermissions);
                }

                // Make sure that we also request terrain texture assets
                RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;

                if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
                {
                    assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
                }

                if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
                {
                    assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
                }

                if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
                {
                    assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
                }

                if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
                {
                    assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
                }

                TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);

                // Asynchronously request all the assets required to perform this archive operation
                ArchiveWriteRequestExecution awre
                    = new ArchiveWriteRequestExecution(
                          sceneObjects,
                          m_scene.RequestModuleInterface <ITerrainModule>(),
                          m_scene.RequestModuleInterface <IRegionSerialiserModule>(),
                          m_scene,
                          archiveWriter,
                          m_requestId,
                          options);

                m_log.InfoFormat("[ARCHIVER]: Creating archive file.  This may take some time.");

                // Write out control file.  This has to be done first so that subsequent loaders will see this file first
                // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
                archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options));
                m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");

                if (SaveAssets)
                {
                    new AssetsRequest(
                        new AssetsArchiver(archiveWriter), assetUuids,
                        m_scene.AssetService, m_scene.UserAccountService,
                        m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute();
                }
                else
                {
                    awre.ReceivedAllAssets(new List <UUID>(), new List <UUID>());
                }
            }
            catch (Exception)
            {
                m_saveStream.Close();
                throw;
            }
        }