fix merge

httptests
UbitUmarov 2017-05-07 04:21:33 +01:00
commit 11f6d28a06
45 changed files with 908 additions and 484 deletions

View File

@ -787,7 +787,7 @@ namespace OpenSim.Groups
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
// Update the founder with new group information. // Update the founder with new group information.
SendAgentGroupDataUpdate(remoteClient, false); SendAgentGroupDataUpdate(remoteClient, true);
} }
else else
remoteClient.SendCreateGroupReply(groupID, false, reason); remoteClient.SendCreateGroupReply(groupID, false, reason);

View File

@ -115,9 +115,10 @@ namespace OpenSim.Groups
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -91,9 +91,10 @@ namespace OpenSim.Groups
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -362,8 +362,6 @@ namespace OpenSim.Capabilities.Handlers
{ {
// Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
imgstream = new MemoryStream();
// Decode image to System.Drawing.Image // Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
{ {
@ -404,10 +402,7 @@ namespace OpenSim.Capabilities.Handlers
if(managedImage != null) if(managedImage != null)
managedImage.Clear(); managedImage.Clear();
if (imgstream != null) if (imgstream != null)
{
imgstream.Close();
imgstream.Dispose(); imgstream.Dispose();
}
} }
return data; return data;

View File

@ -368,9 +368,6 @@ namespace OpenSim.Capabilities.Handlers
try try
{ {
// Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
imgstream = new MemoryStream();
// Decode image to System.Drawing.Image // Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
{ {
@ -412,10 +409,7 @@ namespace OpenSim.Capabilities.Handlers
managedImage.Clear(); managedImage.Clear();
if (imgstream != null) if (imgstream != null)
{
imgstream.Close();
imgstream.Dispose(); imgstream.Dispose();
}
} }
return data; return data;

View File

@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
Migration m = new Migration(dbcon, Assembly, "AssetStore"); Migration m = new Migration(dbcon, Assembly, "AssetStore");
m.Update(); m.Update();
dbcon.Close();
} }
} }
@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL
string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
} }
} }
dbcon.Close();
} }
return asset; return asset;
@ -156,28 +158,27 @@ namespace OpenSim.Data.MySQL
/// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
override public bool StoreAsset(AssetBase asset) override public bool StoreAsset(AssetBase asset)
{ {
string assetName = asset.Name;
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
{
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
m_log.WarnFormat(
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
}
string assetDescription = asset.Description;
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
{
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
m_log.WarnFormat(
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
}
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
string assetName = asset.Name;
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
{
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
m_log.WarnFormat(
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
}
string assetDescription = asset.Description;
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
{
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
m_log.WarnFormat(
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
}
using (MySqlCommand cmd = using (MySqlCommand cmd =
new MySqlCommand( new MySqlCommand(
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
@ -200,15 +201,17 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
cmd.Parameters.AddWithValue("?data", asset.Data); cmd.Parameters.AddWithValue("?data", asset.Data);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
dbcon.Close();
return true; return true;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
asset.FullID, asset.Name, e.Message); asset.FullID, asset.Name, e.Message);
dbcon.Close();
return false; return false;
} }
} }
} }
} }
@ -238,6 +241,7 @@ namespace OpenSim.Data.MySQL
e); e);
} }
} }
dbcon.Close();
} }
} }
@ -270,6 +274,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
bool[] results = new bool[uuids.Length]; bool[] results = new bool[uuids.Length];
@ -334,6 +339,7 @@ namespace OpenSim.Data.MySQL
e); e);
} }
} }
dbcon.Close();
} }
return retList; return retList;
@ -350,6 +356,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?id", id); cmd.Parameters.AddWithValue("?id", id);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
return true; return true;

View File

@ -59,6 +59,7 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
Migration m = new Migration(dbcon, Assembly, "AuthStore"); Migration m = new Migration(dbcon, Assembly, "AuthStore");
m.Update(); m.Update();
dbcon.Close();
} }
} }
@ -76,27 +77,30 @@ namespace OpenSim.Data.MySQL
{ {
cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
IDataReader result = cmd.ExecuteReader(); using(IDataReader result = cmd.ExecuteReader())
if (result.Read())
{ {
ret.PrincipalID = principalID; if(result.Read())
CheckColumnNames(result);
foreach (string s in m_ColumnNames)
{ {
if (s == "UUID") ret.PrincipalID = principalID;
continue;
ret.Data[s] = result[s].ToString(); CheckColumnNames(result);
foreach(string s in m_ColumnNames)
{
if(s == "UUID")
continue;
ret.Data[s] = result[s].ToString();
}
dbcon.Close();
return ret;
}
else
{
dbcon.Close();
return null;
} }
return ret;
}
else
{
return null;
} }
} }
} }

View File

@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL
Migration m = new Migration(dbcon, Assembly, "EstateStore"); Migration m = new Migration(dbcon, Assembly, "EstateStore");
m.Update(); m.Update();
dbcon.Close();
Type t = typeof(EstateSettings); Type t = typeof(EstateSettings);
m_Fields = t.GetFields(BindingFlags.NonPublic | m_Fields = t.GetFields(BindingFlags.NonPublic |
@ -143,7 +144,6 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
cmd.Connection = dbcon; cmd.Connection = dbcon;
bool found = false; bool found = false;
@ -171,6 +171,8 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
cmd.Connection = null;
if (!found && create) if (!found && create)
{ {
@ -231,6 +233,7 @@ namespace OpenSim.Data.MySQL
es.Save(); es.Save();
} }
dbcon.Close();
} }
} }
@ -263,6 +266,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
SaveBanList(es); SaveBanList(es);
@ -300,6 +304,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -329,6 +334,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear(); cmd.Parameters.Clear();
} }
} }
dbcon.Close();
} }
} }
@ -358,6 +364,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear(); cmd.Parameters.Clear();
} }
} }
dbcon.Close();
} }
} }
@ -383,6 +390,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
return uuids.ToArray(); return uuids.ToArray();
@ -437,7 +445,6 @@ namespace OpenSim.Data.MySQL
reader.Close(); reader.Close();
} }
} }
dbcon.Close(); dbcon.Close();
} }
@ -466,7 +473,6 @@ namespace OpenSim.Data.MySQL
reader.Close(); reader.Close();
} }
} }
dbcon.Close(); dbcon.Close();
} }

View File

@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
conn.Open(); conn.Open();
Migration m = new Migration(conn, Assembly, "FSAssetStore"); Migration m = new Migration(conn, Assembly, "FSAssetStore");
m.Update(); m.Update();
conn.Close();
} }
} }
catch (MySqlException e) catch (MySqlException e)
@ -121,9 +122,13 @@ namespace OpenSim.Data.MySQL
} }
catch (MySqlException e) catch (MySqlException e)
{ {
cmd.Connection = null;
conn.Close();
m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString()); m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString());
return false; return false;
} }
conn.Close();
cmd.Connection = null;
} }
return true; return true;
@ -175,7 +180,7 @@ namespace OpenSim.Data.MySQL
UpdateAccessTime(id, AccessTime); UpdateAccessTime(id, AccessTime);
} }
} }
conn.Close();
} }
return meta; return meta;
@ -206,6 +211,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?id", AssetID); cmd.Parameters.AddWithValue("?id", AssetID);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
conn.Close();
} }
} }
@ -299,6 +305,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
conn.Close();
} }
for (int i = 0; i < uuids.Length; i++) for (int i = 0; i < uuids.Length; i++)
@ -333,6 +340,7 @@ namespace OpenSim.Data.MySQL
count = Convert.ToInt32(reader["count"]); count = Convert.ToInt32(reader["count"]);
} }
} }
conn.Close();
} }
return count; return count;
@ -413,8 +421,8 @@ namespace OpenSim.Data.MySQL
imported++; imported++;
} }
} }
} }
importConn.Close();
} }
MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported));

View File

@ -74,7 +74,9 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
return ExecuteNonQueryWithConnection(cmd, dbcon); int ret = ExecuteNonQueryWithConnection(cmd, dbcon);
dbcon.Close();
return ret;
} }
} }
else else
@ -97,12 +99,15 @@ namespace OpenSim.Data.MySQL
try try
{ {
return cmd.ExecuteNonQuery(); int ret = cmd.ExecuteNonQuery();
cmd.Connection = null;
return ret;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error(e.Message, e); m_log.Error(e.Message, e);
m_log.Error(Environment.StackTrace.ToString()); m_log.Error(Environment.StackTrace.ToString());
cmd.Connection = null;
return 0; return 0;
} }
} }

View File

@ -160,8 +160,9 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
T[] ret = DoQueryWithConnection(cmd, dbcon);
return DoQueryWithConnection(cmd, dbcon); dbcon.Close();
return ret;
} }
} }
else else
@ -243,7 +244,7 @@ namespace OpenSim.Data.MySQL
result.Add(row); result.Add(row);
} }
} }
cmd.Connection = null;
return result.ToArray(); return result.ToArray();
} }
@ -402,7 +403,10 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
cmd.Connection = dbcon; cmd.Connection = dbcon;
return cmd.ExecuteScalar(); Object ret = cmd.ExecuteScalar();
cmd.Connection = null;
dbcon.Close();
return ret;
} }
} }
else else

View File

@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
Migration m = new Migration(dbcon, assem, "InventoryStore"); Migration m = new Migration(dbcon, assem, "InventoryStore");
m.Update(); m.Update();
dbcon.Close();
} }
} }
@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
items.Add(item); items.Add(item);
} }
dbcon.Close();
return items; return items;
} }
} }
@ -170,6 +172,7 @@ namespace OpenSim.Data.MySQL
while (reader.Read()) while (reader.Read())
items.Add(readInventoryFolder(reader)); items.Add(readInventoryFolder(reader));
dbcon.Close();
return items; return items;
} }
} }
@ -221,6 +224,7 @@ namespace OpenSim.Data.MySQL
if (items.Count > 0) if (items.Count > 0)
rootFolder = items[0]; rootFolder = items[0];
dbcon.Close();
return rootFolder; return rootFolder;
} }
} }
@ -261,6 +265,7 @@ namespace OpenSim.Data.MySQL
while (reader.Read()) while (reader.Read())
items.Add(readInventoryFolder(reader)); items.Add(readInventoryFolder(reader));
dbcon.Close();
return items; return items;
} }
} }
@ -352,6 +357,7 @@ namespace OpenSim.Data.MySQL
if (reader.Read()) if (reader.Read())
item = readInventoryItem(reader); item = readInventoryItem(reader);
dbcon.Close();
return item; return item;
} }
} }
@ -417,6 +423,7 @@ namespace OpenSim.Data.MySQL
if (reader.Read()) if (reader.Read())
folder = readInventoryFolder(reader); folder = readInventoryFolder(reader);
dbcon.Close();
return folder; return folder;
} }
} }
@ -504,6 +511,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock) lock (m_dbLock)
result.ExecuteNonQuery(); result.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (MySqlException e) catch (MySqlException e)
@ -540,6 +548,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock) lock (m_dbLock)
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (MySqlException e) catch (MySqlException e)
@ -600,6 +609,7 @@ namespace OpenSim.Data.MySQL
m_log.Error(e.ToString()); m_log.Error(e.ToString());
} }
} }
dbcon.Close();
} }
} }
@ -643,6 +653,7 @@ namespace OpenSim.Data.MySQL
m_log.Error(e.ToString()); m_log.Error(e.ToString());
} }
} }
dbcon.Close();
} }
} }
@ -806,6 +817,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock) lock (m_dbLock)
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (MySqlException e) catch (MySqlException e)
@ -833,6 +845,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock) lock (m_dbLock)
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (MySqlException e) catch (MySqlException e)
@ -886,6 +899,7 @@ namespace OpenSim.Data.MySQL
if (item != null) if (item != null)
list.Add(item); list.Add(item);
} }
dbcon.Close();
return list; return list;
} }
} }

View File

@ -60,6 +60,7 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
Migration m = new Migration(dbcon, Assembly, "GridStore"); Migration m = new Migration(dbcon, Assembly, "GridStore");
m.Update(); m.Update();
dbcon.Close();
} }
} }
@ -260,6 +261,8 @@ namespace OpenSim.Data.MySQL
retList.Add(ret); retList.Add(ret);
} }
} }
cmd.Connection = null;
dbcon.Close();
} }
return retList; return retList;

View File

@ -88,6 +88,7 @@ namespace OpenSim.Data.MySQL
// //
Migration m = new Migration(dbcon, Assembly, "RegionStore"); Migration m = new Migration(dbcon, Assembly, "RegionStore");
m.Update(); m.Update();
dbcon.Close();
} }
} }
@ -261,6 +262,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
} }
dbcon.Close();
} }
} }
} }
@ -300,6 +302,7 @@ namespace OpenSim.Data.MySQL
cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
@ -334,6 +337,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
} }
@ -372,6 +376,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
} }
@ -411,6 +416,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
} }
@ -460,6 +466,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -535,6 +542,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -580,6 +588,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
prim.Inventory.RestoreInventoryItems(inventory); prim.Inventory.RestoreInventoryItems(inventory);
@ -634,6 +643,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
}); });
@ -681,6 +691,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
}); });
@ -727,6 +738,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -762,6 +774,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -783,6 +796,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
} }
@ -842,6 +856,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear(); cmd.Parameters.Clear();
} }
} }
dbcon.Close();
} }
} }
} }
@ -863,82 +878,85 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
IDataReader result = ExecuteReader(cmd); using(IDataReader result = ExecuteReader(cmd))
if (!result.Read())
{ {
//No result, so store our default windlight profile and return it if(!result.Read())
nWP.regionID = regionUUID; {
// StoreRegionWindlightSettings(nWP); //No result, so store our default windlight profile and return it
return nWP; nWP.regionID = regionUUID;
} // StoreRegionWindlightSettings(nWP);
else return nWP;
{ }
nWP.regionID = DBGuid.FromDB(result["region_id"]); else
nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); {
nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); nWP.regionID = DBGuid.FromDB(result["region_id"]);
nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); UUID.TryParse(result["normal_map_texture"].ToString(),out nWP.normalMapTexture);
nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
nWP.eastAngle = Convert.ToSingle(result["east_angle"]); nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
nWP.valid = true; nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
nWP.valid = true;
}
} }
} }
dbcon.Close();
} }
return nWP; return nWP;
@ -947,6 +965,7 @@ namespace OpenSim.Data.MySQL
public virtual RegionSettings LoadRegionSettings(UUID regionUUID) public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
{ {
RegionSettings rs = null; RegionSettings rs = null;
bool needStore = false;
lock (m_dbLock) lock (m_dbLock)
{ {
@ -972,13 +991,17 @@ namespace OpenSim.Data.MySQL
rs.RegionUUID = regionUUID; rs.RegionUUID = regionUUID;
rs.OnSave += StoreRegionSettings; rs.OnSave += StoreRegionSettings;
StoreRegionSettings(rs); needStore = true;
} }
} }
} }
dbcon.Close();
} }
} }
if(needStore)
StoreRegionSettings(rs);
LoadSpawnPoints(rs); LoadSpawnPoints(rs);
return rs; return rs;
@ -992,31 +1015,32 @@ namespace OpenSim.Data.MySQL
using (MySqlCommand cmd = dbcon.CreateCommand()) using (MySqlCommand cmd = dbcon.CreateCommand())
{ {
cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "
cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; + "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "
cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; + "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "
cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; + "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "
cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; + "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "
cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; + "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "
cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; + "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "
cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; + "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "
cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; + "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "
cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; + "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "
cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; + "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "
cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; + "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "
cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; + "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "
cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; + "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "
cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; + "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "
cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; + "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "
cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; + "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "
cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; + "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "
cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; + "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "
cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; + "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "
cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; + "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "
cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; + "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "
cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; + "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "
cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; + "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "
cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; + "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"
;
cmd.Parameters.AddWithValue("region_id", wl.regionID); cmd.Parameters.AddWithValue("region_id", wl.regionID);
cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
@ -1084,6 +1108,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
@ -1099,6 +1124,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
@ -1117,14 +1143,19 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
IDataReader result = ExecuteReader(cmd); using(IDataReader result = ExecuteReader(cmd))
if (!result.Read())
{ {
return String.Empty; if(!result.Read())
} {
else dbcon.Close();
{ return String.Empty;
return Convert.ToString(result["llsd_settings"]); }
else
{
string ret = Convert.ToString(result["llsd_settings"]);
dbcon.Close();
return ret;
}
} }
} }
} }
@ -1145,6 +1176,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
@ -1160,6 +1192,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
} }
} }
#endregion #endregion
@ -1212,7 +1245,7 @@ namespace OpenSim.Data.MySQL
FillRegionSettingsCommand(cmd, rs); FillRegionSettingsCommand(cmd, rs);
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
dbcon.Close();
SaveSpawnPoints(rs); SaveSpawnPoints(rs);
} }
} }
@ -1259,6 +1292,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -2123,6 +2157,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
} }
dbcon.Close();
} }
} }
} }
@ -2152,6 +2187,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
@ -2187,6 +2223,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
} }
@ -2221,6 +2258,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear(); cmd.Parameters.Clear();
} }
} }
dbcon.Close();
} }
} }
} }
@ -2240,6 +2278,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
@ -2257,6 +2296,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
@ -2280,6 +2320,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
return ret; return ret;

View File

@ -69,6 +69,7 @@ namespace OpenSim.Data.MySQL
Migration m = new Migration(dbcon, Assembly, "UserProfiles"); Migration m = new Migration(dbcon, Assembly, "UserProfiles");
m.Update(); m.Update();
dbcon.Close();
} }
} }
#endregion Member Functions #endregion Member Functions
@ -89,7 +90,7 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
{ {
string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; const string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
{ {
@ -121,58 +122,58 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
return data; return data;
} }
public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
{ {
string query = string.Empty; const string query =
"INSERT INTO classifieds ("
+ "`classifieduuid`,"
query += "INSERT INTO classifieds ("; + "`creatoruuid`,"
query += "`classifieduuid`,"; + "`creationdate`,"
query += "`creatoruuid`,"; + "`expirationdate`,"
query += "`creationdate`,"; + "`category`,"
query += "`expirationdate`,"; + "`name`,"
query += "`category`,"; + "`description`,"
query += "`name`,"; + "`parceluuid`,"
query += "`description`,"; + "`parentestate`,"
query += "`parceluuid`,"; + "`snapshotuuid`,"
query += "`parentestate`,"; + "`simname`,"
query += "`snapshotuuid`,"; + "`posglobal`,"
query += "`simname`,"; + "`parcelname`,"
query += "`posglobal`,"; + "`classifiedflags`,"
query += "`parcelname`,"; + "`priceforlisting`) "
query += "`classifiedflags`,"; + "VALUES ("
query += "`priceforlisting`) "; + "?ClassifiedId,"
query += "VALUES ("; + "?CreatorId,"
query += "?ClassifiedId,"; + "?CreatedDate,"
query += "?CreatorId,"; + "?ExpirationDate,"
query += "?CreatedDate,"; + "?Category,"
query += "?ExpirationDate,"; + "?Name,"
query += "?Category,"; + "?Description,"
query += "?Name,"; + "?ParcelId,"
query += "?Description,"; + "?ParentEstate,"
query += "?ParcelId,"; + "?SnapshotId,"
query += "?ParentEstate,"; + "?SimName,"
query += "?SnapshotId,"; + "?GlobalPos,"
query += "?SimName,"; + "?ParcelName,"
query += "?GlobalPos,"; + "?Flags,"
query += "?ParcelName,"; + "?ListingPrice ) "
query += "?Flags,"; + "ON DUPLICATE KEY UPDATE "
query += "?ListingPrice ) "; + "category=?Category, "
query += "ON DUPLICATE KEY UPDATE "; + "expirationdate=?ExpirationDate, "
query += "category=?Category, "; + "name=?Name, "
query += "expirationdate=?ExpirationDate, "; + "description=?Description, "
query += "name=?Name, "; + "parentestate=?ParentEstate, "
query += "description=?Description, "; + "posglobal=?GlobalPos, "
query += "parentestate=?ParentEstate, "; + "parcelname=?ParcelName, "
query += "posglobal=?GlobalPos, "; + "classifiedflags=?Flags, "
query += "parcelname=?ParcelName, "; + "priceforlisting=?ListingPrice, "
query += "classifiedflags=?Flags, "; + "snapshotuuid=?SnapshotId"
query += "priceforlisting=?ListingPrice, "; ;
query += "snapshotuuid=?SnapshotId";
if(string.IsNullOrEmpty(ad.ParcelName)) if(string.IsNullOrEmpty(ad.ParcelName))
ad.ParcelName = "Unknown"; ad.ParcelName = "Unknown";
@ -228,6 +229,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -242,10 +244,7 @@ namespace OpenSim.Data.MySQL
public bool DeleteClassifiedRecord(UUID recordId) public bool DeleteClassifiedRecord(UUID recordId)
{ {
string query = string.Empty; const string query = "DELETE FROM classifieds WHERE classifieduuid = ?recordId";
query += "DELETE FROM classifieds WHERE ";
query += "classifieduuid = ?recordId";
try try
{ {
@ -258,6 +257,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); cmd.Parameters.AddWithValue("?recordId", recordId.ToString());
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -271,10 +271,8 @@ namespace OpenSim.Data.MySQL
public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result)
{ {
string query = string.Empty;
query += "SELECT * FROM classifieds WHERE "; const string query = "SELECT * FROM classifieds WHERE classifieduuid = ?AdId";
query += "classifieduuid = ?AdId";
try try
{ {
@ -322,10 +320,8 @@ namespace OpenSim.Data.MySQL
#region Picks Queries #region Picks Queries
public OSDArray GetAvatarPicks(UUID avatarId) public OSDArray GetAvatarPicks(UUID avatarId)
{ {
string query = string.Empty; const string query = "SELECT `pickuuid`,`name` FROM userpicks WHERE creatoruuid = ?Id";
query += "SELECT `pickuuid`,`name` FROM userpicks WHERE ";
query += "creatoruuid = ?Id";
OSDArray data = new OSDArray(); OSDArray data = new OSDArray();
try try
@ -352,6 +348,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -364,12 +361,8 @@ namespace OpenSim.Data.MySQL
public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
{ {
string query = string.Empty;
UserProfilePick pick = new UserProfilePick(); UserProfilePick pick = new UserProfilePick();
const string query = "SELECT * FROM userpicks WHERE creatoruuid = ?CreatorId AND pickuuid = ?PickId";
query += "SELECT * FROM userpicks WHERE ";
query += "creatoruuid = ?CreatorId AND ";
query += "pickuuid = ?PickId";
try try
{ {
@ -422,33 +415,33 @@ namespace OpenSim.Data.MySQL
public bool UpdatePicksRecord(UserProfilePick pick) public bool UpdatePicksRecord(UserProfilePick pick)
{ {
string query = string.Empty; const string query =
"INSERT INTO userpicks VALUES ("
query += "INSERT INTO userpicks VALUES ("; + "?PickId,"
query += "?PickId,"; + "?CreatorId,"
query += "?CreatorId,"; + "?TopPick,"
query += "?TopPick,"; + "?ParcelId,"
query += "?ParcelId,"; + "?Name,"
query += "?Name,"; + "?Desc,"
query += "?Desc,"; + "?SnapshotId,"
query += "?SnapshotId,"; + "?User,"
query += "?User,"; + "?Original,"
query += "?Original,"; + "?SimName,"
query += "?SimName,"; + "?GlobalPos,"
query += "?GlobalPos,"; + "?SortOrder,"
query += "?SortOrder,"; + "?Enabled,"
query += "?Enabled,"; + "?Gatekeeper)"
query += "?Gatekeeper)"; + "ON DUPLICATE KEY UPDATE "
query += "ON DUPLICATE KEY UPDATE "; + "parceluuid=?ParcelId,"
query += "parceluuid=?ParcelId,"; + "name=?Name,"
query += "name=?Name,"; + "description=?Desc,"
query += "description=?Desc,"; + "user=?User,"
query += "user=?User,"; + "simname=?SimName,"
query += "simname=?SimName,"; + "snapshotuuid=?SnapshotId,"
query += "snapshotuuid=?SnapshotId,"; + "pickuuid=?PickId,"
query += "pickuuid=?PickId,"; + "posglobal=?GlobalPos,"
query += "posglobal=?GlobalPos,"; + "gatekeeper=?Gatekeeper"
query += "gatekeeper=?Gatekeeper"; ;
try try
{ {
@ -474,6 +467,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -487,10 +481,7 @@ namespace OpenSim.Data.MySQL
public bool DeletePicksRecord(UUID pickId) public bool DeletePicksRecord(UUID pickId)
{ {
string query = string.Empty; string query = "DELETE FROM userpicks WHERE pickuuid = ?PickId";
query += "DELETE FROM userpicks WHERE ";
query += "pickuuid = ?PickId";
try try
{ {
@ -504,6 +495,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -519,11 +511,7 @@ namespace OpenSim.Data.MySQL
#region Avatar Notes Queries #region Avatar Notes Queries
public bool GetAvatarNotes(ref UserProfileNotes notes) public bool GetAvatarNotes(ref UserProfileNotes notes)
{ // WIP { // WIP
string query = string.Empty; const string query = "SELECT `notes` FROM usernotes WHERE useruuid = ?Id AND targetuuid = ?TargetId";
query += "SELECT `notes` FROM usernotes WHERE ";
query += "useruuid = ?Id AND ";
query += "targetuuid = ?TargetId";
try try
{ {
@ -548,6 +536,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -560,26 +549,25 @@ namespace OpenSim.Data.MySQL
public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
{ {
string query = string.Empty; string query;
bool remove; bool remove;
if(string.IsNullOrEmpty(note.Notes)) if(string.IsNullOrEmpty(note.Notes))
{ {
remove = true; remove = true;
query += "DELETE FROM usernotes WHERE "; query = "DELETE FROM usernotes WHERE useruuid=?UserId AND targetuuid=?TargetId";
query += "useruuid=?UserId AND ";
query += "targetuuid=?TargetId";
} }
else else
{ {
remove = false; remove = false;
query += "INSERT INTO usernotes VALUES ( "; query = "INSERT INTO usernotes VALUES ("
query += "?UserId,"; + "?UserId,"
query += "?TargetId,"; + "?TargetId,"
query += "?Notes )"; + "?Notes )"
query += "ON DUPLICATE KEY "; + "ON DUPLICATE KEY "
query += "UPDATE "; + "UPDATE "
query += "notes=?Notes"; + "notes=?Notes"
;
} }
try try
@ -596,6 +584,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -612,10 +601,7 @@ namespace OpenSim.Data.MySQL
#region Avatar Properties #region Avatar Properties
public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) public bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
{ {
string query = string.Empty; string query = "SELECT * FROM userprofile WHERE useruuid = ?Id";
query += "SELECT * FROM userprofile WHERE ";
query += "useruuid = ?Id";
try try
{ {
@ -664,35 +650,36 @@ namespace OpenSim.Data.MySQL
props.PublishProfile = false; props.PublishProfile = false;
props.PublishMature = false; props.PublishMature = false;
query = "INSERT INTO userprofile ("; query = "INSERT INTO userprofile ("
query += "useruuid, "; + "useruuid, "
query += "profilePartner, "; + "profilePartner, "
query += "profileAllowPublish, "; + "profileAllowPublish, "
query += "profileMaturePublish, "; + "profileMaturePublish, "
query += "profileURL, "; + "profileURL, "
query += "profileWantToMask, "; + "profileWantToMask, "
query += "profileWantToText, "; + "profileWantToText, "
query += "profileSkillsMask, "; + "profileSkillsMask, "
query += "profileSkillsText, "; + "profileSkillsText, "
query += "profileLanguages, "; + "profileLanguages, "
query += "profileImage, "; + "profileImage, "
query += "profileAboutText, "; + "profileAboutText, "
query += "profileFirstImage, "; + "profileFirstImage, "
query += "profileFirstText) VALUES ("; + "profileFirstText) VALUES ("
query += "?userId, "; + "?userId, "
query += "?profilePartner, "; + "?profilePartner, "
query += "?profileAllowPublish, "; + "?profileAllowPublish, "
query += "?profileMaturePublish, "; + "?profileMaturePublish, "
query += "?profileURL, "; + "?profileURL, "
query += "?profileWantToMask, "; + "?profileWantToMask, "
query += "?profileWantToText, "; + "?profileWantToText, "
query += "?profileSkillsMask, "; + "?profileSkillsMask, "
query += "?profileSkillsText, "; + "?profileSkillsText, "
query += "?profileLanguages, "; + "?profileLanguages, "
query += "?profileImage, "; + "?profileImage, "
query += "?profileAboutText, "; + "?profileAboutText, "
query += "?profileFirstImage, "; + "?profileFirstImage, "
query += "?profileFirstText)"; + "?profileFirstText)"
;
dbcon.Close(); dbcon.Close();
dbcon.Open(); dbcon.Open();
@ -719,6 +706,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -733,15 +721,10 @@ namespace OpenSim.Data.MySQL
public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
{ {
string query = string.Empty; const string query = "UPDATE userprofile SET profileURL=?profileURL,"
+ "profileImage=?image, profileAboutText=?abouttext,"
query += "UPDATE userprofile SET "; + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext "
query += "profileURL=?profileURL, "; + "WHERE useruuid=?uuid";
query += "profileImage=?image, ";
query += "profileAboutText=?abouttext,";
query += "profileFirstImage=?firstlifeimage,";
query += "profileFirstText=?firstlifetext ";
query += "WHERE useruuid=?uuid";
try try
{ {
@ -759,6 +742,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -775,15 +759,13 @@ namespace OpenSim.Data.MySQL
#region Avatar Interests #region Avatar Interests
public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) public bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
{ {
string query = string.Empty; const string query = "UPDATE userprofile SET "
+ "profileWantToMask=?WantMask, "
query += "UPDATE userprofile SET "; + "profileWantToText=?WantText,"
query += "profileWantToMask=?WantMask, "; + "profileSkillsMask=?SkillsMask,"
query += "profileWantToText=?WantText,"; + "profileSkillsText=?SkillsText, "
query += "profileSkillsMask=?SkillsMask,"; + "profileLanguages=?Languages "
query += "profileSkillsText=?SkillsText, "; + "WHERE useruuid=?uuid";
query += "profileLanguages=?Languages ";
query += "WHERE useruuid=?uuid";
try try
{ {
@ -817,18 +799,17 @@ namespace OpenSim.Data.MySQL
public OSDArray GetUserImageAssets(UUID avatarId) public OSDArray GetUserImageAssets(UUID avatarId)
{ {
OSDArray data = new OSDArray(); OSDArray data = new OSDArray();
string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; const string queryA = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
// Get classified image assets // Get classified image assets
try try
{ {
using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
{ {
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`classifieds`"), dbcon))
{ {
cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
@ -847,7 +828,7 @@ namespace OpenSim.Data.MySQL
dbcon.Close(); dbcon.Close();
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`userpicks`"), dbcon))
{ {
cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
@ -866,9 +847,9 @@ namespace OpenSim.Data.MySQL
dbcon.Close(); dbcon.Close();
dbcon.Open(); dbcon.Open();
query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; const string queryB = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) using (MySqlCommand cmd = new MySqlCommand(string.Format (queryB,"`userpicks`"), dbcon))
{ {
cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
@ -884,6 +865,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -897,11 +879,7 @@ namespace OpenSim.Data.MySQL
#region User Preferences #region User Preferences
public bool GetUserPreferences(ref UserPreferences pref, ref string result) public bool GetUserPreferences(ref UserPreferences pref, ref string result)
{ {
string query = string.Empty; const string query = "SELECT imviaemail,visible,email FROM usersettings WHERE useruuid = ?Id";
query += "SELECT imviaemail,visible,email FROM ";
query += "usersettings WHERE ";
query += "useruuid = ?Id";
try try
{ {
@ -925,10 +903,9 @@ namespace OpenSim.Data.MySQL
dbcon.Close(); dbcon.Close();
dbcon.Open(); dbcon.Open();
query = "INSERT INTO usersettings VALUES "; const string queryB = "INSERT INTO usersettings VALUES (?uuid,'false','false', ?Email)";
query += "(?uuid,'false','false', ?Email)";
using (MySqlCommand put = new MySqlCommand(query, dbcon)) using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
{ {
put.Parameters.AddWithValue("?Email", pref.EMail); put.Parameters.AddWithValue("?Email", pref.EMail);
@ -939,6 +916,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -953,13 +931,9 @@ namespace OpenSim.Data.MySQL
public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
{ {
string query = string.Empty; const string query = "UPDATE usersettings SET imviaemail=?ImViaEmail,"
+ "visible=?Visible, email=?EMail "
query += "UPDATE usersettings SET "; + "WHERE useruuid=?uuid";
query += "imviaemail=?ImViaEmail, ";
query += "visible=?Visible, ";
query += "email=?EMail ";
query += "WHERE useruuid=?uuid";
try try
{ {
@ -975,6 +949,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -991,11 +966,7 @@ namespace OpenSim.Data.MySQL
#region Integration #region Integration
public bool GetUserAppData(ref UserAppData props, ref string result) public bool GetUserAppData(ref UserAppData props, ref string result)
{ {
string query = string.Empty; const string query = "SELECT * FROM `userdata` WHERE UserId = ?Id AND TagId = ?TagId";
query += "SELECT * FROM `userdata` WHERE ";
query += "UserId = ?Id AND ";
query += "TagId = ?TagId";
try try
{ {
@ -1017,13 +988,8 @@ namespace OpenSim.Data.MySQL
} }
else else
{ {
query += "INSERT INTO userdata VALUES ( "; const string queryB = "INSERT INTO userdata VALUES (?UserId, ?TagId, ?DataKey, ?DataVal)";
query += "?UserId,"; using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
query += "?TagId,";
query += "?DataKey,";
query += "?DataVal) ";
using (MySqlCommand put = new MySqlCommand(query, dbcon))
{ {
put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); put.Parameters.AddWithValue("?UserId", props.UserId.ToString());
put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); put.Parameters.AddWithValue("?TagId", props.TagId.ToString());
@ -1035,6 +1001,7 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)
@ -1049,14 +1016,7 @@ namespace OpenSim.Data.MySQL
public bool SetUserAppData(UserAppData props, ref string result) public bool SetUserAppData(UserAppData props, ref string result)
{ {
string query = string.Empty; const string query = "UPDATE userdata SET TagId = ?TagId, DataKey = ?DataKey, DataVal = ?DataVal WHERE UserId = ?UserId AND TagId = ?TagId";
query += "UPDATE userdata SET ";
query += "TagId = ?TagId, ";
query += "DataKey = ?DataKey, ";
query += "DataVal = ?DataVal WHERE ";
query += "UserId = ?UserId AND ";
query += "TagId = ?TagId";
try try
{ {
@ -1072,6 +1032,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
dbcon.Close();
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -97,6 +97,7 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
Migration m = new Migration(dbcon, Assembly, "XAssetStore"); Migration m = new Migration(dbcon, Assembly, "XAssetStore");
m.Update(); m.Update();
dbcon.Close();
} }
} }
@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
AssetBase asset = null; AssetBase asset = null;
int accessTime = 0;
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -140,7 +142,6 @@ namespace OpenSim.Data.MySQL
dbcon)) dbcon))
{ {
cmd.Parameters.AddWithValue("?ID", assetID.ToString()); cmd.Parameters.AddWithValue("?ID", assetID.ToString());
try try
{ {
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@ -159,23 +160,7 @@ namespace OpenSim.Data.MySQL
asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
accessTime = (int)dbReader["AccessTime"];
if (m_enableCompression)
{
using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
{
MemoryStream outputStream = new MemoryStream();
WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
// int compressedLength = asset.Data.Length;
asset.Data = outputStream.ToArray();
// m_log.DebugFormat(
// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
// asset.ID, asset.Name, asset.Data.Length, compressedLength);
}
}
UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
} }
} }
} }
@ -184,9 +169,38 @@ namespace OpenSim.Data.MySQL
m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
} }
} }
dbcon.Close();
} }
return asset; if(asset == null)
return asset;
if(accessTime > 0)
{
try
{
UpdateAccessTime(asset.Metadata, accessTime);
}
catch { }
}
if (m_enableCompression && asset.Data != null)
{
using(MemoryStream ms = new MemoryStream(asset.Data))
using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
{
using(MemoryStream outputStream = new MemoryStream())
{
decompressionStream.CopyTo(outputStream, int.MaxValue);
// int compressedLength = asset.Data.Length;
asset.Data = outputStream.ToArray();
}
// m_log.DebugFormat(
// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
// asset.ID, asset.Name, asset.Data.Length, compressedLength);
}
}
return asset;
} }
/// <summary> /// <summary>
@ -303,6 +317,7 @@ namespace OpenSim.Data.MySQL
transaction.Commit(); transaction.Commit();
} }
dbcon.Close();
} }
} }
@ -344,6 +359,7 @@ namespace OpenSim.Data.MySQL
"[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
assetMetadata.ID, assetMetadata.Name); assetMetadata.ID, assetMetadata.Name);
} }
dbcon.Close();
} }
} }
@ -474,6 +490,7 @@ namespace OpenSim.Data.MySQL
m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
} }
} }
dbcon.Close();
} }
return retList; return retList;
@ -492,9 +509,9 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?ID", id); cmd.Parameters.AddWithValue("?ID", id);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
// TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
// keep a reference count (?) // keep a reference count (?)
dbcon.Close();
} }
return true; return true;

View File

@ -328,7 +328,6 @@ namespace OpenSim.Data.MySQL
{ {
return false; return false;
} }
cmd.Dispose();
} }
dbcon.Close(); dbcon.Close();

View File

@ -18,7 +18,7 @@ CREATE TABLE `os_groups_groups` (
PRIMARY KEY (`GroupID`), PRIMARY KEY (`GroupID`),
UNIQUE KEY `Name` (`Name`), UNIQUE KEY `Name` (`Name`),
FULLTEXT KEY `Name_2` (`Name`) FULLTEXT KEY `Name_2` (`Name`)
) ENGINE=InnoDB; ) ENGINE=MyISAM;
CREATE TABLE `os_groups_membership` ( CREATE TABLE `os_groups_membership` (

View File

@ -173,16 +173,18 @@ namespace OpenSim.Data.PGSQL
if (m_enableCompression) if (m_enableCompression)
{ {
using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) using(MemoryStream ms = new MemoryStream(asset.Data))
using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
{ {
MemoryStream outputStream = new MemoryStream(); using(MemoryStream outputStream = new MemoryStream())
WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); {
// int compressedLength = asset.Data.Length; decompressionStream.CopyTo(outputStream,int.MaxValue);
asset.Data = outputStream.ToArray(); // int compressedLength = asset.Data.Length;
asset.Data = outputStream.ToArray();
// m_log.DebugFormat( }
// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", // m_log.DebugFormat(
// asset.ID, asset.Name, asset.Data.Length, compressedLength); // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
// asset.ID, asset.Name, asset.Data.Length, compressedLength);
} }
} }

View File

@ -529,7 +529,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (psEvArgs.Request != null) if (psEvArgs.Request != null)
{ {
OSHttpRequest req = new OSHttpRequest(context, request); OSHttpRequest req = new OSHttpRequest(context, request);
string requestBody = String.Empty; string requestBody;
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
using(StreamReader reader = new StreamReader(req.InputStream, encoding)) using(StreamReader reader = new StreamReader(req.InputStream, encoding))
requestBody = reader.ReadToEnd(); requestBody = reader.ReadToEnd();
@ -695,7 +695,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
//m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler");
IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
string requestBody = String.Empty;
string requestBody;
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
using(StreamReader reader = new StreamReader(request.InputStream, encoding)) using(StreamReader reader = new StreamReader(request.InputStream, encoding))
requestBody = reader.ReadToEnd(); requestBody = reader.ReadToEnd();
@ -814,6 +815,8 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
request.InputStream.Dispose();
if (buffer != null) if (buffer != null)
{ {
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
@ -1119,7 +1122,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
String requestBody; String requestBody;
Stream requestStream = request.InputStream; Stream requestStream = Util.Copy(request.InputStream);
Stream innerStream = null; Stream innerStream = null;
try try
{ {
@ -1130,10 +1133,9 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8))
{
requestBody = reader.ReadToEnd(); requestBody = reader.ReadToEnd();
} }
}
finally finally
{ {
if (innerStream != null && innerStream.CanRead) if (innerStream != null && innerStream.CanRead)
@ -1396,13 +1398,10 @@ namespace OpenSim.Framework.Servers.HttpServer
//m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
Stream requestStream = request.InputStream; Stream requestStream = request.InputStream;
string requestBody = string.Empty; string requestBody;
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
using(StreamReader reader = new StreamReader(requestStream,encoding)) using(StreamReader reader = new StreamReader(requestStream, encoding))
requestBody = reader.ReadToEnd(); requestBody= reader.ReadToEnd();
if(requestStream.CanRead)
requestStream.Close();
//m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
@ -1725,12 +1724,10 @@ namespace OpenSim.Framework.Servers.HttpServer
byte[] buffer; byte[] buffer;
Stream requestStream = request.InputStream; Stream requestStream = request.InputStream;
string requestBody = string.Empty; string requestBody;
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
using(StreamReader reader = new StreamReader(requestStream,encoding)) using(StreamReader reader = new StreamReader(requestStream, encoding))
requestBody = reader.ReadToEnd(); requestBody = reader.ReadToEnd();
if(requestStream.CanRead)
requestStream.Close();
Hashtable keysvals = new Hashtable(); Hashtable keysvals = new Hashtable();
Hashtable headervals = new Hashtable(); Hashtable headervals = new Hashtable();
@ -2269,7 +2266,7 @@ namespace OpenSim.Framework.Servers.HttpServer
string file = Path.Combine(".", "http_500.html"); string file = Path.Combine(".", "http_500.html");
if (!File.Exists(file)) if (!File.Exists(file))
return getDefaultHTTP500(); return getDefaultHTTP500();
string result = string.Empty; string result;
using(StreamReader sr = File.OpenText(file)) using(StreamReader sr = File.OpenText(file))
result = sr.ReadToEnd(); result = sr.ReadToEnd();
return result; return result;

View File

@ -50,11 +50,10 @@ namespace OpenSim.Framework.Servers.HttpServer
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
string requestBody;
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
StreamReader streamReader = new StreamReader(request, encoding); using(StreamReader streamReader = new StreamReader(request,encoding))
requestBody = streamReader.ReadToEnd();
string requestBody = streamReader.ReadToEnd();
streamReader.Close();
string param = GetParam(path); string param = GetParam(path);
string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse); string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse);

View File

@ -185,8 +185,9 @@ namespace OpenSim.Region.ClientStack.Linden
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader reader = new StreamReader(request); string message;
string message = reader.ReadToEnd(); using(StreamReader reader = new StreamReader(request))
message = reader.ReadToEnd();
OSD osd = OSDParser.DeserializeLLSDXml(message); OSD osd = OSDParser.DeserializeLLSDXml(message);

View File

@ -216,6 +216,8 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
rc.Request(reqStream, m_Auth); rc.Request(reqStream, m_Auth);
m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId); m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId);
} }
if(reqStream != null)
reqStream.Dispose();
}, null, "XBakesModule.Store" }, null, "XBakesModule.Store"
); );
} }

View File

@ -65,9 +65,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
protected override byte[] ProcessRequest( protected override byte[] ProcessRequest(
string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -119,7 +119,15 @@ namespace OpenSim.Region.CoreModules.Framework
if(!client.IsActive) if(!client.IsActive)
return; return;
GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID); if(m_scenes.Count == 0)
return;
Scene baseScene = m_scenes[0];
if(baseScene == null || baseScene.ShuttingDown)
return;
GridRegion r = baseScene.GridService.GetRegionByUUID(UUID.Zero, regionID);
if(!client.IsActive) if(!client.IsActive)
return; return;

View File

@ -60,9 +60,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
// m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body); // m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);

View File

@ -460,9 +460,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
if (resp.ContentLength > 0) if (resp.ContentLength > 0)
{ {
StreamReader content = new StreamReader(resp.GetResponseStream()); using(StreamReader content = new StreamReader(resp.GetResponseStream()))
m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd()); m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
content.Close();
} }
} }
} }

View File

@ -901,7 +901,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
// Update the founder with new group information. // Update the founder with new group information.
SendAgentGroupDataUpdate(remoteClient, false); SendAgentGroupDataUpdate(remoteClient, true);
return groupID; return groupID;
} }
@ -1520,6 +1520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
lastname, activeGroupPowers, activeGroupName, lastname, activeGroupPowers, activeGroupName,
activeGroupTitle); activeGroupTitle);
if (tellOthers) if (tellOthers)
SendScenePresenceUpdate(agentID, activeGroupTitle); SendScenePresenceUpdate(agentID, activeGroupTitle);

View File

@ -82,11 +82,11 @@ namespace OpenSim.Server.Handlers.Authentication
switch (p[0]) switch (p[0])
{ {
case "plain": case "plain":
StreamReader sr = new StreamReader(request); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(request))
sr.Close(); body = sr.ReadToEnd();
return DoPlainMethods(body); return DoPlainMethods(body);
case "crypt": case "crypt":
byte[] buffer = new byte[request.Length]; byte[] buffer = new byte[request.Length];
long length = request.Length; long length = request.Length;

View File

@ -222,7 +222,10 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
try try
{ {
NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd()); string forPost;
using(StreamReader sr = new StreamReader(httpRequest.InputStream))
forPost = sr.ReadToEnd();
NameValueCollection postQuery = HttpUtility.ParseQueryString(forPost);
NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query); NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query);
NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery); NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery);

View File

@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.Avatar
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -65,10 +65,8 @@ namespace OpenSim.Server.Handlers.BakedTextures
return new byte[0]; return new byte[0];
} }
StreamReader sr = new StreamReader(request); using(StreamReader sr = new StreamReader(request))
m_BakesService.Store(p[0],sr.ReadToEnd());
m_BakesService.Store(p[0], sr.ReadToEnd());
sr.Close();
return new byte[0]; return new byte[0];
} }

View File

@ -282,9 +282,10 @@ namespace OpenSim.Server.Handlers
// /estates/estate/?eid=int&region=uuid // /estates/estate/?eid=int&region=uuid
if ("estate".Equals(resource)) if ("estate".Equals(resource))
{ {
StreamReader sr = new StreamReader(request); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(request))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body); Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body);

View File

@ -61,9 +61,9 @@ namespace OpenSim.Server.Handlers.Friends
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -65,9 +65,9 @@ namespace OpenSim.Server.Handlers.Grid
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.GridUser
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -71,9 +71,9 @@ namespace OpenSim.Server.Handlers.Hypergrid
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -95,9 +95,9 @@ namespace OpenSim.Server.Handlers.Inventory
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body); //m_log.DebugFormat("[XXX]: query String: {0}", body);

View File

@ -104,9 +104,9 @@ namespace OpenSim.Server.Handlers.MapImage
protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); // m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
try try

View File

@ -102,9 +102,9 @@ namespace OpenSim.Server.Handlers.MapImage
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); // m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
try try
@ -215,13 +215,16 @@ namespace OpenSim.Server.Handlers.MapImage
private byte[] DocToBytes(XmlDocument doc) private byte[] DocToBytes(XmlDocument doc)
{ {
MemoryStream ms = new MemoryStream(); using(MemoryStream ms = new MemoryStream())
XmlTextWriter xw = new XmlTextWriter(ms, null); {
xw.Formatting = Formatting.Indented; using(XmlTextWriter xw = new XmlTextWriter(ms,null))
doc.WriteTo(xw); {
xw.Flush(); xw.Formatting = Formatting.Indented;
doc.WriteTo(xw);
xw.Flush();
}
return ms.ToArray(); return ms.ToArray();
}
} }
private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)

View File

@ -72,9 +72,9 @@ namespace OpenSim.Server.Handlers.UserAccounts
protected override byte[] ProcessRequest(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); string body;
string body = sr.ReadToEnd(); using(StreamReader sr = new StreamReader(requestData))
sr.Close(); body = sr.ReadToEnd();
body = body.Trim(); body = body.Trim();
// We need to check the authorization header // We need to check the authorization header

View File

@ -183,8 +183,8 @@ namespace OpenSim.Services.Connectors
{ {
using (StreamReader sr = new StreamReader(s)) using (StreamReader sr = new StreamReader(s))
{ {
sr.ReadToEnd(); // just try to read
//reply = sr.ReadToEnd().Trim(); //reply = sr.ReadToEnd().Trim();
sr.ReadToEnd().Trim();
//m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
} }
} }

View File

@ -0,0 +1,339 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenMetaverse;
using OpenSim.Data;
namespace OpenSim.Tests.Common.Mock
{
public class TestGroupsDataPlugin : IGroupsData
{
class CompositeKey
{
private readonly string _key;
public string Key
{
get { return _key; }
}
public CompositeKey(UUID _k1, string _k2)
{
_key = _k1.ToString() + _k2;
}
public CompositeKey(UUID _k1, string _k2, string _k3)
{
_key = _k1.ToString() + _k2 + _k3;
}
public override bool Equals(object obj)
{
if (obj is CompositeKey)
{
return Key == ((CompositeKey)obj).Key;
}
return false;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
return Key;
}
}
private Dictionary<UUID, GroupData> m_Groups;
private Dictionary<CompositeKey, MembershipData> m_Membership;
private Dictionary<CompositeKey, RoleData> m_Roles;
private Dictionary<CompositeKey, RoleMembershipData> m_RoleMembership;
private Dictionary<UUID, InvitationData> m_Invites;
private Dictionary<UUID, NoticeData> m_Notices;
private Dictionary<string, PrincipalData> m_Principals;
public TestGroupsDataPlugin(string connectionString, string realm)
{
m_Groups = new Dictionary<UUID, GroupData>();
m_Membership = new Dictionary<CompositeKey, MembershipData>();
m_Roles = new Dictionary<CompositeKey, RoleData>();
m_RoleMembership = new Dictionary<CompositeKey, RoleMembershipData>();
m_Invites = new Dictionary<UUID, InvitationData>();
m_Notices = new Dictionary<UUID, NoticeData>();
m_Principals = new Dictionary<string, PrincipalData>();
}
#region groups table
public bool StoreGroup(GroupData data)
{
return false;
}
public GroupData RetrieveGroup(UUID groupID)
{
if (m_Groups.ContainsKey(groupID))
return m_Groups[groupID];
return null;
}
public GroupData RetrieveGroup(string name)
{
return m_Groups.Values.First(g => g.Data.ContainsKey("Name") && g.Data["Name"] == name);
}
public GroupData[] RetrieveGroups(string pattern)
{
if (string.IsNullOrEmpty(pattern))
pattern = "1";
IEnumerable<GroupData> groups = m_Groups.Values.Where(g => g.Data.ContainsKey("Name") && (g.Data["Name"].StartsWith(pattern) || g.Data["Name"].EndsWith(pattern)));
return (groups != null) ? groups.ToArray() : new GroupData[0];
}
public bool DeleteGroup(UUID groupID)
{
return m_Groups.Remove(groupID);
}
public int GroupsCount()
{
return m_Groups.Count;
}
#endregion
#region membership table
public MembershipData RetrieveMember(UUID groupID, string pricipalID)
{
CompositeKey dkey = new CompositeKey(groupID, pricipalID);
if (m_Membership.ContainsKey(dkey))
return m_Membership[dkey];
return null;
}
public MembershipData[] RetrieveMembers(UUID groupID)
{
IEnumerable<CompositeKey> keys = m_Membership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray();
}
public MembershipData[] RetrieveMemberships(string principalID)
{
IEnumerable<CompositeKey> keys = m_Membership.Keys.Where(k => k.Key.EndsWith(principalID.ToString()));
return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray();
}
public MembershipData[] RetrievePrincipalGroupMemberships(string principalID)
{
return RetrieveMemberships(principalID);
}
public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID)
{
CompositeKey dkey = new CompositeKey(groupID, principalID);
if (m_Membership.ContainsKey(dkey))
return m_Membership[dkey];
return null;
}
public bool StoreMember(MembershipData data)
{
CompositeKey dkey = new CompositeKey(data.GroupID, data.PrincipalID);
m_Membership[dkey] = data;
return true;
}
public bool DeleteMember(UUID groupID, string principalID)
{
CompositeKey dkey = new CompositeKey(groupID, principalID);
if (m_Membership.ContainsKey(dkey))
return m_Membership.Remove(dkey);
return false;
}
public int MemberCount(UUID groupID)
{
return m_Membership.Count;
}
#endregion
#region roles table
public bool StoreRole(RoleData data)
{
CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString());
m_Roles[dkey] = data;
return true;
}
public RoleData RetrieveRole(UUID groupID, UUID roleID)
{
CompositeKey dkey = new CompositeKey(groupID, roleID.ToString());
if (m_Roles.ContainsKey(dkey))
return m_Roles[dkey];
return null;
}
public RoleData[] RetrieveRoles(UUID groupID)
{
IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
return keys.Where(m_Roles.ContainsKey).Select(x => m_Roles[x]).ToArray();
}
public bool DeleteRole(UUID groupID, UUID roleID)
{
CompositeKey dkey = new CompositeKey(groupID, roleID.ToString());
if (m_Roles.ContainsKey(dkey))
return m_Roles.Remove(dkey);
return false;
}
public int RoleCount(UUID groupID)
{
return m_Roles.Count;
}
#endregion
#region rolememberhip table
public RoleMembershipData[] RetrieveRolesMembers(UUID groupID)
{
IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
}
public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID)
{
IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString() + roleID.ToString()));
return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
}
public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID)
{
IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID));
return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
}
public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID)
{
CompositeKey dkey = new CompositeKey(groupID, roleID.ToString(), principalID);
if (m_RoleMembership.ContainsKey(dkey))
return m_RoleMembership[dkey];
return null;
}
public int RoleMemberCount(UUID groupID, UUID roleID)
{
return m_RoleMembership.Count;
}
public bool StoreRoleMember(RoleMembershipData data)
{
CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID);
m_RoleMembership[dkey] = data;
return true;
}
public bool DeleteRoleMember(RoleMembershipData data)
{
CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID);
if (m_RoleMembership.ContainsKey(dkey))
return m_RoleMembership.Remove(dkey);
return false;
}
public bool DeleteMemberAllRoles(UUID groupID, string principalID)
{
List<CompositeKey> keys = m_RoleMembership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)).ToList();
foreach (CompositeKey k in keys)
m_RoleMembership.Remove(k);
return true;
}
#endregion
#region principals table
public bool StorePrincipal(PrincipalData data)
{
m_Principals[data.PrincipalID] = data;
return true;
}
public PrincipalData RetrievePrincipal(string principalID)
{
if (m_Principals.ContainsKey(principalID))
return m_Principals[principalID];
return null;
}
public bool DeletePrincipal(string principalID)
{
if (m_Principals.ContainsKey(principalID))
return m_Principals.Remove(principalID);
return false;
}
#endregion
#region invites table
public bool StoreInvitation(InvitationData data)
{
return false;
}
public InvitationData RetrieveInvitation(UUID inviteID)
{
return null;
}
public InvitationData RetrieveInvitation(UUID groupID, string principalID)
{
return null;
}
public bool DeleteInvite(UUID inviteID)
{
return false;
}
public void DeleteOldInvites()
{
}
#endregion
#region notices table
public bool StoreNotice(NoticeData data)
{
return false;
}
public NoticeData RetrieveNotice(UUID noticeID)
{
return null;
}
public NoticeData[] RetrieveNotices(UUID groupID)
{
return new NoticeData[0];
}
public bool DeleteNotice(UUID noticeID)
{
return false;
}
public void DeleteOldNotices()
{
}
#endregion
}
}

View File

@ -72,12 +72,21 @@ namespace OpenSim.Tests.Permissions
IConfigSource config = new IniConfigSource(); IConfigSource config = new IniConfigSource();
config.AddConfig("Messaging"); config.AddConfig("Messaging");
config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule"); config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
config.AddConfig("Modules"); config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
config.AddConfig("InventoryService"); config.AddConfig("InventoryService");
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService"); config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin"); config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin");
config.AddConfig("Groups");
config.Configs["Groups"].Set("Enabled", "true");
config.Configs["Groups"].Set("Module", "Groups Module V2");
config.Configs["Groups"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestGroupsDataPlugin");
config.Configs["Groups"].Set("ServicesConnectorModule", "Groups Local Service Connector");
config.Configs["Groups"].Set("LocalService", "local");
m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config); m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config);
// Add modules // Add modules
SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule()); SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule());

Binary file not shown.