aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-06-04 03:01:52 +0100
committerJustin Clark-Casey (justincc)2011-06-04 03:01:52 +0100
commit205b2f7ea4aacb66304d3e9a5c70c5001fdeda4d (patch)
tree7960f56b6f8e396ebc4ff164b42942c6195c2397 /OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
parentExtend TestGiveInventoryFolder() to test giving back the freshly received folder (diff)
downloadopensim-SC-205b2f7ea4aacb66304d3e9a5c70c5001fdeda4d.zip
opensim-SC-205b2f7ea4aacb66304d3e9a5c70c5001fdeda4d.tar.gz
opensim-SC-205b2f7ea4aacb66304d3e9a5c70c5001fdeda4d.tar.bz2
opensim-SC-205b2f7ea4aacb66304d3e9a5c70c5001fdeda4d.tar.xz
Remove the unmaintained 'CMS' framework, which was really a 'source-control' experiment from 2008.
This hasn't been touched for about 2 years and I haven't being using it. If this is wrong then please let me know.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs365
1 files changed, 0 insertions, 365 deletions
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
deleted file mode 100644
index 3a6996e..0000000
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
+++ /dev/null
@@ -1,365 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Diagnostics;
32
33using OpenMetaverse;
34
35using OpenSim;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Serialization;
40using OpenSim.Region.Physics.Manager;
41
42using log4net;
43
44namespace OpenSim.Region.OptionalModules.ContentManagement
45{
46 public class CMModel
47 {
48 #region Static Fields
49
50 static float TimeToUpdate = 0;
51 static float TimeToConvertXml = 0;
52 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
53
54 #endregion Static Fields
55
56 #region Fields
57
58 /// <value>
59 /// The class that contains all auras and metaentities used in the CMS.
60 /// </value>
61 CMEntityCollection m_MetaEntityCollection = new CMEntityCollection();
62 IContentDatabase m_database = null;
63
64 #endregion Fields
65
66 #region Constructors
67
68 public CMModel()
69 {
70 }
71
72 #endregion Constructors
73
74 #region Public Properties
75
76 public CMEntityCollection MetaEntityCollection
77 {
78 get { return m_MetaEntityCollection; }
79 }
80
81 #endregion Public Properties
82
83 #region Public Methods
84
85 /// <summary>
86 /// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity
87 /// it is a new part that must have a green aura (for diff mode).
88 /// Returns list of ContentManagementEntities
89 /// </summary>
90 public ArrayList CheckForNewEntitiesMissingAuras(Scene scene)
91 {
92 ArrayList missingList = null;
93 ArrayList newList = new ArrayList();
94
95 m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName);
96
97 //Check if the current scene has groups not included in the current list of MetaEntities
98 //If so, then the current scene's parts that are new should be marked green.
99 missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities());
100
101 foreach (Object missingPart in missingList)
102 {
103 if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID))
104 continue;
105 newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart));
106 }
107 m_log.Info("Number of missing objects found: " + newList.Count);
108 return newList;
109 }
110
111 /// <summary>
112 /// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message.
113 /// </summary>
114 public void CommitRegion(Scene scene, String logMessage)
115 {
116 m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length);
117 m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage);
118 m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName);
119 }
120
121 public void DeleteAllMetaObjects()
122 {
123 m_MetaEntityCollection.ClearAll();
124 }
125
126 public ContentManagementEntity FindMetaEntityAffectedByUndo(UUID uuid)
127 {
128 ContentManagementEntity ent = GetMetaGroupByPrim(uuid);
129 return ent;
130 }
131
132 //-------------------------------- HELPERS --------------------------------------------------------------------//
133 public ContentManagementEntity GetMetaGroupByPrim(UUID uuid)
134 {
135 foreach (Object ent in m_MetaEntityCollection.Entities.Values)
136 {
137 if (((ContentManagementEntity)ent).HasChildPrim(uuid))
138 return (ContentManagementEntity)ent;
139 }
140 return null;
141 }
142
143 public void Initialise(string database)
144 {
145 if (database == "FileSystemDatabase")
146 m_database = new FileSystemDatabase();
147 else if (database == "GitDatabase")
148 m_database = new GitDatabase();
149 }
150
151 public void InitialiseDatabase(Scene scene, string dir)
152 {
153 m_database.Initialise(scene, dir);
154 }
155
156 /// <summary>
157 /// Should be called just once to finish initializing the database.
158 /// </summary>
159 public void PostInitialise()
160 {
161 m_database.PostInitialise();
162 }
163
164 /// <summary>
165 /// Removes the green aura when an a new scene object group is deleted.
166 /// </summary>
167 public void RemoveOrUpdateDeletedEntity(SceneObjectGroup group)
168 {
169 // Deal with new parts not revisioned that have been deleted.
170 SceneObjectPart[] parts = group.Parts;
171 for (int i = 0; i < parts.Length; i++)
172 {
173 if (m_MetaEntityCollection.Auras.ContainsKey(parts[i].UUID))
174 m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(parts[i].UUID);
175 }
176 }
177
178 /// <summary>
179 /// Retrieves the latest revision of a region in xml form,
180 /// converts it to scene object groups and scene presences,
181 /// swaps the current scene's entity list with the revision's list.
182 /// Note: Since deleted objects while
183 /// </summary>
184 public void RollbackRegion(Scene scene)
185 {
186 System.Collections.ArrayList xmllist = null;
187 SceneObjectGroup temp = null;
188 System.Collections.Hashtable deleteListUUIDs = new Hashtable();
189// Dictionary<LLUUID, EntityBase> SearchList = new Dictionary<LLUUID,EntityBase>();
190 Dictionary<UUID, EntityBase> ReplacementList = new Dictionary<UUID,EntityBase>();
191 int revision = m_database.GetMostRecentRevision(scene.RegionInfo.RegionID);
192// EntityBase[] searchArray;
193
194 xmllist = m_database.GetRegionObjectXMLList(scene.RegionInfo.RegionID, revision);
195 if (xmllist == null)
196 {
197 m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") does not have given revision number (" + revision + ").");
198 return;
199 }
200
201 m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") revision number (" + revision + ").");
202 m_log.Info("[CMMODEL]: Scene Objects = " + xmllist.Count);
203 m_log.Info("[CMMODEL]: Converting scene entities list to specified revision.");
204
205 m_log.ErrorFormat("[CMMODEL]: 1");
206
207 foreach (string xml in xmllist)
208 {
209 try
210 {
211 temp = SceneObjectSerializer.FromXml2Format(xml);
212 temp.SetScene(scene);
213
214 SceneObjectPart[] parts = temp.Parts;
215 for (int i = 0; i < parts.Length; i++)
216 parts[i].RegionHandle = scene.RegionInfo.RegionHandle;
217
218 ReplacementList.Add(temp.UUID, (EntityBase)temp);
219 }
220 catch (Exception e)
221 {
222 m_log.Info("[CMMODEL]: Error while creating replacement list for rollback: " + e);
223 }
224 }
225
226 //If in scene but not in revision and not a client, remove them
227 while (true)
228 {
229 try
230 {
231 foreach (EntityBase entity in scene.GetEntities())
232 {
233 if (entity == null)
234 continue;
235
236 if (entity is ScenePresence)
237 {
238 ReplacementList.Add(entity.UUID, entity);
239 continue;
240 }
241 else //if (!ReplacementList.ContainsKey(entity.UUID))
242 deleteListUUIDs.Add(entity.UUID, 0);
243 }
244 }
245 catch(Exception e)
246 {
247 m_log.ErrorFormat("[CMMODEL]: " + e);
248 deleteListUUIDs.Clear();
249 ReplacementList.Clear();
250 continue;
251 }
252 break;
253 }
254
255 foreach (UUID uuid in deleteListUUIDs.Keys)
256 {
257 try
258 {
259 // I thought that the DeleteGroup() function would handle all of this, but it doesn't. I'm not sure WHAT it handles.
260 ((SceneObjectGroup)scene.Entities[uuid]).DetachFromBackup();
261 scene.PhysicsScene.RemovePrim(((SceneObjectGroup)scene.Entities[uuid]).RootPart.PhysActor);
262 scene.SendKillObject(scene.Entities[uuid].LocalId);
263 scene.SceneGraph.DeleteSceneObject(uuid, false);
264 ((SceneObjectGroup)scene.Entities[uuid]).DeleteGroupFromScene(false);
265 }
266 catch(Exception e)
267 {
268 m_log.ErrorFormat("[CMMODEL]: Error while removing objects from scene: " + e);
269 }
270 }
271
272 lock (scene)
273 {
274 scene.Entities.Clear();
275
276 foreach (KeyValuePair<UUID,EntityBase> kvp in ReplacementList)
277 {
278 scene.Entities.Add(kvp.Value);
279 }
280 }
281
282 foreach (EntityBase ent in ReplacementList.Values)
283 {
284 try
285 {
286 if (!(ent is SceneObjectGroup))
287 continue;
288
289 if ((((SceneObjectGroup)ent).RootPart.GetEffectiveObjectFlags() & (uint) PrimFlags.Phantom) == 0)
290 ((SceneObjectGroup)ent).ApplyPhysics(true);
291 ((SceneObjectGroup)ent).AttachToBackup();
292 ((SceneObjectGroup)ent).HasGroupChanged = true; // If not true, then attaching to backup does nothing because no change is detected.
293 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
294 }
295 catch(Exception e)
296 {
297 m_log.ErrorFormat("[CMMODEL]: Error while attaching new scene entities to backup and scheduling for a full update: " + e);
298 }
299 }
300 m_log.Info("[CMMODEL]: Scheduling a backup of new scene object groups to backup.");
301 scene.Backup(true);
302 }
303
304 /// <summary>
305 /// Downloads the latest revision of the given scene and converts the xml file to CMEntities. After this method, the view can find the differences
306 /// and display the differences to clients.
307 /// </summary>
308 public void UpdateCMEntities(Scene scene)
309 {
310 Stopwatch x = new Stopwatch();
311 x.Start();
312
313 System.Collections.ArrayList xmllist = null;
314 m_log.Debug("[CONTENT MANAGEMENT] Retrieving object xml files for region: " + scene.RegionInfo.RegionID);
315 xmllist = m_database.GetRegionObjectXMLList(scene.RegionInfo.RegionID);
316 m_log.Info("[FSDB]: got list");
317 if (xmllist == null)
318 return;
319
320 Stopwatch y = new Stopwatch();
321 y.Start();
322 foreach (string xml in xmllist)
323 m_MetaEntityCollection.CreateNewEntity(xml, scene);
324 y.Stop();
325 TimeToConvertXml += y.ElapsedMilliseconds;
326 m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities for " + scene.RegionInfo.RegionName + ": " + y.ElapsedMilliseconds);
327 m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities so far: " + TimeToConvertXml);
328
329 m_log.Info("[FSDB]: checking for new scene object parts missing green auras and create the auras");
330 CheckForNewEntitiesMissingAuras(scene);
331
332 x.Stop();
333 TimeToUpdate += x.ElapsedMilliseconds;
334 m_log.Info("[FileSystemDatabase] Time spent Updating entity list for " + scene.RegionInfo.RegionName + ": " + x.ElapsedMilliseconds);
335 m_log.Info("[FileSystemDatabase] Time spent Updating so far: " + TimeToUpdate);
336 }
337
338 /// <summary>
339 /// Detects if a scene object group from the scene list has moved or changed scale. The green aura
340 /// that surrounds the object is then moved or scaled with the group.
341 /// </summary>
342 public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group)
343 {
344 System.Collections.ArrayList auraList = new System.Collections.ArrayList();
345 if (group == null)
346 return null;
347
348 SceneObjectPart[] parts = group.Parts;
349 for (int i = 0; i < parts.Length; i++)
350 {
351 SceneObjectPart part = parts[i];
352 if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
353 {
354 ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new Vector3(0, 254, 0), part.Scale);
355 ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition();
356 auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]);
357 }
358 }
359
360 return auraList;
361 }
362
363 #endregion Public Methods
364 }
365}