From cbe434149e79304da9251bfe946f43f6a08c1393 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 03:31:53 +0000 Subject: [PATCH] Change the signature of the forms requester data in preparation to getting to where lists can be sent as requests --- OpenSim/Server/Base/ServerUtils.cs | 12 +-- .../AuthenticationServerPostHandler.cs | 14 +-- .../Handlers/Grid/GridServerPostHandler.cs | 92 +++++++++---------- .../Presence/PresenceServerPostHandler.cs | 8 +- .../AuthenticationServiceConnector.cs | 6 +- .../Connectors/Grid/GridServiceConnector.cs | 16 ++-- 6 files changed, 74 insertions(+), 74 deletions(-) diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 0964caaed7..413a078063 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -160,9 +160,9 @@ namespace OpenSim.Server.Base } } - public static Dictionary ParseQueryString(string query) + public static Dictionary ParseQueryString(string query) { - Dictionary result = new Dictionary(); + Dictionary result = new Dictionary(); string[] terms = query.Split(new char[] {'&'}); if (terms.Length == 0) @@ -186,17 +186,17 @@ namespace OpenSim.Server.Base return result; } - public static string BuildQueryString(Dictionary data) + public static string BuildQueryString(Dictionary data) { string qstring = String.Empty; - foreach (KeyValuePair kvp in data) + foreach (KeyValuePair kvp in data) { string part; - if (kvp.Value != String.Empty) + if (kvp.Value.ToString() != String.Empty) { part = System.Web.HttpUtility.UrlEncode(kvp.Key) + - "=" + System.Web.HttpUtility.UrlEncode(kvp.Value); + "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); } else { diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 490a13a30f..47bc860207 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -86,14 +86,14 @@ namespace OpenSim.Server.Handlers.Authentication private byte[] DoPlainMethods(string body) { - Dictionary request = + Dictionary request = ServerUtils.ParseQueryString(body); int lifetime = 30; if (request.ContainsKey("LIFETIME")) { - lifetime = Convert.ToInt32(request["LIFETIME"]); + lifetime = Convert.ToInt32(request["LIFETIME"].ToString()); if (lifetime > 30) lifetime = 30; } @@ -103,12 +103,12 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("PRINCIPAL")) return FailureResult(); - string method = request["METHOD"]; + string method = request["METHOD"].ToString(); UUID principalID; string token; - if (!UUID.TryParse(request["PRINCIPAL"], out principalID)) + if (!UUID.TryParse(request["PRINCIPAL"].ToString(), out principalID)) return FailureResult(); switch (method) @@ -117,7 +117,7 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("PASSWORD")) return FailureResult(); - token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"], lifetime); + token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime); if (token != String.Empty) return SuccessResult(token); @@ -126,7 +126,7 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("TOKEN")) return FailureResult(); - if (m_AuthenticationService.Verify(principalID, request["TOKEN"], lifetime)) + if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime)) return SuccessResult(); return FailureResult(); @@ -134,7 +134,7 @@ namespace OpenSim.Server.Handlers.Authentication if (!request.ContainsKey("TOKEN")) return FailureResult(); - if (m_AuthenticationService.Release(principalID, request["TOKEN"])) + if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString())) return SuccessResult(); return FailureResult(); diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 433ed0b700..d99b791a1b 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -69,13 +69,13 @@ namespace OpenSim.Server.Handlers.Grid try { - Dictionary request = + Dictionary request = ServerUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) return FailureResult(); - string method = request["METHOD"]; + string method = request["METHOD"].ToString(); switch (method) { @@ -117,22 +117,22 @@ namespace OpenSim.Server.Handlers.Grid #region Method-specific handlers - byte[] Register(Dictionary request) + byte[] Register(Dictionary request) { UUID scopeID = UUID.Zero; if (request.ContainsKey("SCOPEID")) - UUID.TryParse(request["SCOPEID"], out scopeID); + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); int versionNumberMin = 0, versionNumberMax = 0; if (request.ContainsKey("VERSIONMIN")) - Int32.TryParse(request["VERSIONMIN"], out versionNumberMin); + Int32.TryParse(request["VERSIONMIN"].ToString(), out versionNumberMin); else m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region"); if (request.ContainsKey("VERSIONMAX")) - Int32.TryParse(request["VERSIONMAX"], out versionNumberMax); + Int32.TryParse(request["VERSIONMAX"].ToString(), out versionNumberMax); else m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); @@ -147,8 +147,8 @@ namespace OpenSim.Server.Handlers.Grid GridRegion rinfo = null; try { - foreach (KeyValuePair kvp in request) - rinfoData[kvp.Key] = kvp.Value; + foreach (KeyValuePair kvp in request) + rinfoData[kvp.Key] = kvp.Value.ToString(); rinfo = new GridRegion(rinfoData); } catch (Exception e) @@ -166,11 +166,11 @@ namespace OpenSim.Server.Handlers.Grid return FailureResult(); } - byte[] Deregister(Dictionary request) + byte[] Deregister(Dictionary request) { UUID regionID = UUID.Zero; - if (request["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out regionID); + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region"); @@ -183,17 +183,17 @@ namespace OpenSim.Server.Handlers.Grid } - byte[] GetNeighbours(Dictionary request) + byte[] GetNeighbours(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + 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["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out regionID); + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); @@ -221,17 +221,17 @@ namespace OpenSim.Server.Handlers.Grid } - byte[] GetRegionByUUID(Dictionary request) + byte[] GetRegionByUUID(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + 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["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out regionID); + if (request.ContainsKey("REGIONID")) + UUID.TryParse(request["REGIONID"].ToString(), out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); @@ -250,21 +250,21 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionByPosition(Dictionary request) + byte[] GetRegionByPosition(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + 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["X"] != null) - Int32.TryParse(request["X"], out x); + 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["Y"] != null) - Int32.TryParse(request["Y"], out y); + 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"); @@ -283,17 +283,17 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionByName(Dictionary request) + byte[] GetRegionByName(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + 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["NAME"] != null) - regionName = request["NAME"]; + if (request.ContainsKey("NAME")) + regionName = request["NAME"].ToString(); else m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); @@ -312,23 +312,23 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionsByName(Dictionary request) + byte[] GetRegionsByName(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) - UUID.TryParse(request["SCOPEID"], out scopeID); + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); string regionName = string.Empty; - if (request["NAME"] != null) - regionName = request["NAME"]; + if (request.ContainsKey("NAME")) + regionName = request["NAME"].ToString(); else m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); int max = 0; - if (request["MAX"] != null) - Int32.TryParse(request["MAX"], out max); + if (request.ContainsKey("MAX")) + Int32.TryParse(request["MAX"].ToString(), out max); else m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); @@ -355,30 +355,30 @@ namespace OpenSim.Server.Handlers.Grid return encoding.GetBytes(xmlString); } - byte[] GetRegionRange(Dictionary request) + byte[] GetRegionRange(Dictionary request) { //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); UUID scopeID = UUID.Zero; if (request.ContainsKey("SCOPEID")) - UUID.TryParse(request["SCOPEID"], out scopeID); + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); int xmin = 0, xmax = 0, ymin = 0, ymax = 0; if (request.ContainsKey("XMIN")) - Int32.TryParse(request["XMIN"], out xmin); + Int32.TryParse(request["XMIN"].ToString(), out xmin); else m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); if (request.ContainsKey("XMAX")) - Int32.TryParse(request["XMAX"], out xmax); + Int32.TryParse(request["XMAX"].ToString(), out xmax); else m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); if (request.ContainsKey("YMIN")) - Int32.TryParse(request["YMIN"], out ymin); + Int32.TryParse(request["YMIN"].ToString(), out ymin); else m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); if (request.ContainsKey("YMAX")) - Int32.TryParse(request["YMAX"], out ymax); + Int32.TryParse(request["YMAX"].ToString(), out ymax); else m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 2558fa0aaf..b1c6bcf296 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -68,13 +68,13 @@ namespace OpenSim.Server.Handlers.Presence try { - Dictionary request = + Dictionary request = ServerUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) return FailureResult(); - string method = request["METHOD"]; + string method = request["METHOD"].ToString(); switch (method) { @@ -92,12 +92,12 @@ namespace OpenSim.Server.Handlers.Presence } - byte[] Report(Dictionary request) + byte[] Report(Dictionary request) { PresenceInfo info = new PresenceInfo(); info.Data = new Dictionary(); - if (request["PrincipalID"] == null || request["RegionID"] == null) + if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("RegionID")) return FailureResult(); if (!UUID.TryParse(request["PrincipalID"].ToString(), diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index 50e817e064..19bb3e24cf 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs @@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors public string Authenticate(UUID principalID, string password, int lifetime) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["LIFETIME"] = lifetime.ToString(); sendData["PRINCIPAL"] = principalID.ToString(); sendData["PASSWORD"] = password; @@ -106,7 +106,7 @@ namespace OpenSim.Services.Connectors public bool Verify(UUID principalID, string token, int lifetime) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["LIFETIME"] = lifetime.ToString(); sendData["PRINCIPAL"] = principalID.ToString(); sendData["TOKEN"] = token; @@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors public bool Release(UUID principalID, string token) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["PRINCIPAL"] = principalID.ToString(); sendData["TOKEN"] = token; diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 02f2b79cfb..99aa3fb15c 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -89,7 +89,7 @@ namespace OpenSim.Services.Connectors public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); foreach (KeyValuePair kvp in rinfo) sendData[kvp.Key] = (string)kvp.Value; @@ -130,7 +130,7 @@ namespace OpenSim.Services.Connectors public virtual bool DeregisterRegion(UUID regionID) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["REGIONID"] = regionID.ToString(); @@ -162,7 +162,7 @@ namespace OpenSim.Services.Connectors public virtual List GetNeighbours(UUID scopeID, UUID regionID) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); sendData["REGIONID"] = regionID.ToString(); @@ -212,7 +212,7 @@ namespace OpenSim.Services.Connectors public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); sendData["REGIONID"] = regionID.ToString(); @@ -258,7 +258,7 @@ namespace OpenSim.Services.Connectors public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); sendData["X"] = x.ToString(); @@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); sendData["NAME"] = regionName; @@ -344,7 +344,7 @@ namespace OpenSim.Services.Connectors public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); sendData["NAME"] = name; @@ -396,7 +396,7 @@ namespace OpenSim.Services.Connectors public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { - Dictionary sendData = new Dictionary(); + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); sendData["XMIN"] = xmin.ToString();