aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs')
-rw-r--r--OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs64
1 files changed, 51 insertions, 13 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
index 8c3af72..995a3c4 100644
--- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
@@ -35,6 +35,7 @@ using System.Text;
35using OpenSim.Server.Base; 35using OpenSim.Server.Base;
36using OpenSim.Server.Handlers.Base; 36using OpenSim.Server.Handlers.Base;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Framework; 39using OpenSim.Framework;
39using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
40 41
@@ -70,9 +71,9 @@ namespace OpenSim.Server.Handlers.Simulation
70 responsedata["content_type"] = "text/html"; 71 responsedata["content_type"] = "text/html";
71 72
72 UUID objectID; 73 UUID objectID;
74 UUID regionID;
73 string action; 75 string action;
74 ulong regionHandle; 76 if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action))
75 if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action))
76 { 77 {
77 m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); 78 m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
78 responsedata["int_response_code"] = 404; 79 responsedata["int_response_code"] = 404;
@@ -85,12 +86,12 @@ namespace OpenSim.Server.Handlers.Simulation
85 string method = (string)request["http-method"]; 86 string method = (string)request["http-method"];
86 if (method.Equals("POST")) 87 if (method.Equals("POST"))
87 { 88 {
88 DoObjectPost(request, responsedata, regionHandle); 89 DoObjectPost(request, responsedata, regionID);
89 return responsedata; 90 return responsedata;
90 } 91 }
91 else if (method.Equals("PUT")) 92 else if (method.Equals("PUT"))
92 { 93 {
93 DoObjectPut(request, responsedata, regionHandle); 94 DoObjectPut(request, responsedata, regionID);
94 return responsedata; 95 return responsedata;
95 } 96 }
96 //else if (method.Equals("DELETE")) 97 //else if (method.Equals("DELETE"))
@@ -109,7 +110,7 @@ namespace OpenSim.Server.Handlers.Simulation
109 110
110 } 111 }
111 112
112 protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) 113 protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
113 { 114 {
114 OSDMap args = Utils.GetOSDMap((string)request["body"]); 115 OSDMap args = Utils.GetOSDMap((string)request["body"]);
115 if (args == null) 116 if (args == null)
@@ -118,14 +119,32 @@ namespace OpenSim.Server.Handlers.Simulation
118 responsedata["str_response_string"] = "false"; 119 responsedata["str_response_string"] = "false";
119 return; 120 return;
120 } 121 }
122 // retrieve the input arguments
123 int x = 0, y = 0;
124 UUID uuid = UUID.Zero;
125 string regionname = string.Empty;
126 if (args.ContainsKey("destination_x") && args["destination_x"] != null)
127 Int32.TryParse(args["destination_x"].AsString(), out x);
128 if (args.ContainsKey("destination_y") && args["destination_y"] != null)
129 Int32.TryParse(args["destination_y"].AsString(), out y);
130 if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
131 UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
132 if (args.ContainsKey("destination_name") && args["destination_name"] != null)
133 regionname = args["destination_name"].ToString();
134
135 GridRegion destination = new GridRegion();
136 destination.RegionID = uuid;
137 destination.RegionLocX = x;
138 destination.RegionLocY = y;
139 destination.RegionName = regionname;
121 140
122 string sogXmlStr = "", extraStr = "", stateXmlStr = ""; 141 string sogXmlStr = "", extraStr = "", stateXmlStr = "";
123 if (args["sog"] != null) 142 if (args.ContainsKey("sog") && args["sog"] != null)
124 sogXmlStr = args["sog"].AsString(); 143 sogXmlStr = args["sog"].AsString();
125 if (args["extra"] != null) 144 if (args.ContainsKey("extra") && args["extra"] != null)
126 extraStr = args["extra"].AsString(); 145 extraStr = args["extra"].AsString();
127 146
128 IScene s = m_SimulationService.GetScene(regionhandle); 147 IScene s = m_SimulationService.GetScene(destination.RegionHandle);
129 ISceneObject sog = null; 148 ISceneObject sog = null;
130 try 149 try
131 { 150 {
@@ -158,13 +177,13 @@ namespace OpenSim.Server.Handlers.Simulation
158 } 177 }
159 } 178 }
160 // This is the meaning of POST object 179 // This is the meaning of POST object
161 bool result = m_SimulationService.CreateObject(regionhandle, sog, false); 180 bool result = m_SimulationService.CreateObject(destination, sog, false);
162 181
163 responsedata["int_response_code"] = HttpStatusCode.OK; 182 responsedata["int_response_code"] = HttpStatusCode.OK;
164 responsedata["str_response_string"] = result.ToString(); 183 responsedata["str_response_string"] = result.ToString();
165 } 184 }
166 185
167 protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) 186 protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID)
168 { 187 {
169 OSDMap args = Utils.GetOSDMap((string)request["body"]); 188 OSDMap args = Utils.GetOSDMap((string)request["body"]);
170 if (args == null) 189 if (args == null)
@@ -174,14 +193,33 @@ namespace OpenSim.Server.Handlers.Simulation
174 return; 193 return;
175 } 194 }
176 195
196 // retrieve the input arguments
197 int x = 0, y = 0;
198 UUID uuid = UUID.Zero;
199 string regionname = string.Empty;
200 if (args.ContainsKey("destination_x") && args["destination_x"] != null)
201 Int32.TryParse(args["destination_x"].AsString(), out x);
202 if (args.ContainsKey("destination_y") && args["destination_y"] != null)
203 Int32.TryParse(args["destination_y"].AsString(), out y);
204 if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
205 UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
206 if (args.ContainsKey("destination_name") && args["destination_name"] != null)
207 regionname = args["destination_name"].ToString();
208
209 GridRegion destination = new GridRegion();
210 destination.RegionID = uuid;
211 destination.RegionLocX = x;
212 destination.RegionLocY = y;
213 destination.RegionName = regionname;
214
177 UUID userID = UUID.Zero, itemID = UUID.Zero; 215 UUID userID = UUID.Zero, itemID = UUID.Zero;
178 if (args["userid"] != null) 216 if (args.ContainsKey("userid") && args["userid"] != null)
179 userID = args["userid"].AsUUID(); 217 userID = args["userid"].AsUUID();
180 if (args["itemid"] != null) 218 if (args.ContainsKey("itemid") && args["itemid"] != null)
181 itemID = args["itemid"].AsUUID(); 219 itemID = args["itemid"].AsUUID();
182 220
183 // This is the meaning of PUT object 221 // This is the meaning of PUT object
184 bool result = m_SimulationService.CreateObject(regionhandle, userID, itemID); 222 bool result = m_SimulationService.CreateObject(destination, userID, itemID);
185 223
186 responsedata["int_response_code"] = 200; 224 responsedata["int_response_code"] = 200;
187 responsedata["str_response_string"] = result.ToString(); 225 responsedata["str_response_string"] = result.ToString();