diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Regions')
6 files changed, 0 insertions, 689 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs deleted file mode 100644 index d99ba57..0000000 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs +++ /dev/null | |||
@@ -1,228 +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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Xml.Serialization; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Servers; | ||
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | |||
38 | namespace OpenSim.ApplicationPlugins.Rest.Regions | ||
39 | { | ||
40 | public partial class RestRegionPlugin : RestPlugin | ||
41 | { | ||
42 | #region GET methods | ||
43 | public string GetHandler(string request, string path, string param, | ||
44 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
45 | { | ||
46 | // foreach (string h in httpRequest.Headers.AllKeys) | ||
47 | // foreach (string v in httpRequest.Headers.GetValues(h)) | ||
48 | // m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v); | ||
49 | |||
50 | MsgID = RequestID; | ||
51 | m_log.DebugFormat("{0} GET path {1} param {2}", MsgID, path, param); | ||
52 | |||
53 | try | ||
54 | { | ||
55 | // param empty: regions list | ||
56 | if (String.IsNullOrEmpty(param)) return GetHandlerRegions(httpResponse); | ||
57 | |||
58 | // param not empty: specific region | ||
59 | return GetHandlerRegion(httpResponse, param); | ||
60 | } | ||
61 | catch (Exception e) | ||
62 | { | ||
63 | return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "GET", e); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public string GetHandlerRegions(IOSHttpResponse httpResponse) | ||
68 | { | ||
69 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | ||
70 | |||
71 | rxw.WriteStartElement(String.Empty, "regions", String.Empty); | ||
72 | foreach (Scene s in App.SceneManager.Scenes) | ||
73 | { | ||
74 | rxw.WriteStartElement(String.Empty, "uuid", String.Empty); | ||
75 | rxw.WriteString(s.RegionInfo.RegionID.ToString()); | ||
76 | rxw.WriteEndElement(); | ||
77 | } | ||
78 | rxw.WriteEndElement(); | ||
79 | |||
80 | return rxw.ToString(); | ||
81 | } | ||
82 | |||
83 | protected string ShortRegionInfo(string key, string value) | ||
84 | { | ||
85 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | ||
86 | |||
87 | if (String.IsNullOrEmpty(value) || | ||
88 | String.IsNullOrEmpty(key)) return null; | ||
89 | |||
90 | rxw.WriteStartElement(String.Empty, "region", String.Empty); | ||
91 | rxw.WriteStartElement(String.Empty, key, String.Empty); | ||
92 | rxw.WriteString(value); | ||
93 | rxw.WriteEndDocument(); | ||
94 | |||
95 | return rxw.ToString(); | ||
96 | } | ||
97 | |||
98 | public string GetHandlerRegion(IOSHttpResponse httpResponse, string param) | ||
99 | { | ||
100 | // be resilient and don't get confused by a terminating '/' | ||
101 | param = param.TrimEnd(new char[]{'/'}); | ||
102 | string[] comps = param.Split('/'); | ||
103 | UUID regionID = (UUID)comps[0]; | ||
104 | |||
105 | m_log.DebugFormat("{0} GET region UUID {1}", MsgID, regionID.ToString()); | ||
106 | |||
107 | if (UUID.Zero == regionID) throw new Exception("missing region ID"); | ||
108 | |||
109 | Scene scene = null; | ||
110 | App.SceneManager.TryGetScene(regionID, out scene); | ||
111 | if (null == scene) return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound, | ||
112 | "GET", "cannot find region {0}", regionID.ToString()); | ||
113 | |||
114 | RegionDetails details = new RegionDetails(scene.RegionInfo); | ||
115 | |||
116 | // m_log.DebugFormat("{0} GET comps {1}", MsgID, comps.Length); | ||
117 | // for (int i = 0; i < comps.Length; i++) m_log.DebugFormat("{0} GET comps[{1}] >{2}<", MsgID, i, comps[i]); | ||
118 | |||
119 | if (1 == comps.Length) | ||
120 | { | ||
121 | // complete region details requested | ||
122 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | ||
123 | XmlSerializer xs = new XmlSerializer(typeof(RegionDetails)); | ||
124 | xs.Serialize(rxw, details, _xmlNs); | ||
125 | return rxw.ToString(); | ||
126 | } | ||
127 | |||
128 | if (2 == comps.Length) | ||
129 | { | ||
130 | string resp = ShortRegionInfo(comps[1], details[comps[1]]); | ||
131 | if (null != resp) return resp; | ||
132 | |||
133 | // m_log.DebugFormat("{0} GET comps advanced: >{1}<", MsgID, comps[1]); | ||
134 | |||
135 | // check for {terrain,stats,prims} | ||
136 | switch (comps[1].ToLower()) | ||
137 | { | ||
138 | case "terrain": | ||
139 | return RegionTerrain(httpResponse, scene); | ||
140 | |||
141 | case "stats": | ||
142 | return RegionStats(httpResponse, scene); | ||
143 | |||
144 | case "prims": | ||
145 | return RegionPrims(httpResponse, scene, Vector3.Zero, Vector3.Zero); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | if (3 == comps.Length) | ||
150 | { | ||
151 | switch (comps[1].ToLower()) | ||
152 | { | ||
153 | case "prims": | ||
154 | string[] subregion = comps[2].Split(','); | ||
155 | if (subregion.Length == 6) | ||
156 | { | ||
157 | Vector3 min, max; | ||
158 | try | ||
159 | { | ||
160 | min = new Vector3((float)Double.Parse(subregion[0], Culture.NumberFormatInfo), (float)Double.Parse(subregion[1], Culture.NumberFormatInfo), (float)Double.Parse(subregion[2], Culture.NumberFormatInfo)); | ||
161 | max = new Vector3((float)Double.Parse(subregion[3], Culture.NumberFormatInfo), (float)Double.Parse(subregion[4], Culture.NumberFormatInfo), (float)Double.Parse(subregion[5], Culture.NumberFormatInfo)); | ||
162 | } | ||
163 | catch (Exception) | ||
164 | { | ||
165 | return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest, | ||
166 | "GET", "invalid subregion parameter"); | ||
167 | } | ||
168 | return RegionPrims(httpResponse, scene, min, max); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest, | ||
173 | "GET", "invalid subregion parameter"); | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | |||
178 | return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest, | ||
179 | "GET", "too many parameters {0}", param); | ||
180 | } | ||
181 | #endregion GET methods | ||
182 | |||
183 | protected string RegionTerrain(IOSHttpResponse httpResponse, Scene scene) | ||
184 | { | ||
185 | httpResponse.SendChunked = true; | ||
186 | httpResponse.ContentType = "text/xml"; | ||
187 | |||
188 | return scene.Heightmap.SaveToXmlString(); | ||
189 | //return Failure(httpResponse, OSHttpStatusCode.ServerErrorNotImplemented, | ||
190 | // "GET", "terrain not implemented"); | ||
191 | } | ||
192 | |||
193 | protected string RegionStats(IOSHttpResponse httpResponse, Scene scene) | ||
194 | { | ||
195 | int users = scene.GetRootAgentCount(); | ||
196 | int objects = scene.Entities.Count - users; | ||
197 | |||
198 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | ||
199 | |||
200 | rxw.WriteStartElement(String.Empty, "region", String.Empty); | ||
201 | rxw.WriteStartElement(String.Empty, "stats", String.Empty); | ||
202 | |||
203 | rxw.WriteStartElement(String.Empty, "users", String.Empty); | ||
204 | rxw.WriteString(users.ToString()); | ||
205 | rxw.WriteEndElement(); | ||
206 | |||
207 | rxw.WriteStartElement(String.Empty, "objects", String.Empty); | ||
208 | rxw.WriteString(objects.ToString()); | ||
209 | rxw.WriteEndElement(); | ||
210 | |||
211 | rxw.WriteEndDocument(); | ||
212 | |||
213 | return rxw.ToString(); | ||
214 | } | ||
215 | |||
216 | protected string RegionPrims(IOSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max) | ||
217 | { | ||
218 | httpResponse.SendChunked = true; | ||
219 | httpResponse.ContentType = "text/xml"; | ||
220 | |||
221 | IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>(); | ||
222 | if (serialiser != null) | ||
223 | serialiser.SavePrimsToXml2(scene, new StreamWriter(httpResponse.OutputStream), min, max); | ||
224 | |||
225 | return ""; | ||
226 | } | ||
227 | } | ||
228 | } | ||
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs deleted file mode 100644 index 468faea..0000000 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs +++ /dev/null | |||
@@ -1,136 +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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Xml.Serialization; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework.Servers; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | |||
37 | namespace OpenSim.ApplicationPlugins.Rest.Regions | ||
38 | { | ||
39 | public partial class RestRegionPlugin : RestPlugin | ||
40 | { | ||
41 | #region GET methods | ||
42 | public string GetRegionInfoHandler(string request, string path, string param, | ||
43 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
44 | { | ||
45 | // foreach (string h in httpRequest.Headers.AllKeys) | ||
46 | // foreach (string v in httpRequest.Headers.GetValues(h)) | ||
47 | // m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v); | ||
48 | |||
49 | MsgID = RequestID; | ||
50 | m_log.DebugFormat("{0} GET path {1} param {2}", MsgID, path, param); | ||
51 | |||
52 | try | ||
53 | { | ||
54 | // param empty: regions list | ||
55 | // if (String.IsNullOrEmpty(param)) | ||
56 | return GetRegionInfoHandlerRegions(httpResponse); | ||
57 | |||
58 | // // param not empty: specific region | ||
59 | // return GetRegionInfoHandlerRegion(httpResponse, param); | ||
60 | } | ||
61 | catch (Exception e) | ||
62 | { | ||
63 | return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "GET", e); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public string GetRegionInfoHandlerRegions(IOSHttpResponse httpResponse) | ||
68 | { | ||
69 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | ||
70 | |||
71 | // regions info | ||
72 | rxw.WriteStartElement(String.Empty, "regions", String.Empty); | ||
73 | { | ||
74 | // regions info: number of regions | ||
75 | rxw.WriteStartAttribute(String.Empty, "number", String.Empty); | ||
76 | rxw.WriteValue(App.SceneManager.Scenes.Count); | ||
77 | rxw.WriteEndAttribute(); | ||
78 | |||
79 | // regions info: max number of regions | ||
80 | rxw.WriteStartAttribute(String.Empty, "max", String.Empty); | ||
81 | if (App.ConfigSource.Source.Configs["RemoteAdmin"] != null) | ||
82 | { | ||
83 | rxw.WriteValue(App.ConfigSource.Source.Configs["RemoteAdmin"].GetInt("region_limit", -1)); | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | rxw.WriteValue(-1); | ||
88 | } | ||
89 | rxw.WriteEndAttribute(); | ||
90 | |||
91 | // regions info: region | ||
92 | foreach (Scene s in App.SceneManager.Scenes) | ||
93 | { | ||
94 | rxw.WriteStartElement(String.Empty, "region", String.Empty); | ||
95 | |||
96 | rxw.WriteStartAttribute(String.Empty, "uuid", String.Empty); | ||
97 | rxw.WriteString(s.RegionInfo.RegionID.ToString()); | ||
98 | rxw.WriteEndAttribute(); | ||
99 | |||
100 | rxw.WriteStartAttribute(String.Empty, "name", String.Empty); | ||
101 | rxw.WriteString(s.RegionInfo.RegionName); | ||
102 | rxw.WriteEndAttribute(); | ||
103 | |||
104 | rxw.WriteStartAttribute(String.Empty, "x", String.Empty); | ||
105 | rxw.WriteValue(s.RegionInfo.RegionLocX); | ||
106 | rxw.WriteEndAttribute(); | ||
107 | |||
108 | rxw.WriteStartAttribute(String.Empty, "y", String.Empty); | ||
109 | rxw.WriteValue(s.RegionInfo.RegionLocY); | ||
110 | rxw.WriteEndAttribute(); | ||
111 | |||
112 | rxw.WriteStartAttribute(String.Empty, "external_hostname", String.Empty); | ||
113 | rxw.WriteString(s.RegionInfo.ExternalHostName); | ||
114 | rxw.WriteEndAttribute(); | ||
115 | |||
116 | rxw.WriteStartAttribute(String.Empty, "ip", String.Empty); | ||
117 | rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); | ||
118 | rxw.WriteEndAttribute(); | ||
119 | |||
120 | int users = s.GetRootAgentCount(); | ||
121 | rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); | ||
122 | rxw.WriteValue(users); | ||
123 | rxw.WriteEndAttribute(); | ||
124 | |||
125 | rxw.WriteStartAttribute(String.Empty, "objects", String.Empty); | ||
126 | rxw.WriteValue(s.Entities.Count - users); | ||
127 | rxw.WriteEndAttribute(); | ||
128 | |||
129 | rxw.WriteEndElement(); | ||
130 | } | ||
131 | } | ||
132 | return rxw.ToString(); | ||
133 | } | ||
134 | #endregion GET methods | ||
135 | } | ||
136 | } | ||
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs deleted file mode 100644 index f666f45..0000000 --- a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs +++ /dev/null | |||
@@ -1,122 +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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework.Servers; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | |||
36 | namespace OpenSim.ApplicationPlugins.Rest.Regions | ||
37 | { | ||
38 | public partial class RestRegionPlugin : RestPlugin | ||
39 | { | ||
40 | #region POST methods | ||
41 | |||
42 | public string PostHandler(string request, string path, string param, | ||
43 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
44 | { | ||
45 | // foreach (string h in httpRequest.Headers.AllKeys) | ||
46 | // foreach (string v in httpRequest.Headers.GetValues(h)) | ||
47 | // m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v); | ||
48 | |||
49 | MsgID = RequestID; | ||
50 | m_log.DebugFormat("{0} POST path {1} param {2}", MsgID, path, param); | ||
51 | |||
52 | try | ||
53 | { | ||
54 | // param empty: new region post | ||
55 | if (!IsGod(httpRequest)) | ||
56 | // XXX: this needs to be turned into a FailureUnauthorized(...) | ||
57 | return Failure(httpResponse, OSHttpStatusCode.ClientErrorUnauthorized, | ||
58 | "GET", "you are not god"); | ||
59 | |||
60 | if (String.IsNullOrEmpty(param)) return CreateRegion(httpRequest, httpResponse); | ||
61 | |||
62 | // Parse region ID and other parameters | ||
63 | param = param.TrimEnd(new char[] {'/'}); | ||
64 | string[] comps = param.Split('/'); | ||
65 | UUID regionID = (UUID) comps[0]; | ||
66 | |||
67 | m_log.DebugFormat("{0} POST region UUID {1}", MsgID, regionID.ToString()); | ||
68 | if (UUID.Zero == regionID) throw new Exception("missing region ID"); | ||
69 | |||
70 | Scene scene = null; | ||
71 | App.SceneManager.TryGetScene(regionID, out scene); | ||
72 | if (null == scene) | ||
73 | return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound, | ||
74 | "POST", "cannot find region {0}", regionID.ToString()); | ||
75 | |||
76 | if (2 == comps.Length) | ||
77 | { | ||
78 | // check for {prims} | ||
79 | switch (comps[1].ToLower()) | ||
80 | { | ||
81 | case "prims": | ||
82 | return LoadPrims(request, httpRequest, httpResponse, scene); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound, | ||
87 | "POST", "url {0} not supported", param); | ||
88 | } | ||
89 | catch (Exception e) | ||
90 | { | ||
91 | return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "POST", e); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | public string CreateRegion(IOSHttpRequest request, IOSHttpResponse response) | ||
96 | { | ||
97 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | ||
98 | |||
99 | rxw.WriteStartElement(String.Empty, "regions", String.Empty); | ||
100 | foreach (Scene s in App.SceneManager.Scenes) | ||
101 | { | ||
102 | rxw.WriteStartElement(String.Empty, "uuid", String.Empty); | ||
103 | rxw.WriteString(s.RegionInfo.RegionID.ToString()); | ||
104 | rxw.WriteEndElement(); | ||
105 | } | ||
106 | rxw.WriteEndElement(); | ||
107 | |||
108 | return rxw.ToString(); | ||
109 | } | ||
110 | |||
111 | public string LoadPrims(string requestBody, IOSHttpRequest request, IOSHttpResponse response, Scene scene) | ||
112 | { | ||
113 | IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>(); | ||
114 | if (serialiser != null) | ||
115 | serialiser.LoadPrimsFromXml2(scene, new StringReader(requestBody), true); | ||
116 | |||
117 | return ""; | ||
118 | } | ||
119 | |||
120 | #endregion POST methods | ||
121 | } | ||
122 | } | ||
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs b/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs deleted file mode 100644 index 5e76009..0000000 --- a/OpenSim/ApplicationPlugins/Rest/Regions/RegionDetails.cs +++ /dev/null | |||
@@ -1,98 +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 | |||
28 | using System; | ||
29 | using System.Xml.Serialization; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.ApplicationPlugins.Rest.Regions | ||
34 | { | ||
35 | [XmlRoot(ElementName="region", IsNullable = false)] | ||
36 | public class RegionDetails | ||
37 | { | ||
38 | public string region_name; | ||
39 | public string region_id; | ||
40 | public uint region_x; | ||
41 | public uint region_y; | ||
42 | public string region_owner; | ||
43 | public string region_owner_id; | ||
44 | public uint region_http_port; | ||
45 | public uint region_port; | ||
46 | public string region_server_uri; | ||
47 | public string region_external_hostname; | ||
48 | |||
49 | public RegionDetails() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public RegionDetails(RegionInfo regInfo) | ||
54 | { | ||
55 | region_name = regInfo.RegionName; | ||
56 | region_id = regInfo.RegionID.ToString(); | ||
57 | region_x = regInfo.RegionLocX; | ||
58 | region_y = regInfo.RegionLocY; | ||
59 | region_owner_id = regInfo.EstateSettings.EstateOwner.ToString(); | ||
60 | region_http_port = regInfo.HttpPort; | ||
61 | region_server_uri = regInfo.ServerURI; | ||
62 | region_external_hostname = regInfo.ExternalHostName; | ||
63 | |||
64 | Uri uri = new Uri(region_server_uri); | ||
65 | region_port = (uint)uri.Port; | ||
66 | } | ||
67 | |||
68 | public string this[string idx] | ||
69 | { | ||
70 | get | ||
71 | { | ||
72 | switch (idx.ToLower()) | ||
73 | { | ||
74 | case "name": | ||
75 | return region_name; | ||
76 | case "id": | ||
77 | return region_id; | ||
78 | case "location": | ||
79 | return String.Format("<x>{0}</x><y>{1}</y>", region_x, region_y); | ||
80 | case "owner": | ||
81 | return region_owner; | ||
82 | case "owner_id": | ||
83 | return region_owner_id; | ||
84 | case "http_port": | ||
85 | return region_http_port.ToString(); | ||
86 | case "server_uri": | ||
87 | return region_server_uri; | ||
88 | case "external_hostname": | ||
89 | case "hostname": | ||
90 | return region_external_hostname; | ||
91 | |||
92 | default: | ||
93 | return null; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | } | ||
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/Resources/RestRegionPlugin.addin.xml b/OpenSim/ApplicationPlugins/Rest/Regions/Resources/RestRegionPlugin.addin.xml deleted file mode 100644 index 94eca48..0000000 --- a/OpenSim/ApplicationPlugins/Rest/Regions/Resources/RestRegionPlugin.addin.xml +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | <Addin id="OpenSim.ApplicationPlugins.Rest.Regions" version="0.1"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.ApplicationPlugins.Rest.Regions.dll"/> | ||
4 | </Runtime> | ||
5 | <Dependencies> | ||
6 | <Addin id="OpenSim" version="0.5" /> | ||
7 | </Dependencies> | ||
8 | <Extension path = "/OpenSim/Startup"> | ||
9 | <Plugin id="RestRegions" type="OpenSim.ApplicationPlugins.Rest.Regions.RestRegionPlugin" /> | ||
10 | </Extension> | ||
11 | </Addin> | ||
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs deleted file mode 100644 index 02ef588..0000000 --- a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs +++ /dev/null | |||
@@ -1,94 +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 | |||
28 | using System; | ||
29 | using System.Xml.Serialization; | ||
30 | |||
31 | namespace OpenSim.ApplicationPlugins.Rest.Regions | ||
32 | { | ||
33 | public partial class RestRegionPlugin : RestPlugin | ||
34 | { | ||
35 | private static XmlSerializerNamespaces _xmlNs; | ||
36 | |||
37 | static RestRegionPlugin() | ||
38 | { | ||
39 | _xmlNs = new XmlSerializerNamespaces(); | ||
40 | _xmlNs.Add(String.Empty, String.Empty); | ||
41 | } | ||
42 | |||
43 | #region overriding properties | ||
44 | public override string Name | ||
45 | { | ||
46 | get { return "REGION"; } | ||
47 | } | ||
48 | |||
49 | public override string ConfigName | ||
50 | { | ||
51 | get { return "RestRegionPlugin"; } | ||
52 | } | ||
53 | #endregion overriding properties | ||
54 | |||
55 | #region overriding methods | ||
56 | /// <summary> | ||
57 | /// This method is called by OpenSimMain immediately after loading the | ||
58 | /// plugin and after basic server setup, but before running any server commands. | ||
59 | /// </summary> | ||
60 | /// <remarks> | ||
61 | /// Note that entries MUST be added to the active configuration files before | ||
62 | /// the plugin can be enabled. | ||
63 | /// </remarks> | ||
64 | public override void Initialise(OpenSimBase openSim) | ||
65 | { | ||
66 | try | ||
67 | { | ||
68 | base.Initialise(openSim); | ||
69 | if (!IsEnabled) | ||
70 | { | ||
71 | //m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID); | ||
72 | return; | ||
73 | } | ||
74 | |||
75 | m_log.InfoFormat("{0} REST region plugin enabled", MsgID); | ||
76 | |||
77 | // add REST method handlers | ||
78 | AddRestStreamHandler("GET", "/regions/", GetHandler); | ||
79 | AddRestStreamHandler("POST", "/regions/", PostHandler); | ||
80 | AddRestStreamHandler("GET", "/regioninfo/", GetRegionInfoHandler); | ||
81 | } | ||
82 | catch (Exception e) | ||
83 | { | ||
84 | m_log.WarnFormat("{0} Initialization failed: {1}", MsgID, e.Message); | ||
85 | m_log.DebugFormat("{0} Initialization failed: {1}", MsgID, e.ToString()); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public override void Close() | ||
90 | { | ||
91 | } | ||
92 | #endregion overriding methods | ||
93 | } | ||
94 | } | ||