ToKeyValuePairs() public method

public ToKeyValuePairs ( ) : object>.Dictionary
return object>.Dictionary
Ejemplo n.º 1
1
        public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo, UUID SecureSessionID, out UUID SessionID)
        {
            SessionID = UUID.Zero;
            Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
            Dictionary<string, object> sendData = new Dictionary<string,object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = (string)kvp.Value;

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["SESSIONID"] = SecureSessionID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = WebUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/grid",
                        reqString);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        if (replyData.ContainsKey("Message"))
                        {
                            SessionID = UUID.Parse(replyData["Message"].ToString());
                        }
                        m_log.Info("[GridService]: Successfully registered region " + regionInfo.RegionName + " at " + regionInfo.RegionLocX + "," + regionInfo.RegionLocY + " to the grid server @ " + m_ServerURI);
                        return String.Empty;
                    }
                    else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        //m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
                        return replyData["Message"].ToString();
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                    }
                    else
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
                        return "Unexpected result "+replyData["Result"].ToString();
                    }
                }
                else
                    m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply from " + m_ServerURI);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server " + m_ServerURI + " : {0}", e.Message);
            }

            return "Error communicating with grid service";
        }
        public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo)
        {
            Dictionary <string, object> rinfo    = regionInfo.ToKeyValuePairs();
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> kvp in rinfo)
            {
                sendData[kvp.Key] = (string)kvp.Value;
            }

            sendData["SCOPEID"]    = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "register";

            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         m_ServerURI + "/grid",
                                                                         reqString);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        return(String.Empty);
                    }
                    else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
                        return(replyData["Message"].ToString());
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                    }
                    else
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
                        return("Unexpected result " + replyData["Result"].ToString());
                    }
                }
                else
                {
                    m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
            }

            return("Error communicating with grid service");
        }
Ejemplo n.º 3
0
        private byte[] GetRegionByPosition(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
            }

            int x = 0, y = 0;

            if (request.ContainsKey("X"))
            {
                Int32.TryParse(request["X"].ToString(), out x);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
            }
            if (request.ContainsKey("Y"))
            {
                Int32.TryParse(request["Y"].ToString(), out y);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
            }

            GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);

            rinfo = CleanRegion(rinfo);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = WebUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
Ejemplo n.º 4
0
        public RegionData RegionInfo2RegionData(GridRegion rinfo)
        {
            RegionData rdata = new RegionData();

            rdata.posX                 = (int)rinfo.RegionLocX;
            rdata.posY                 = (int)rinfo.RegionLocY;
            rdata.RegionID             = rinfo.RegionID;
            rdata.RegionName           = rinfo.RegionName;
            rdata.Data                 = rinfo.ToKeyValuePairs();
            rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
            rdata.Data["owner_uuid"]   = rinfo.EstateOwner.ToString();
            return(rdata);
        }
Ejemplo n.º 5
0
        byte[] GetRegionByPosition(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
            }

            int x = 0, y = 0;

            if (request.ContainsKey("X"))
            {
                Int32.TryParse(request["X"].ToString(), out x);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
            }
            if (request.ContainsKey("Y"))
            {
                Int32.TryParse(request["Y"].ToString(), out y);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
            }

            // m_log.DebugFormat("{0} GetRegionByPosition: loc=<{1},{2}>", LogHeader, x, y);
            GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] GetRegionByName(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
            }

            string regionName = string.Empty;

            if (request.ContainsKey("NAME"))
            {
                regionName = request["NAME"].ToString();
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
            }

            GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
        private byte[] GetRegionByUUID(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
            }

            UUID regionID = UUID.Zero;

            if (request.ContainsKey("REGIONID"))
            {
                UUID.TryParse(request["REGIONID"].ToString(), out regionID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
            }

            GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Ejemplo n.º 8
0
 public RegionData RegionInfo2RegionData(GridRegion rinfo)
 {
     RegionData rdata = new RegionData();
     rdata.posX = (int)rinfo.RegionLocX;
     rdata.posY = (int)rinfo.RegionLocY;
     rdata.RegionID = rinfo.RegionID;
     rdata.RegionName = rinfo.RegionName;
     rdata.Data = rinfo.ToKeyValuePairs();
     rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
     rdata.Data["owner_uuid"] = rinfo.EstateOwner.ToString();
     return rdata;
 }
Ejemplo n.º 9
0
        public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
        {
            Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
            Dictionary<string, object> sendData = new Dictionary<string,object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = (string)kvp.Value;

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri = m_ServerURI + "/grid";
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        return String.Empty;
                    }
                    else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);

                        return replyData["Message"].ToString();
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
                    }
                    else
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);

                        return "Unexpected result " + replyData["Result"].ToString();
                    }
                }
                else
                {
                    m_log.ErrorFormat(
                        "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
            }

            return string.Format("Error communicating with the grid service at {0}", uri);
        }
Ejemplo n.º 10
0
        public string OldRegisterRegion(GridRegion region)
        {
            Dictionary<string, object> rinfo = region.ToKeyValuePairs();
            Dictionary<string, object> sendData = new Dictionary<string, object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = (string)kvp.Value;

            sendData["SCOPEID"] = region.ScopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = WebUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
                foreach (string m_ServerURI in serverURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                            m_ServerURI,
                            reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
                        {
                            return String.Empty;
                        }
                        else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
                        {
                            m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
                            return replyData["Message"].ToString();
                        }
                        else if (!replyData.ContainsKey("Result"))
                        {
                            m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                        }
                        else
                        {
                            m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
                            return "Unexpected result " + replyData["Result"].ToString();
                        }

                    }
                    else
                        m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
            }

            return "Error communicating with grid service";
        }
Ejemplo n.º 11
0
        public virtual string UpdateMap(UUID scopeID, GridRegion region, UUID sessionID)
        {
            Dictionary<string, object> sendData = region.ToKeyValuePairs();

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["SESSIONID"] = sessionID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "update_map";

            string reqString = WebUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/grid",
                        reqString);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
                        return String.Empty;

                    else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        if (replyData["Message"].ToString() == "")
                        {
                            if (RegisterRegion(scopeID, region, sessionID, out sessionID) != "")
                            {
                                m_log.DebugFormat("[GRID CONNECTOR]: update_map failed, non Aurora grid-server?");
                            }
                            return "";
                        }
                        else
                        {
                            m_log.DebugFormat("[GRID CONNECTOR]: update_map failed: {0}", replyData["Message"].ToString());
                            return replyData["Message"].ToString();
                        }
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                    }
                    else
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
                        return "Unexpected result " + replyData["Result"].ToString();
                    }
                }
                else
                    m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
            }

            return "Error communicating with grid service";
        }
        public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
        {
            Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
            Dictionary<string, object> sendData = new Dictionary<string,object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = (string)kvp.Value;

            try
            {
                if (File.Exists("RegisterKey.txt"))
                {
                    StreamReader reader = new StreamReader("RegisterKey.txt");
                    sendData["REGISTERKEY"] = reader.ReadLine();
                }
            }catch(Exception registerKeyE)
            {
                m_log.Error("Error while reading the register key." + registerKeyE.Message);
            }

            DirectoryInfo d = new DirectoryInfo(@".");
            FileInfo[] Files = d.GetFiles("*.dll");
            string md5String = "";

            foreach (FileInfo file in Files)
            {
                md5String = md5String + MD5.Create().ComputeHash(File.ReadAllBytes(file.FullName));
            }

            sendData["DATAMD5"] = GetMD5Hash(md5String);

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["GRIDAUTHCODE"] = GetMD5Hash(OpenSim.VersionInfo.Version);
            sendData["METHOD"] = "register";

            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri = m_ServerURI + "/grid";
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        return String.Empty;
                    }
                    else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);

                        return replyData["Message"].ToString();
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
                    }
                    else
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);

                        return "Unexpected result " + replyData["Result"].ToString();
                    }
                }
                else
                {
                    m_log.ErrorFormat(
                        "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
            }

            return string.Format("Error communicating with the grid service at {0}", uri);
        }
Ejemplo n.º 13
0
        public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
        {
            Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
            Dictionary<string, string> sendData = new Dictionary<string,string>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = (string)kvp.Value;

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = ServerUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/grid",
                        reqString);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
                        return true;
                    else if (!replyData.ContainsKey("Result"))
                        m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                    else
                        m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
                    
                }
                else
                    m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
            }

            return false;
        }