aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs116
1 files changed, 116 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs
new file mode 100644
index 0000000..1ebf3e0
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs
@@ -0,0 +1,116 @@
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 OpenSim 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
28using OpenSim.Framework.Communications.Cache;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.World.Serialiser;
31using OpenSim.Region.Environment.Scenes;
32using System.Collections.Generic;
33using System.Reflection;
34using libsecondlife;
35using log4net;
36using Nini.Config;
37
38namespace OpenSim.Region.Environment
39{
40 /// <summary>
41 /// Handles an individual archive request
42 /// </summary>
43 public class ArchiveRequest
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 private Scene m_scene;
48 private string m_savePath;
49
50 public ArchiveRequest(Scene scene, string savePath)
51 {
52 m_scene = scene;
53 m_savePath = savePath;
54
55 ArchiveRegion();
56 }
57
58 protected void ArchiveRegion()
59 {
60 m_log.Warn("[ARCHIVER]: Archive region not yet implemented");
61
62 Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>();
63
64 List<EntityBase> entities = m_scene.GetEntities();
65
66 foreach (EntityBase entity in entities)
67 {
68 if (entity is SceneObjectGroup)
69 {
70 SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
71
72 foreach (SceneObjectPart part in sceneObject.GetParts())
73 {
74 LLUUID texture = new LLUUID(part.Shape.TextureEntry, 0);
75 textureUuids[texture] = 1;
76 }
77 }
78 }
79
80 string serEntities = SerializeObjects(entities);
81
82 if (serEntities != null && serEntities.Length > 0)
83 {
84 m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count);
85 m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} textures", textureUuids.Count);
86 }
87 }
88
89 /// <summary>
90 /// Get an xml representation of the given scene objects.
91 /// </summary>
92 /// <param name="scene"></param>
93 /// <returns></returns>
94 protected static string SerializeObjects(List<EntityBase> entities)
95 {
96 string serialization = "<scene>";
97
98 List<string> serObjects = new List<string>();
99
100 foreach (EntityBase ent in entities)
101 {
102 if (ent is SceneObjectGroup)
103 {
104 serObjects.Add(((SceneObjectGroup) ent).ToXmlString2());
105 }
106 }
107
108 foreach (string serObject in serObjects)
109 serialization += serObject;
110
111 serialization += "</scene>";
112
113 return serialization;
114 }
115 }
116}