// subclasses can override this
 protected virtual bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog)
 {
     return(m_SimulationService.CreateObject(destination, newPosition, sog, false));
 }
Beispiel #2
0
        protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
        {
            OSDMap args = WebUtils.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }
            // retrieve the input arguments
            int    x = 0, y = 0;
            UUID   uuid       = UUID.Zero;
            string regionname = string.Empty;

            if (args.ContainsKey("destination_x") && args["destination_x"] != null)
            {
                Int32.TryParse(args["destination_x"].AsString(), out x);
            }
            if (args.ContainsKey("destination_y") && args["destination_y"] != null)
            {
                Int32.TryParse(args["destination_y"].AsString(), out y);
            }
            if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
            {
                UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
            }
            if (args.ContainsKey("destination_name") && args["destination_name"] != null)
            {
                regionname = args["destination_name"].ToString();
            }

            GridRegion destination = new GridRegion();

            destination.RegionID   = uuid;
            destination.RegionLocX = x;
            destination.RegionLocY = y;
            destination.RegionName = regionname;

            string sogXmlStr = "", extraStr = "";

            if (args.ContainsKey("sog") && args["sog"] != null)
            {
                sogXmlStr = args["sog"].AsString();
            }

            IScene       s   = m_SimulationService.GetScene(destination.RegionHandle);
            ISceneObject sog = null;

            try
            {
                //m_log.DebugFormat("[OBJECT HANDLER]: received {0}", sogXmlStr);
                IRegionSerialiserModule mod = s.RequestModuleInterface <IRegionSerialiserModule>();
                if (mod != null)
                {
                    sog = mod.DeserializeGroupFromXml2(sogXmlStr, s);
                    if (sog != null)
                    {
                        sog.ExtraFromXmlString(extraStr);
                    }
                }
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[OBJECT HANDLER]: exception on deserializing scene object {0}", ex.ToString());
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            bool result = false;

            if (sog == null)
            {
                m_log.ErrorFormat("[OBJECT HANDLER]: error on deserializing scene object as the object was null!");

                responsedata["int_response_code"]   = HttpStatusCode.OK;
                responsedata["str_response_string"] = result.ToString();
            }

            try
            {
                // This is the meaning of POST object
                result = m_SimulationService.CreateObject(destination, sog);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[OBJECT HANDLER]: Exception in CreateObject: {0}", e.StackTrace);
            }

            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = result.ToString();
        }