diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs deleted file mode 100644 index 0780d86..0000000 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Xml; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Serialization; | ||
37 | using OpenSim.Framework.Serialization.External; | ||
38 | using OpenSim.Region.CoreModules.World.Terrain; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.World.Archiver | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Method called when all the necessary assets for an archive request have been received. | ||
46 | /// </summary> | ||
47 | public delegate void AssetsRequestCallback( | ||
48 | ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids); | ||
49 | |||
50 | /// <summary> | ||
51 | /// Execute the write of an archive once we have received all the necessary data | ||
52 | /// </summary> | ||
53 | public class ArchiveWriteRequestExecution | ||
54 | { | ||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | |||
57 | protected ITerrainModule m_terrainModule; | ||
58 | protected IRegionSerialiserModule m_serialiser; | ||
59 | protected List<SceneObjectGroup> m_sceneObjects; | ||
60 | protected Scene m_scene; | ||
61 | protected TarArchiveWriter m_archiveWriter; | ||
62 | protected Guid m_requestId; | ||
63 | protected Dictionary<string, object> m_options; | ||
64 | |||
65 | public ArchiveWriteRequestExecution( | ||
66 | List<SceneObjectGroup> sceneObjects, | ||
67 | ITerrainModule terrainModule, | ||
68 | IRegionSerialiserModule serialiser, | ||
69 | Scene scene, | ||
70 | TarArchiveWriter archiveWriter, | ||
71 | Guid requestId, | ||
72 | Dictionary<string, object> options) | ||
73 | { | ||
74 | m_sceneObjects = sceneObjects; | ||
75 | m_terrainModule = terrainModule; | ||
76 | m_serialiser = serialiser; | ||
77 | m_scene = scene; | ||
78 | m_archiveWriter = archiveWriter; | ||
79 | m_requestId = requestId; | ||
80 | m_options = options; | ||
81 | } | ||
82 | |||
83 | protected internal void ReceivedAllAssets( | ||
84 | ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) | ||
85 | { | ||
86 | try | ||
87 | { | ||
88 | Save(assetsFoundUuids, assetsNotFoundUuids); | ||
89 | } | ||
90 | finally | ||
91 | { | ||
92 | m_archiveWriter.Close(); | ||
93 | } | ||
94 | |||
95 | m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName); | ||
96 | |||
97 | m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty); | ||
98 | } | ||
99 | |||
100 | protected internal void Save(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) | ||
101 | { | ||
102 | foreach (UUID uuid in assetsNotFoundUuids) | ||
103 | { | ||
104 | m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); | ||
105 | } | ||
106 | |||
107 | // m_log.InfoFormat( | ||
108 | // "[ARCHIVER]: Received {0} of {1} assets requested", | ||
109 | // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); | ||
110 | |||
111 | m_log.InfoFormat("[ARCHIVER]: Adding region settings to archive."); | ||
112 | |||
113 | // Write out region settings | ||
114 | string settingsPath | ||
115 | = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); | ||
116 | m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings)); | ||
117 | |||
118 | m_log.InfoFormat("[ARCHIVER]: Adding parcel settings to archive."); | ||
119 | |||
120 | // Write out land data (aka parcel) settings | ||
121 | List<ILandObject>landObjects = m_scene.LandChannel.AllParcels(); | ||
122 | foreach (ILandObject lo in landObjects) | ||
123 | { | ||
124 | LandData landData = lo.LandData; | ||
125 | string landDataPath = String.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, | ||
126 | landData.GlobalID.ToString()); | ||
127 | m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); | ||
128 | } | ||
129 | |||
130 | m_log.InfoFormat("[ARCHIVER]: Adding terrain information to archive."); | ||
131 | |||
132 | // Write out terrain | ||
133 | string terrainPath | ||
134 | = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName); | ||
135 | |||
136 | MemoryStream ms = new MemoryStream(); | ||
137 | m_terrainModule.SaveToStream(terrainPath, ms); | ||
138 | m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); | ||
139 | ms.Close(); | ||
140 | |||
141 | m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive."); | ||
142 | |||
143 | // Write out scene object metadata | ||
144 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) | ||
145 | { | ||
146 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); | ||
147 | |||
148 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, m_options); | ||
149 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | } \ No newline at end of file | ||