Change the signature of the forms requester data in preparation to getting

to where lists can be sent as requests
mysql-performance
Melanie 2009-12-27 03:31:53 +00:00
parent 4799f1ce92
commit cbe434149e
6 changed files with 74 additions and 74 deletions

View File

@ -160,9 +160,9 @@ namespace OpenSim.Server.Base
} }
} }
public static Dictionary<string, string> ParseQueryString(string query) public static Dictionary<string, object> ParseQueryString(string query)
{ {
Dictionary<string, string> result = new Dictionary<string, string>(); Dictionary<string, object> result = new Dictionary<string, object>();
string[] terms = query.Split(new char[] {'&'}); string[] terms = query.Split(new char[] {'&'});
if (terms.Length == 0) if (terms.Length == 0)
@ -186,17 +186,17 @@ namespace OpenSim.Server.Base
return result; return result;
} }
public static string BuildQueryString(Dictionary<string, string> data) public static string BuildQueryString(Dictionary<string, object> data)
{ {
string qstring = String.Empty; string qstring = String.Empty;
foreach (KeyValuePair<string, string> kvp in data) foreach (KeyValuePair<string, object> kvp in data)
{ {
string part; string part;
if (kvp.Value != String.Empty) if (kvp.Value.ToString() != String.Empty)
{ {
part = System.Web.HttpUtility.UrlEncode(kvp.Key) + part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
"=" + System.Web.HttpUtility.UrlEncode(kvp.Value); "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
} }
else else
{ {

View File

@ -86,14 +86,14 @@ namespace OpenSim.Server.Handlers.Authentication
private byte[] DoPlainMethods(string body) private byte[] DoPlainMethods(string body)
{ {
Dictionary<string, string> request = Dictionary<string, object> request =
ServerUtils.ParseQueryString(body); ServerUtils.ParseQueryString(body);
int lifetime = 30; int lifetime = 30;
if (request.ContainsKey("LIFETIME")) if (request.ContainsKey("LIFETIME"))
{ {
lifetime = Convert.ToInt32(request["LIFETIME"]); lifetime = Convert.ToInt32(request["LIFETIME"].ToString());
if (lifetime > 30) if (lifetime > 30)
lifetime = 30; lifetime = 30;
} }
@ -103,12 +103,12 @@ namespace OpenSim.Server.Handlers.Authentication
if (!request.ContainsKey("PRINCIPAL")) if (!request.ContainsKey("PRINCIPAL"))
return FailureResult(); return FailureResult();
string method = request["METHOD"]; string method = request["METHOD"].ToString();
UUID principalID; UUID principalID;
string token; string token;
if (!UUID.TryParse(request["PRINCIPAL"], out principalID)) if (!UUID.TryParse(request["PRINCIPAL"].ToString(), out principalID))
return FailureResult(); return FailureResult();
switch (method) switch (method)
@ -117,7 +117,7 @@ namespace OpenSim.Server.Handlers.Authentication
if (!request.ContainsKey("PASSWORD")) if (!request.ContainsKey("PASSWORD"))
return FailureResult(); return FailureResult();
token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"], lifetime); token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime);
if (token != String.Empty) if (token != String.Empty)
return SuccessResult(token); return SuccessResult(token);
@ -126,7 +126,7 @@ namespace OpenSim.Server.Handlers.Authentication
if (!request.ContainsKey("TOKEN")) if (!request.ContainsKey("TOKEN"))
return FailureResult(); return FailureResult();
if (m_AuthenticationService.Verify(principalID, request["TOKEN"], lifetime)) if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime))
return SuccessResult(); return SuccessResult();
return FailureResult(); return FailureResult();
@ -134,7 +134,7 @@ namespace OpenSim.Server.Handlers.Authentication
if (!request.ContainsKey("TOKEN")) if (!request.ContainsKey("TOKEN"))
return FailureResult(); return FailureResult();
if (m_AuthenticationService.Release(principalID, request["TOKEN"])) if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString()))
return SuccessResult(); return SuccessResult();
return FailureResult(); return FailureResult();

View File

@ -69,13 +69,13 @@ namespace OpenSim.Server.Handlers.Grid
try try
{ {
Dictionary<string, string> request = Dictionary<string, object> request =
ServerUtils.ParseQueryString(body); ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("METHOD")) if (!request.ContainsKey("METHOD"))
return FailureResult(); return FailureResult();
string method = request["METHOD"]; string method = request["METHOD"].ToString();
switch (method) switch (method)
{ {
@ -117,22 +117,22 @@ namespace OpenSim.Server.Handlers.Grid
#region Method-specific handlers #region Method-specific handlers
byte[] Register(Dictionary<string, string> request) byte[] Register(Dictionary<string, object> request)
{ {
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request.ContainsKey("SCOPEID")) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
int versionNumberMin = 0, versionNumberMax = 0; int versionNumberMin = 0, versionNumberMax = 0;
if (request.ContainsKey("VERSIONMIN")) if (request.ContainsKey("VERSIONMIN"))
Int32.TryParse(request["VERSIONMIN"], out versionNumberMin); Int32.TryParse(request["VERSIONMIN"].ToString(), out versionNumberMin);
else else
m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region"); m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region");
if (request.ContainsKey("VERSIONMAX")) if (request.ContainsKey("VERSIONMAX"))
Int32.TryParse(request["VERSIONMAX"], out versionNumberMax); Int32.TryParse(request["VERSIONMAX"].ToString(), out versionNumberMax);
else else
m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); 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; GridRegion rinfo = null;
try try
{ {
foreach (KeyValuePair<string, string> kvp in request) foreach (KeyValuePair<string, object> kvp in request)
rinfoData[kvp.Key] = kvp.Value; rinfoData[kvp.Key] = kvp.Value.ToString();
rinfo = new GridRegion(rinfoData); rinfo = new GridRegion(rinfoData);
} }
catch (Exception e) catch (Exception e)
@ -166,11 +166,11 @@ namespace OpenSim.Server.Handlers.Grid
return FailureResult(); return FailureResult();
} }
byte[] Deregister(Dictionary<string, string> request) byte[] Deregister(Dictionary<string, object> request)
{ {
UUID regionID = UUID.Zero; UUID regionID = UUID.Zero;
if (request["REGIONID"] != null) if (request.ContainsKey("REGIONID"))
UUID.TryParse(request["REGIONID"], out regionID); UUID.TryParse(request["REGIONID"].ToString(), out regionID);
else else
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region"); m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region");
@ -183,17 +183,17 @@ namespace OpenSim.Server.Handlers.Grid
} }
byte[] GetNeighbours(Dictionary<string, string> request) byte[] GetNeighbours(Dictionary<string, object> request)
{ {
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request["SCOPEID"] != null) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
UUID regionID = UUID.Zero; UUID regionID = UUID.Zero;
if (request["REGIONID"] != null) if (request.ContainsKey("REGIONID"))
UUID.TryParse(request["REGIONID"], out regionID); UUID.TryParse(request["REGIONID"].ToString(), out regionID);
else else
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
@ -221,17 +221,17 @@ namespace OpenSim.Server.Handlers.Grid
} }
byte[] GetRegionByUUID(Dictionary<string, string> request) byte[] GetRegionByUUID(Dictionary<string, object> request)
{ {
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request["SCOPEID"] != null) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
UUID regionID = UUID.Zero; UUID regionID = UUID.Zero;
if (request["REGIONID"] != null) if (request.ContainsKey("REGIONID"))
UUID.TryParse(request["REGIONID"], out regionID); UUID.TryParse(request["REGIONID"].ToString(), out regionID);
else else
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); 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); return encoding.GetBytes(xmlString);
} }
byte[] GetRegionByPosition(Dictionary<string, string> request) byte[] GetRegionByPosition(Dictionary<string, object> request)
{ {
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request["SCOPEID"] != null) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
int x = 0, y = 0; int x = 0, y = 0;
if (request["X"] != null) if (request.ContainsKey("X"))
Int32.TryParse(request["X"], out x); Int32.TryParse(request["X"].ToString(), out x);
else else
m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
if (request["Y"] != null) if (request.ContainsKey("Y"))
Int32.TryParse(request["Y"], out y); Int32.TryParse(request["Y"].ToString(), out y);
else else
m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); 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); return encoding.GetBytes(xmlString);
} }
byte[] GetRegionByName(Dictionary<string, string> request) byte[] GetRegionByName(Dictionary<string, object> request)
{ {
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request["SCOPEID"] != null) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
string regionName = string.Empty; string regionName = string.Empty;
if (request["NAME"] != null) if (request.ContainsKey("NAME"))
regionName = request["NAME"]; regionName = request["NAME"].ToString();
else else
m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); 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); return encoding.GetBytes(xmlString);
} }
byte[] GetRegionsByName(Dictionary<string, string> request) byte[] GetRegionsByName(Dictionary<string, object> request)
{ {
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request["SCOPEID"] != null) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
string regionName = string.Empty; string regionName = string.Empty;
if (request["NAME"] != null) if (request.ContainsKey("NAME"))
regionName = request["NAME"]; regionName = request["NAME"].ToString();
else else
m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
int max = 0; int max = 0;
if (request["MAX"] != null) if (request.ContainsKey("MAX"))
Int32.TryParse(request["MAX"], out max); Int32.TryParse(request["MAX"].ToString(), out max);
else else
m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); 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); return encoding.GetBytes(xmlString);
} }
byte[] GetRegionRange(Dictionary<string, string> request) byte[] GetRegionRange(Dictionary<string, object> request)
{ {
//m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
UUID scopeID = UUID.Zero; UUID scopeID = UUID.Zero;
if (request.ContainsKey("SCOPEID")) if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID); UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
int xmin = 0, xmax = 0, ymin = 0, ymax = 0; int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
if (request.ContainsKey("XMIN")) if (request.ContainsKey("XMIN"))
Int32.TryParse(request["XMIN"], out xmin); Int32.TryParse(request["XMIN"].ToString(), out xmin);
else else
m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
if (request.ContainsKey("XMAX")) if (request.ContainsKey("XMAX"))
Int32.TryParse(request["XMAX"], out xmax); Int32.TryParse(request["XMAX"].ToString(), out xmax);
else else
m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
if (request.ContainsKey("YMIN")) if (request.ContainsKey("YMIN"))
Int32.TryParse(request["YMIN"], out ymin); Int32.TryParse(request["YMIN"].ToString(), out ymin);
else else
m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
if (request.ContainsKey("YMAX")) if (request.ContainsKey("YMAX"))
Int32.TryParse(request["YMAX"], out ymax); Int32.TryParse(request["YMAX"].ToString(), out ymax);
else else
m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");

View File

@ -68,13 +68,13 @@ namespace OpenSim.Server.Handlers.Presence
try try
{ {
Dictionary<string, string> request = Dictionary<string, object> request =
ServerUtils.ParseQueryString(body); ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("METHOD")) if (!request.ContainsKey("METHOD"))
return FailureResult(); return FailureResult();
string method = request["METHOD"]; string method = request["METHOD"].ToString();
switch (method) switch (method)
{ {
@ -92,12 +92,12 @@ namespace OpenSim.Server.Handlers.Presence
} }
byte[] Report(Dictionary<string, string> request) byte[] Report(Dictionary<string, object> request)
{ {
PresenceInfo info = new PresenceInfo(); PresenceInfo info = new PresenceInfo();
info.Data = new Dictionary<string, string>(); info.Data = new Dictionary<string, string>();
if (request["PrincipalID"] == null || request["RegionID"] == null) if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("RegionID"))
return FailureResult(); return FailureResult();
if (!UUID.TryParse(request["PrincipalID"].ToString(), if (!UUID.TryParse(request["PrincipalID"].ToString(),

View File

@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors
public string Authenticate(UUID principalID, string password, int lifetime) public string Authenticate(UUID principalID, string password, int lifetime)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["LIFETIME"] = lifetime.ToString(); sendData["LIFETIME"] = lifetime.ToString();
sendData["PRINCIPAL"] = principalID.ToString(); sendData["PRINCIPAL"] = principalID.ToString();
sendData["PASSWORD"] = password; sendData["PASSWORD"] = password;
@ -106,7 +106,7 @@ namespace OpenSim.Services.Connectors
public bool Verify(UUID principalID, string token, int lifetime) public bool Verify(UUID principalID, string token, int lifetime)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["LIFETIME"] = lifetime.ToString(); sendData["LIFETIME"] = lifetime.ToString();
sendData["PRINCIPAL"] = principalID.ToString(); sendData["PRINCIPAL"] = principalID.ToString();
sendData["TOKEN"] = token; sendData["TOKEN"] = token;
@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors
public bool Release(UUID principalID, string token) public bool Release(UUID principalID, string token)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["PRINCIPAL"] = principalID.ToString(); sendData["PRINCIPAL"] = principalID.ToString();
sendData["TOKEN"] = token; sendData["TOKEN"] = token;

View File

@ -89,7 +89,7 @@ namespace OpenSim.Services.Connectors
public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
Dictionary<string, string> sendData = new Dictionary<string,string>(); Dictionary<string, object> sendData = new Dictionary<string,object>();
foreach (KeyValuePair<string, object> kvp in rinfo) foreach (KeyValuePair<string, object> kvp in rinfo)
sendData[kvp.Key] = (string)kvp.Value; sendData[kvp.Key] = (string)kvp.Value;
@ -130,7 +130,7 @@ namespace OpenSim.Services.Connectors
public virtual bool DeregisterRegion(UUID regionID) public virtual bool DeregisterRegion(UUID regionID)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["REGIONID"] = regionID.ToString(); sendData["REGIONID"] = regionID.ToString();
@ -162,7 +162,7 @@ namespace OpenSim.Services.Connectors
public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["REGIONID"] = regionID.ToString(); sendData["REGIONID"] = regionID.ToString();
@ -212,7 +212,7 @@ namespace OpenSim.Services.Connectors
public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["REGIONID"] = regionID.ToString(); sendData["REGIONID"] = regionID.ToString();
@ -258,7 +258,7 @@ namespace OpenSim.Services.Connectors
public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["X"] = x.ToString(); sendData["X"] = x.ToString();
@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors
public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["NAME"] = regionName; sendData["NAME"] = regionName;
@ -344,7 +344,7 @@ namespace OpenSim.Services.Connectors
public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["NAME"] = name; sendData["NAME"] = name;
@ -396,7 +396,7 @@ namespace OpenSim.Services.Connectors
public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["XMIN"] = xmin.ToString(); sendData["XMIN"] = xmin.ToString();