29 using System.Collections;
31 using System.Reflection;
35 using OpenSim.Server.Base;
36 using OpenSim.Server.Handlers.Base;
37 using OpenSim.Services.Interfaces;
39 using OpenSim.Framework;
40 using OpenSim.Framework.Servers.HttpServer;
43 using OpenMetaverse.StructuredData;
48 namespace OpenSim.Server.Handlers.Simulation
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 m_SimulationService = sim;
62 public Hashtable
Handler(Hashtable request)
72 Hashtable responsedata =
new Hashtable();
73 responsedata[
"content_type"] =
"text/html";
78 if (!
Utils.
GetParams((
string)request[
"uri"], out objectID, out regionID, out action))
80 m_log.InfoFormat(
"[OBJECT HANDLER]: Invalid parameters for object message {0}", request[
"uri"]);
81 responsedata[
"int_response_code"] = 404;
82 responsedata[
"str_response_string"] =
"false";
90 string method = (string)request[
"http-method"];
91 if (method.Equals(
"POST"))
93 DoObjectPost(request, responsedata, regionID);
103 m_log.InfoFormat(
"[OBJECT HANDLER]: method {0} not supported in object message", method);
104 responsedata[
"int_response_code"] = HttpStatusCode.MethodNotAllowed;
105 responsedata[
"str_response_string"] =
"Method not allowed";
112 m_log.WarnFormat(
"[OBJECT HANDLER]: Caught exception {0}", e.StackTrace);
113 responsedata[
"int_response_code"] = HttpStatusCode.InternalServerError;
114 responsedata[
"str_response_string"] =
"Internal server error";
121 protected void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
123 OSDMap args = Utils.GetOSDMap((string)request[
"body"]);
126 responsedata[
"int_response_code"] = 400;
127 responsedata[
"str_response_string"] =
"false";
132 UUID uuid = UUID.Zero;
133 string regionname = string.Empty;
134 Vector3 newPosition = Vector3.Zero;
136 if (args.ContainsKey(
"destination_x") && args[
"destination_x"] != null)
137 Int32.TryParse(args[
"destination_x"].AsString(), out x);
138 if (args.ContainsKey(
"destination_y") && args[
"destination_y"] != null)
139 Int32.TryParse(args[
"destination_y"].AsString(), out y);
140 if (args.ContainsKey(
"destination_uuid") && args[
"destination_uuid"] != null)
141 UUID.TryParse(args[
"destination_uuid"].AsString(), out uuid);
142 if (args.ContainsKey(
"destination_name") && args[
"destination_name"] != null)
143 regionname = args[
"destination_name"].ToString();
144 if (args.ContainsKey(
"new_position") && args[
"new_position"] != null)
145 Vector3.TryParse(args[
"new_position"], out newPosition);
148 destination.RegionID = uuid;
149 destination.RegionLocX = x;
150 destination.RegionLocY = y;
151 destination.RegionName = regionname;
153 string sogXmlStr =
"", extraStr =
"", stateXmlStr =
"";
154 if (args.ContainsKey(
"sog") && args[
"sog"] != null)
155 sogXmlStr = args[
"sog"].AsString();
156 if (args.ContainsKey(
"extra") && args[
"extra"] != null)
157 extraStr = args[
"extra"].AsString();
159 IScene s = m_SimulationService.GetScene(destination.RegionID);
164 sog = s.DeserializeObject(sogXmlStr);
165 sog.ExtraFromXmlString(extraStr);
169 m_log.InfoFormat(
"[OBJECT HANDLER]: exception on deserializing scene object {0}", ex.Message);
170 responsedata[
"int_response_code"] = HttpStatusCode.BadRequest;
171 responsedata[
"str_response_string"] =
"Bad request";
175 if (args.ContainsKey(
"modified"))
178 sog.HasGroupChanged =
false;
182 stateXmlStr = args[
"state"].AsString();
183 if (stateXmlStr !=
"")
187 sog.SetState(stateXmlStr, s);
191 m_log.InfoFormat(
"[OBJECT HANDLER]: exception on setting state for scene object {0}", ex.Message);
201 result = CreateObject(destination, newPosition, sog);
205 m_log.DebugFormat(
"[OBJECT HANDLER]: Exception in CreateObject: {0}", e.StackTrace);
208 responsedata[
"int_response_code"] = HttpStatusCode.OK;
209 responsedata[
"str_response_string"] = result.ToString();
215 return m_SimulationService.CreateObject(destination, newPosition, sog,
false);
Hashtable Handler(Hashtable request)
OpenMetaverse.StructuredData.OSDMap OSDMap
static bool GetParams(string uri, out UUID uuid, out UUID regionID, out string action)
Extract the param from an uri.
OpenSim.Services.Interfaces.GridRegion GridRegion
void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
virtual bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog)
bool AllowScriptCrossings
ObjectHandler(ISimulationService sim)