diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs | 122 |
1 files changed, 0 insertions, 122 deletions
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 | } | ||