diff options
author | Jeff Ames | 2008-05-28 00:26:00 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-28 00:26:00 +0000 |
commit | eed2f7ac186977f9b074588168253fde57128b3e (patch) | |
tree | d6de785ea8a0c9a1e842e59825b5d2a4cb2a675f /OpenSim/Region | |
parent | * Include prims.xml file in archive (diff) | |
download | opensim-SC_OLD-eed2f7ac186977f9b074588168253fde57128b3e.zip opensim-SC_OLD-eed2f7ac186977f9b074588168253fde57128b3e.tar.gz opensim-SC_OLD-eed2f7ac186977f9b074588168253fde57128b3e.tar.bz2 opensim-SC_OLD-eed2f7ac186977f9b074588168253fde57128b3e.tar.xz |
Update svn properties. Fix inconsistent newlines.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs | 374 |
1 files changed, 187 insertions, 187 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs index 8a3fdb6..1579485 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs | |||
@@ -1,104 +1,104 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using OpenSim.Framework; |
29 | using OpenSim.Framework.Communications.Cache; | 29 | using OpenSim.Framework.Communications.Cache; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | using OpenSim.Region.Environment.Modules.World.Serialiser; | 31 | using OpenSim.Region.Environment.Modules.World.Serialiser; |
32 | using OpenSim.Region.Environment.Scenes; | 32 | using OpenSim.Region.Environment.Scenes; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | using libsecondlife; | 35 | using libsecondlife; |
36 | using log4net; | 36 | using log4net; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | 38 | ||
39 | namespace OpenSim.Region.Environment | 39 | namespace OpenSim.Region.Environment |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Method called when all the necessary assets for an archive request have been received. | 42 | /// Method called when all the necessary assets for an archive request have been received. |
43 | /// </summary> | 43 | /// </summary> |
44 | public delegate void AssetsRequestCallback(IDictionary<LLUUID, AssetBase> assets); | 44 | public delegate void AssetsRequestCallback(IDictionary<LLUUID, AssetBase> assets); |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Handles an individual archive request | 47 | /// Handles an individual archive request |
48 | /// </summary> | 48 | /// </summary> |
49 | public class ArchiveRequest | 49 | public class ArchiveRequest |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private Scene m_scene; | 53 | private Scene m_scene; |
54 | private string m_savePath; | 54 | private string m_savePath; |
55 | 55 | ||
56 | private string m_serializedEntities; | 56 | private string m_serializedEntities; |
57 | 57 | ||
58 | public ArchiveRequest(Scene scene, string savePath) | 58 | public ArchiveRequest(Scene scene, string savePath) |
59 | { | 59 | { |
60 | m_scene = scene; | 60 | m_scene = scene; |
61 | m_savePath = savePath; | 61 | m_savePath = savePath; |
62 | 62 | ||
63 | ArchiveRegion(); | 63 | ArchiveRegion(); |
64 | } | 64 | } |
65 | 65 | ||
66 | protected void ArchiveRegion() | 66 | protected void ArchiveRegion() |
67 | { | 67 | { |
68 | m_log.Warn("[ARCHIVER]: Archive region not yet implemented"); | 68 | m_log.Warn("[ARCHIVER]: Archive region not yet implemented"); |
69 | 69 | ||
70 | Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>(); | 70 | Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>(); |
71 | 71 | ||
72 | List<EntityBase> entities = m_scene.GetEntities(); | 72 | List<EntityBase> entities = m_scene.GetEntities(); |
73 | 73 | ||
74 | foreach (EntityBase entity in entities) | 74 | foreach (EntityBase entity in entities) |
75 | { | 75 | { |
76 | if (entity is SceneObjectGroup) | 76 | if (entity is SceneObjectGroup) |
77 | { | 77 | { |
78 | SceneObjectGroup sceneObject = (SceneObjectGroup)entity; | 78 | SceneObjectGroup sceneObject = (SceneObjectGroup)entity; |
79 | 79 | ||
80 | foreach (SceneObjectPart part in sceneObject.GetParts()) | 80 | foreach (SceneObjectPart part in sceneObject.GetParts()) |
81 | { | 81 | { |
82 | LLUUID texture = new LLUUID(part.Shape.TextureEntry, 0); | 82 | LLUUID texture = new LLUUID(part.Shape.TextureEntry, 0); |
83 | textureUuids[texture] = 1; | 83 | textureUuids[texture] = 1; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | m_serializedEntities = SerializeObjects(entities); | 88 | m_serializedEntities = SerializeObjects(entities); |
89 | 89 | ||
90 | if (m_serializedEntities != null && m_serializedEntities.Length > 0) | 90 | if (m_serializedEntities != null && m_serializedEntities.Length > 0) |
91 | { | 91 | { |
92 | m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); | 92 | m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); |
93 | m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} textures", textureUuids.Count); | 93 | m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} textures", textureUuids.Count); |
94 | 94 | ||
95 | // Asynchronously request all the assets required to perform this archive operation | 95 | // Asynchronously request all the assets required to perform this archive operation |
96 | new AssetsRequest(ReceivedAllAssets, m_scene.AssetCache, textureUuids.Keys); | 96 | new AssetsRequest(ReceivedAllAssets, m_scene.AssetCache, textureUuids.Keys); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | protected internal void ReceivedAllAssets(IDictionary<LLUUID, AssetBase> assets) | 100 | protected internal void ReceivedAllAssets(IDictionary<LLUUID, AssetBase> assets) |
101 | { | 101 | { |
102 | m_log.DebugFormat("[ARCHIVER]: Received all {0} textures required", assets.Count); | 102 | m_log.DebugFormat("[ARCHIVER]: Received all {0} textures required", assets.Count); |
103 | 103 | ||
104 | // XXX: Shouldn't hijack the asset async callback thread like this - this is only temporary | 104 | // XXX: Shouldn't hijack the asset async callback thread like this - this is only temporary |
@@ -112,91 +112,91 @@ namespace OpenSim.Region.Environment | |||
112 | archive.AddFile(uuid.ToString() + ".jp2", assets[uuid].Data); | 112 | archive.AddFile(uuid.ToString() + ".jp2", assets[uuid].Data); |
113 | } | 113 | } |
114 | 114 | ||
115 | archive.WriteTar(m_savePath); | 115 | archive.WriteTar(m_savePath); |
116 | } | 116 | } |
117 | 117 | ||
118 | /// <summary> | 118 | /// <summary> |
119 | /// Get an xml representation of the given scene objects. | 119 | /// Get an xml representation of the given scene objects. |
120 | /// </summary> | 120 | /// </summary> |
121 | /// <param name="scene"></param> | 121 | /// <param name="scene"></param> |
122 | /// <returns></returns> | 122 | /// <returns></returns> |
123 | protected static string SerializeObjects(List<EntityBase> entities) | 123 | protected static string SerializeObjects(List<EntityBase> entities) |
124 | { | 124 | { |
125 | string serialization = "<scene>"; | 125 | string serialization = "<scene>"; |
126 | 126 | ||
127 | List<string> serObjects = new List<string>(); | 127 | List<string> serObjects = new List<string>(); |
128 | 128 | ||
129 | foreach (EntityBase ent in entities) | 129 | foreach (EntityBase ent in entities) |
130 | { | 130 | { |
131 | if (ent is SceneObjectGroup) | 131 | if (ent is SceneObjectGroup) |
132 | { | 132 | { |
133 | serObjects.Add(((SceneObjectGroup) ent).ToXmlString2()); | 133 | serObjects.Add(((SceneObjectGroup) ent).ToXmlString2()); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | foreach (string serObject in serObjects) | 137 | foreach (string serObject in serObjects) |
138 | serialization += serObject; | 138 | serialization += serObject; |
139 | 139 | ||
140 | serialization += "</scene>"; | 140 | serialization += "</scene>"; |
141 | 141 | ||
142 | return serialization; | 142 | return serialization; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | /// <summary> | 146 | /// <summary> |
147 | /// Encapsulate the asynchronous requests for the assets required for an archive operation | 147 | /// Encapsulate the asynchronous requests for the assets required for an archive operation |
148 | /// </summary> | 148 | /// </summary> |
149 | class AssetsRequest | 149 | class AssetsRequest |
150 | { | 150 | { |
151 | /// <summary> | 151 | /// <summary> |
152 | /// Callback used when all the assets requested have been received. | 152 | /// Callback used when all the assets requested have been received. |
153 | /// </summary> | 153 | /// </summary> |
154 | protected AssetsRequestCallback m_assetsRequestCallback; | 154 | protected AssetsRequestCallback m_assetsRequestCallback; |
155 | 155 | ||
156 | /// <summary> | 156 | /// <summary> |
157 | /// Assets retrieved in this request | 157 | /// Assets retrieved in this request |
158 | /// </summary> | 158 | /// </summary> |
159 | protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>(); | 159 | protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>(); |
160 | 160 | ||
161 | /// <summary> | 161 | /// <summary> |
162 | /// Record the number of asset replies required so we know when we've finished | 162 | /// Record the number of asset replies required so we know when we've finished |
163 | /// </summary> | 163 | /// </summary> |
164 | private int m_repliesRequired; | 164 | private int m_repliesRequired; |
165 | 165 | ||
166 | /// <summary> | 166 | /// <summary> |
167 | /// Asset cache used to request the assets | 167 | /// Asset cache used to request the assets |
168 | /// </summary> | 168 | /// </summary> |
169 | protected AssetCache m_assetCache; | 169 | protected AssetCache m_assetCache; |
170 | 170 | ||
171 | protected internal AssetsRequest(AssetsRequestCallback assetsRequestCallback, AssetCache assetCache, ICollection<LLUUID> uuids) | 171 | protected internal AssetsRequest(AssetsRequestCallback assetsRequestCallback, AssetCache assetCache, ICollection<LLUUID> uuids) |
172 | { | 172 | { |
173 | m_assetsRequestCallback = assetsRequestCallback; | 173 | m_assetsRequestCallback = assetsRequestCallback; |
174 | m_assetCache = assetCache; | 174 | m_assetCache = assetCache; |
175 | m_repliesRequired = uuids.Count; | 175 | m_repliesRequired = uuids.Count; |
176 | 176 | ||
177 | // We can stop here if there are no assets to fetch | 177 | // We can stop here if there are no assets to fetch |
178 | if (m_repliesRequired == 0) | 178 | if (m_repliesRequired == 0) |
179 | m_assetsRequestCallback(m_assets); | 179 | m_assetsRequestCallback(m_assets); |
180 | 180 | ||
181 | foreach (LLUUID uuid in uuids) | 181 | foreach (LLUUID uuid in uuids) |
182 | { | 182 | { |
183 | m_assetCache.GetAsset(uuid, AssetRequestCallback, true); | 183 | m_assetCache.GetAsset(uuid, AssetRequestCallback, true); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /// <summary> | 187 | /// <summary> |
188 | /// Called back by the asset cache when it has the asset | 188 | /// Called back by the asset cache when it has the asset |
189 | /// </summary> | 189 | /// </summary> |
190 | /// <param name="assetID"></param> | 190 | /// <param name="assetID"></param> |
191 | /// <param name="asset"></param> | 191 | /// <param name="asset"></param> |
192 | public void AssetRequestCallback(LLUUID assetID, AssetBase asset) | 192 | public void AssetRequestCallback(LLUUID assetID, AssetBase asset) |
193 | { | 193 | { |
194 | m_assets[assetID] = asset; | 194 | m_assets[assetID] = asset; |
195 | 195 | ||
196 | if (m_assets.Count == m_repliesRequired) | 196 | if (m_assets.Count == m_repliesRequired) |
197 | { | 197 | { |
198 | m_assetsRequestCallback(m_assets); | 198 | m_assetsRequestCallback(m_assets); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |