aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs116
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs56
2 files changed, 118 insertions, 54 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}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
index dc81f41..cff9235 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
@@ -25,6 +25,7 @@
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
28using OpenSim.Framework.Communications.Cache;
28using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
29using OpenSim.Region.Environment.Modules.World.Serialiser; 30using OpenSim.Region.Environment.Modules.World.Serialiser;
30using OpenSim.Region.Environment.Scenes; 31using OpenSim.Region.Environment.Scenes;
@@ -71,65 +72,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
71 72
72 public void ArchiveRegion(string savePath) 73 public void ArchiveRegion(string savePath)
73 { 74 {
74 m_log.Warn("[ARCHIVER]: Archive region not yet implemented"); 75 new ArchiveRequest(m_scene, savePath);
75
76 Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>();
77
78 List<EntityBase> entities = m_scene.GetEntities();
79
80 foreach (EntityBase entity in entities)
81 {
82 if (entity is SceneObjectGroup)
83 {
84 SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
85
86 foreach (SceneObjectPart part in sceneObject.GetParts())
87 {
88 LLUUID texture = new LLUUID(part.Shape.TextureEntry, 0);
89 textureUuids[texture] = 1;
90 }
91 }
92 }
93
94 string serEntities = SerializeObjects(entities);
95
96 if (serEntities != null && serEntities.Length > 0)
97 {
98 m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count);
99 m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} textures", textureUuids.Count);
100 }
101 } 76 }
102 77
103 public void DearchiveRegion(string loadPath) 78 public void DearchiveRegion(string loadPath)
104 { 79 {
105 m_log.Warn("[ARCHIVER]: Dearchive region not yet implemented"); 80 m_log.Warn("[ARCHIVER]: Dearchive region not yet implemented");
106 } 81 }
107
108 /// <summary>
109 /// Get an xml representation of the given scene objects.
110 /// </summary>
111 /// <param name="scene"></param>
112 /// <returns></returns>
113 private static string SerializeObjects(List<EntityBase> entities)
114 {
115 string serialization = "<scene>";
116
117 List<string> serObjects = new List<string>();
118
119 foreach (EntityBase ent in entities)
120 {
121 if (ent is SceneObjectGroup)
122 {
123 serObjects.Add(((SceneObjectGroup) ent).ToXmlString2());
124 }
125 }
126
127 foreach (string serObject in serObjects)
128 serialization += serObject;
129
130 serialization += "</scene>";
131
132 return serialization;
133 }
134 } 82 }
135} \ No newline at end of file 83} \ No newline at end of file