aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-05-08 18:05:54 +0000
committerJustin Clarke Casey2009-05-08 18:05:54 +0000
commit9f39a490b55580a25baf25db49cfaba8abd8e6b5 (patch)
tree4c16e1948290490111482a89e88c40e36ef12892 /OpenSim
parent* minor: rename xml sog serialization method for readability (diff)
downloadopensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.zip
opensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.tar.gz
opensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.tar.bz2
opensim-SC_OLD-9f39a490b55580a25baf25db49cfaba8abd8e6b5.tar.xz
* refactor: break out sog original xml serialization to a separate class
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs66
5 files changed, 67 insertions, 60 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 8dbf72a..88416d3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1816,7 +1816,7 @@ namespace OpenSim.Region.Framework.Scenes
1816 { 1816 {
1817 UUID assetID = UUID.Zero; 1817 UUID assetID = UUID.Zero;
1818 1818
1819 string sceneObjectXml = objectGroup.ToXmlString(); 1819 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1820 1820
1821 // Get the user info of the item destination 1821 // Get the user info of the item destination
1822 // 1822 //
@@ -2040,7 +2040,7 @@ namespace OpenSim.Region.Framework.Scenes
2040 "[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}", 2040 "[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
2041 grp.UUID, grp.GetAttachmentPoint()); 2041 grp.UUID, grp.GetAttachmentPoint());
2042 2042
2043 string sceneObjectXml = objectGroup.ToXmlString(); 2043 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
2044 2044
2045 CachedUserInfo userInfo = 2045 CachedUserInfo userInfo =
2046 CommsManager.UserProfileCacheService.GetUserDetails(agentID); 2046 CommsManager.UserProfileCacheService.GetUserDetails(agentID);
@@ -2111,7 +2111,7 @@ namespace OpenSim.Region.Framework.Scenes
2111 itemID = UUID.Zero; 2111 itemID = UUID.Zero;
2112 if (grp != null) 2112 if (grp != null)
2113 { 2113 {
2114 string sceneObjectXml = grp.ToXmlString(); 2114 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
2115 2115
2116 CachedUserInfo userInfo = 2116 CachedUserInfo userInfo =
2117 CommsManager.UserProfileCacheService.GetUserDetails(AgentId); 2117 CommsManager.UserProfileCacheService.GetUserDetails(AgentId);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a81bd12..d1260d4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -44,6 +44,7 @@ using OpenSim.Framework.Communications.Clients;
44using OpenSim.Framework.Console; 44using OpenSim.Framework.Console;
45using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes.Scripting; 46using OpenSim.Region.Framework.Scenes.Scripting;
47using OpenSim.Region.Framework.Scenes.Serialization;
47using OpenSim.Region.Physics.Manager; 48using OpenSim.Region.Physics.Manager;
48using Timer=System.Timers.Timer; 49using Timer=System.Timers.Timer;
49using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 50using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
@@ -3383,7 +3384,7 @@ namespace OpenSim.Region.Framework.Scenes
3383 break; 3384 break;
3384 3385
3385 case 2: // Sell a copy 3386 case 2: // Sell a copy
3386 string sceneObjectXml = group.ToXmlString(); 3387 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
3387 3388
3388 CachedUserInfo userInfo = 3389 CachedUserInfo userInfo =
3389 CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 3390 CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index b0de405..cceb444 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -655,50 +655,6 @@ namespace OpenSim.Region.Framework.Scenes
655 655
656 #endregion 656 #endregion
657 657
658 public string ToXmlString()
659 {
660 using (StringWriter sw = new StringWriter())
661 {
662 using (XmlTextWriter writer = new XmlTextWriter(sw))
663 {
664 ToXml(writer);
665 }
666
667 return sw.ToString();
668 }
669 }
670
671 public void ToXml(XmlTextWriter writer)
672 {
673 //m_log.DebugFormat("[SOG]: Starting serialization of {0}", Name);
674 //int time = System.Environment.TickCount;
675
676 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
677 writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
678 m_rootPart.ToXml(writer);
679 writer.WriteEndElement();
680 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
681
682 lock (m_parts)
683 {
684 foreach (SceneObjectPart part in m_parts.Values)
685 {
686 if (part.UUID != m_rootPart.UUID)
687 {
688 writer.WriteStartElement(String.Empty, "Part", String.Empty);
689 part.ToXml(writer);
690 writer.WriteEndElement();
691 }
692 }
693 }
694
695 writer.WriteEndElement(); // OtherParts
696 SaveScriptedState(writer);
697 writer.WriteEndElement(); // SceneObjectGroup
698
699 //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
700 }
701
702 public string ToXmlString2() 658 public string ToXmlString2()
703 { 659 {
704 using (StringWriter sw = new StringWriter()) 660 using (StringWriter sw = new StringWriter())
@@ -714,7 +670,6 @@ namespace OpenSim.Region.Framework.Scenes
714 670
715 public void ToXml2(XmlTextWriter writer) 671 public void ToXml2(XmlTextWriter writer)
716 { 672 {
717
718 //m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name); 673 //m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name);
719 //int time = System.Environment.TickCount; 674 //int time = System.Environment.TickCount;
720 675
@@ -738,12 +693,10 @@ namespace OpenSim.Region.Framework.Scenes
738 writer.WriteEndElement(); // End of SceneObjectGroup 693 writer.WriteEndElement(); // End of SceneObjectGroup
739 694
740 //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); 695 //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
741
742 } 696 }
743 697
744 private void SaveScriptedState(XmlTextWriter writer) 698 public void SaveScriptedState(XmlTextWriter writer)
745 { 699 {
746
747 XmlDocument doc = new XmlDocument(); 700 XmlDocument doc = new XmlDocument();
748 Dictionary<UUID,string> states = new Dictionary<UUID,string>(); 701 Dictionary<UUID,string> states = new Dictionary<UUID,string>();
749 702
@@ -774,7 +727,6 @@ namespace OpenSim.Region.Framework.Scenes
774 } 727 }
775 writer.WriteEndElement(); // End of GroupScriptStates 728 writer.WriteEndElement(); // End of GroupScriptStates
776 } 729 }
777
778 } 730 }
779 731
780 /// <summary> 732 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
index b5f46ee..212ca72 100644
--- a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Region.Framework.Scenes
90 { 90 {
91 if (ent is SceneObjectGroup) 91 if (ent is SceneObjectGroup)
92 { 92 {
93 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); 93 stream.WriteLine(SceneObjectSerializer.ToOriginalXmlFormat((SceneObjectGroup)ent));
94 primCount++; 94 primCount++;
95 } 95 }
96 } 96 }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index ebb27c3..9eac3be 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
64 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 64 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
65 //int time = System.Environment.TickCount; 65 //int time = System.Environment.TickCount;
66 66
67 SceneObjectGroup so = new SceneObjectGroup(); 67 SceneObjectGroup sceneObject = new SceneObjectGroup();
68 68
69 // libomv.types changes UUID to Guid 69 // libomv.types changes UUID to Guid
70 serialization = serialization.Replace("<UUID>", "<Guid>"); 70 serialization = serialization.Replace("<UUID>", "<Guid>");
@@ -94,7 +94,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
94 { 94 {
95 sr = new StringReader(parts[0].InnerXml); 95 sr = new StringReader(parts[0].InnerXml);
96 reader = new XmlTextReader(sr); 96 reader = new XmlTextReader(sr);
97 so.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); 97 sceneObject.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader));
98 reader.Close(); 98 reader.Close();
99 sr.Close(); 99 sr.Close();
100 } 100 }
@@ -107,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
107 reader = new XmlTextReader(sr); 107 reader = new XmlTextReader(sr);
108 SceneObjectPart part = SceneObjectPart.FromXml(reader); 108 SceneObjectPart part = SceneObjectPart.FromXml(reader);
109 linkNum = part.LinkNum; 109 linkNum = part.LinkNum;
110 so.AddPart(part); 110 sceneObject.AddPart(part);
111 part.LinkNum = linkNum; 111 part.LinkNum = linkNum;
112 part.TrimPermissions(); 112 part.TrimPermissions();
113 part.StoreUndoState(); 113 part.StoreUndoState();
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
117 117
118 // Script state may, or may not, exist. Not having any, is NOT 118 // Script state may, or may not, exist. Not having any, is NOT
119 // ever a problem. 119 // ever a problem.
120 so.LoadScriptState(doc); 120 sceneObject.LoadScriptState(doc);
121 } 121 }
122 catch (Exception e) 122 catch (Exception e)
123 { 123 {
@@ -127,7 +127,61 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
127 127
128 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); 128 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
129 129
130 return so; 130 return sceneObject;
131 } 131 }
132
133 /// <summary>
134 /// Serialize a scene object to the original xml format
135 /// </summary>
136 /// <param name="sceneObject"></param>
137 /// <returns></returns>
138 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
139 {
140 using (StringWriter sw = new StringWriter())
141 {
142 using (XmlTextWriter writer = new XmlTextWriter(sw))
143 {
144 ToOriginalXmlFormat(sceneObject, writer);
145 }
146
147 return sw.ToString();
148 }
149 }
150
151 /// <summary>
152 /// Serialize a scene object to the original xml format
153 /// </summary>
154 /// <param name="sceneObject"></param>
155 /// <returns></returns>
156 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer)
157 {
158 //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
159 //int time = System.Environment.TickCount;
160
161 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
162 writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
163 sceneObject.RootPart.ToXml(writer);
164 writer.WriteEndElement();
165 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
166
167 lock (sceneObject.Children)
168 {
169 foreach (SceneObjectPart part in sceneObject.Children.Values)
170 {
171 if (part.UUID != sceneObject.RootPart.UUID)
172 {
173 writer.WriteStartElement(String.Empty, "Part", String.Empty);
174 part.ToXml(writer);
175 writer.WriteEndElement();
176 }
177 }
178 }
179
180 writer.WriteEndElement(); // OtherParts
181 sceneObject.SaveScriptedState(writer);
182 writer.WriteEndElement(); // SceneObjectGroup
183
184 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
185 }
132 } 186 }
133} 187}