aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/Regions
diff options
context:
space:
mode:
authorDr Scofield2009-05-18 09:34:30 +0000
committerDr Scofield2009-05-18 09:34:30 +0000
commit2ad8710e190b7543989cdb96a5268d21d2b5cefb (patch)
tree1ebf5e7463f04201459ff2fcd8f81b32a23d6ab2 /OpenSim/ApplicationPlugins/Rest/Regions
parentThank you kindly, StrawberryFride, for a patch that: (diff)
downloadopensim-SC_OLD-2ad8710e190b7543989cdb96a5268d21d2b5cefb.zip
opensim-SC_OLD-2ad8710e190b7543989cdb96a5268d21d2b5cefb.tar.gz
opensim-SC_OLD-2ad8710e190b7543989cdb96a5268d21d2b5cefb.tar.bz2
opensim-SC_OLD-2ad8710e190b7543989cdb96a5268d21d2b5cefb.tar.xz
fixing XmlWriter problem
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs53
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs86
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs14
3 files changed, 81 insertions, 72 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
index 3fc7c06..ced3e5c 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
@@ -65,29 +65,33 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
65 65
66 public string GetHandlerRegions(OSHttpResponse httpResponse) 66 public string GetHandlerRegions(OSHttpResponse httpResponse)
67 { 67 {
68 XmlWriter.WriteStartElement(String.Empty, "regions", String.Empty); 68 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
69
70 rxw.WriteStartElement(String.Empty, "regions", String.Empty);
69 foreach (Scene s in App.SceneManager.Scenes) 71 foreach (Scene s in App.SceneManager.Scenes)
70 { 72 {
71 XmlWriter.WriteStartElement(String.Empty, "uuid", String.Empty); 73 rxw.WriteStartElement(String.Empty, "uuid", String.Empty);
72 XmlWriter.WriteString(s.RegionInfo.RegionID.ToString()); 74 rxw.WriteString(s.RegionInfo.RegionID.ToString());
73 XmlWriter.WriteEndElement(); 75 rxw.WriteEndElement();
74 } 76 }
75 XmlWriter.WriteEndElement(); 77 rxw.WriteEndElement();
76 78
77 return XmlWriterResult; 79 return rxw.ToString();
78 } 80 }
79 81
80 protected string ShortRegionInfo(string key, string value) 82 protected string ShortRegionInfo(string key, string value)
81 { 83 {
84 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
85
82 if (String.IsNullOrEmpty(value) || 86 if (String.IsNullOrEmpty(value) ||
83 String.IsNullOrEmpty(key)) return null; 87 String.IsNullOrEmpty(key)) return null;
84 88
85 XmlWriter.WriteStartElement(String.Empty, "region", String.Empty); 89 rxw.WriteStartElement(String.Empty, "region", String.Empty);
86 XmlWriter.WriteStartElement(String.Empty, key, String.Empty); 90 rxw.WriteStartElement(String.Empty, key, String.Empty);
87 XmlWriter.WriteString(value); 91 rxw.WriteString(value);
88 XmlWriter.WriteEndDocument(); 92 rxw.WriteEndDocument();
89 93
90 return XmlWriterResult; 94 return rxw.ToString();
91 } 95 }
92 96
93 public string GetHandlerRegion(OSHttpResponse httpResponse, string param) 97 public string GetHandlerRegion(OSHttpResponse httpResponse, string param)
@@ -114,9 +118,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
114 if (1 == comps.Length) 118 if (1 == comps.Length)
115 { 119 {
116 // complete region details requested 120 // complete region details requested
121 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
117 XmlSerializer xs = new XmlSerializer(typeof(RegionDetails)); 122 XmlSerializer xs = new XmlSerializer(typeof(RegionDetails));
118 xs.Serialize(XmlWriter, details, _xmlNs); 123 xs.Serialize(rxw, details, _xmlNs);
119 return XmlWriterResult; 124 return rxw.ToString();
120 } 125 }
121 126
122 if (2 == comps.Length) 127 if (2 == comps.Length)
@@ -185,20 +190,22 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
185 int users = scene.GetAvatars().Count; 190 int users = scene.GetAvatars().Count;
186 int objects = scene.Entities.Count - users; 191 int objects = scene.Entities.Count - users;
187 192
188 XmlWriter.WriteStartElement(String.Empty, "region", String.Empty); 193 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
189 XmlWriter.WriteStartElement(String.Empty, "stats", String.Empty); 194
195 rxw.WriteStartElement(String.Empty, "region", String.Empty);
196 rxw.WriteStartElement(String.Empty, "stats", String.Empty);
190 197
191 XmlWriter.WriteStartElement(String.Empty, "users", String.Empty); 198 rxw.WriteStartElement(String.Empty, "users", String.Empty);
192 XmlWriter.WriteString(users.ToString()); 199 rxw.WriteString(users.ToString());
193 XmlWriter.WriteEndElement(); 200 rxw.WriteEndElement();
194 201
195 XmlWriter.WriteStartElement(String.Empty, "objects", String.Empty); 202 rxw.WriteStartElement(String.Empty, "objects", String.Empty);
196 XmlWriter.WriteString(objects.ToString()); 203 rxw.WriteString(objects.ToString());
197 XmlWriter.WriteEndElement(); 204 rxw.WriteEndElement();
198 205
199 XmlWriter.WriteEndDocument(); 206 rxw.WriteEndDocument();
200 207
201 return XmlWriterResult; 208 return rxw.ToString();
202 } 209 }
203 210
204 protected string RegionPrims(OSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max) 211 protected string RegionPrims(OSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max)
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
index b49c5e9..5f83885 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
@@ -66,78 +66,78 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
66 66
67 public string GetRegionInfoHandlerRegions(OSHttpResponse httpResponse) 67 public string GetRegionInfoHandlerRegions(OSHttpResponse httpResponse)
68 { 68 {
69 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
70
69 // regions info 71 // regions info
70 XmlWriter.WriteStartElement(String.Empty, "regions", String.Empty); 72 rxw.WriteStartElement(String.Empty, "regions", String.Empty);
71 { 73 {
72 // regions info: number of regions 74 // regions info: number of regions
73 XmlWriter.WriteStartAttribute(String.Empty, "number", String.Empty); 75 rxw.WriteStartAttribute(String.Empty, "number", String.Empty);
74 XmlWriter.WriteValue(App.SceneManager.Scenes.Count); 76 rxw.WriteValue(App.SceneManager.Scenes.Count);
75 XmlWriter.WriteEndAttribute(); 77 rxw.WriteEndAttribute();
76 78
77 // regions info: max number of regions 79 // regions info: max number of regions
78 XmlWriter.WriteStartAttribute(String.Empty, "max", String.Empty); 80 rxw.WriteStartAttribute(String.Empty, "max", String.Empty);
79 if (App.ConfigSource.Source.Configs["RemoteAdmin"] != null) 81 if (App.ConfigSource.Source.Configs["RemoteAdmin"] != null)
80 { 82 {
81 XmlWriter.WriteValue(App.ConfigSource.Source.Configs["RemoteAdmin"].GetInt("region_limit", -1)); 83 rxw.WriteValue(App.ConfigSource.Source.Configs["RemoteAdmin"].GetInt("region_limit", -1));
82 } 84 }
83 else 85 else
84 { 86 {
85 XmlWriter.WriteValue(-1); 87 rxw.WriteValue(-1);
86 } 88 }
87 XmlWriter.WriteEndAttribute(); 89 rxw.WriteEndAttribute();
88 90
89 // regions info: region 91 // regions info: region
90 foreach (Scene s in App.SceneManager.Scenes) 92 foreach (Scene s in App.SceneManager.Scenes)
91 { 93 {
92 XmlWriter.WriteStartElement(String.Empty, "region", String.Empty); 94 rxw.WriteStartElement(String.Empty, "region", String.Empty);
93 95
94 XmlWriter.WriteStartAttribute(String.Empty, "uuid", String.Empty); 96 rxw.WriteStartAttribute(String.Empty, "uuid", String.Empty);
95 XmlWriter.WriteString(s.RegionInfo.RegionID.ToString()); 97 rxw.WriteString(s.RegionInfo.RegionID.ToString());
96 XmlWriter.WriteEndAttribute(); 98 rxw.WriteEndAttribute();
97 99
98 XmlWriter.WriteStartAttribute(String.Empty, "name", String.Empty); 100 rxw.WriteStartAttribute(String.Empty, "name", String.Empty);
99 XmlWriter.WriteString(s.RegionInfo.RegionName); 101 rxw.WriteString(s.RegionInfo.RegionName);
100 XmlWriter.WriteEndAttribute(); 102 rxw.WriteEndAttribute();
101 103
102 XmlWriter.WriteStartAttribute(String.Empty, "x", String.Empty); 104 rxw.WriteStartAttribute(String.Empty, "x", String.Empty);
103 XmlWriter.WriteValue(s.RegionInfo.RegionLocX); 105 rxw.WriteValue(s.RegionInfo.RegionLocX);
104 XmlWriter.WriteEndAttribute(); 106 rxw.WriteEndAttribute();
105 107
106 XmlWriter.WriteStartAttribute(String.Empty, "y", String.Empty); 108 rxw.WriteStartAttribute(String.Empty, "y", String.Empty);
107 XmlWriter.WriteValue(s.RegionInfo.RegionLocY); 109 rxw.WriteValue(s.RegionInfo.RegionLocY);
108 XmlWriter.WriteEndAttribute(); 110 rxw.WriteEndAttribute();
109 111
110 XmlWriter.WriteStartAttribute(String.Empty, "external_hostname", String.Empty); 112 rxw.WriteStartAttribute(String.Empty, "external_hostname", String.Empty);
111 XmlWriter.WriteString(s.RegionInfo.ExternalHostName); 113 rxw.WriteString(s.RegionInfo.ExternalHostName);
112 XmlWriter.WriteEndAttribute(); 114 rxw.WriteEndAttribute();
113 115
114 XmlWriter.WriteStartAttribute(String.Empty, "master_name", String.Empty); 116 rxw.WriteStartAttribute(String.Empty, "master_name", String.Empty);
115 XmlWriter.WriteString(String.Format("{0} {1}", s.RegionInfo.MasterAvatarFirstName, s.RegionInfo.MasterAvatarLastName)); 117 rxw.WriteString(String.Format("{0} {1}", s.RegionInfo.MasterAvatarFirstName, s.RegionInfo.MasterAvatarLastName));
116 XmlWriter.WriteEndAttribute(); 118 rxw.WriteEndAttribute();
117 119
118 XmlWriter.WriteStartAttribute(String.Empty, "master_uuid", String.Empty); 120 rxw.WriteStartAttribute(String.Empty, "master_uuid", String.Empty);
119 XmlWriter.WriteString(s.RegionInfo.MasterAvatarAssignedUUID.ToString()); 121 rxw.WriteString(s.RegionInfo.MasterAvatarAssignedUUID.ToString());
120 XmlWriter.WriteEndAttribute(); 122 rxw.WriteEndAttribute();
121 123
122 XmlWriter.WriteStartAttribute(String.Empty, "ip", String.Empty); 124 rxw.WriteStartAttribute(String.Empty, "ip", String.Empty);
123 XmlWriter.WriteString(s.RegionInfo.InternalEndPoint.ToString()); 125 rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
124 XmlWriter.WriteEndAttribute(); 126 rxw.WriteEndAttribute();
125 127
126 int users = s.GetAvatars().Count; 128 int users = s.GetAvatars().Count;
127 XmlWriter.WriteStartAttribute(String.Empty, "avatars", String.Empty); 129 rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
128 XmlWriter.WriteValue(users); 130 rxw.WriteValue(users);
129 XmlWriter.WriteEndAttribute(); 131 rxw.WriteEndAttribute();
130 132
131 XmlWriter.WriteStartAttribute(String.Empty, "objects", String.Empty); 133 rxw.WriteStartAttribute(String.Empty, "objects", String.Empty);
132 XmlWriter.WriteValue(s.Entities.Count - users); 134 rxw.WriteValue(s.Entities.Count - users);
133 XmlWriter.WriteEndAttribute(); 135 rxw.WriteEndAttribute();
134 136
135 XmlWriter.WriteEndElement(); 137 rxw.WriteEndElement();
136 } 138 }
137 } 139 }
138 XmlWriter.WriteEndElement(); 140 return rxw.ToString();
139
140 return XmlWriterResult;
141 } 141 }
142 #endregion GET methods 142 #endregion GET methods
143 } 143 }
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs
index 4b8bb5c..58cb102 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs
@@ -94,16 +94,18 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
94 94
95 public string CreateRegion(OSHttpRequest request, OSHttpResponse response) 95 public string CreateRegion(OSHttpRequest request, OSHttpResponse response)
96 { 96 {
97 XmlWriter.WriteStartElement(String.Empty, "regions", String.Empty); 97 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
98
99 rxw.WriteStartElement(String.Empty, "regions", String.Empty);
98 foreach (Scene s in App.SceneManager.Scenes) 100 foreach (Scene s in App.SceneManager.Scenes)
99 { 101 {
100 XmlWriter.WriteStartElement(String.Empty, "uuid", String.Empty); 102 rxw.WriteStartElement(String.Empty, "uuid", String.Empty);
101 XmlWriter.WriteString(s.RegionInfo.RegionID.ToString()); 103 rxw.WriteString(s.RegionInfo.RegionID.ToString());
102 XmlWriter.WriteEndElement(); 104 rxw.WriteEndElement();
103 } 105 }
104 XmlWriter.WriteEndElement(); 106 rxw.WriteEndElement();
105 107
106 return XmlWriterResult; 108 return rxw.ToString();
107 } 109 }
108 110
109 public string LoadPrims(string requestBody, OSHttpRequest request, OSHttpResponse response, Scene scene) 111 public string LoadPrims(string requestBody, OSHttpRequest request, OSHttpResponse response, Scene scene)