* Some more experimental work on distributed assets. Nothing hotwired yet.

* Introduced preprocess step in FetchAsset (Might revert this later)
  * Some minor CCC
  * Added actual implementation of GetUserProfile( uri ) and the corresponding handler to OGS1.
  * Introduced non-functioning GetUserUri( userProfile) awaiting user server wireup (this might move elsewhere)
0.6.5-rc1
lbsa71 2009-04-13 20:04:18 +00:00
parent bd7d00db33
commit 29355de6ee
12 changed files with 238 additions and 150 deletions

View File

@ -25,7 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
@ -33,7 +36,13 @@ namespace OpenSim.Data
{ {
public abstract class AssetDataBase : IAssetDataPlugin public abstract class AssetDataBase : IAssetDataPlugin
{ {
public abstract AssetBase FetchAsset(UUID uuid); public virtual AssetBase FetchAsset(UUID uuid)
{
return FetchStoredAsset(uuid);
}
protected abstract AssetBase FetchStoredAsset(UUID uuid);
public abstract void CreateAsset(AssetBase asset); public abstract void CreateAsset(AssetBase asset);
public abstract void UpdateAsset(AssetBase asset); public abstract void UpdateAsset(AssetBase asset);
public abstract bool ExistsAsset(UUID uuid); public abstract bool ExistsAsset(UUID uuid);

View File

@ -43,11 +43,11 @@ namespace OpenSim.Data.MSSQL
private const string _migrationStore = "AssetStore"; private const string _migrationStore = "AssetStore";
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private long TicksToEpoch; private long m_ticksToEpoch;
/// <summary> /// <summary>
/// Database manager /// Database manager
/// </summary> /// </summary>
private MSSQLManager database; private MSSQLManager m_database;
#region IPlugin Members #region IPlugin Members
@ -72,11 +72,11 @@ namespace OpenSim.Data.MSSQL
/// <param name="connectionString">connect string</param> /// <param name="connectionString">connect string</param>
override public void Initialise(string connectionString) override public void Initialise(string connectionString)
{ {
TicksToEpoch = new System.DateTime(1970, 1, 1).Ticks; m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
if (!string.IsNullOrEmpty(connectionString)) if (!string.IsNullOrEmpty(connectionString))
{ {
database = new MSSQLManager(connectionString); m_database = new MSSQLManager(connectionString);
} }
else else
{ {
@ -88,13 +88,13 @@ namespace OpenSim.Data.MSSQL
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id"); string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password"); string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
database = m_database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword); settingPassword);
} }
//New migration to check for DB changes //New migration to check for DB changes
database.CheckMigration(_migrationStore); m_database.CheckMigration(_migrationStore);
} }
/// <summary> /// <summary>
@ -102,7 +102,7 @@ namespace OpenSim.Data.MSSQL
/// </summary> /// </summary>
override public string Version override public string Version
{ {
get { return database.getVersion(); } get { return m_database.getVersion(); }
} }
/// <summary> /// <summary>
@ -118,15 +118,15 @@ namespace OpenSim.Data.MSSQL
#region IAssetDataPlugin Members #region IAssetDataPlugin Members
/// <summary> /// <summary>
/// Fetch Asset from database /// Fetch Asset from m_database
/// </summary> /// </summary>
/// <param name="assetID">the asset UUID</param> /// <param name="assetID">the asset UUID</param>
/// <returns></returns> /// <returns></returns>
override public AssetBase FetchAsset(UUID assetID) override protected AssetBase FetchStoredAsset(UUID assetID)
{ {
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM assets WHERE id = @id")) using (AutoClosingSqlCommand command = m_database.Query("SELECT * FROM assets WHERE id = @id"))
{ {
command.Parameters.Add(database.CreateParameter("id", assetID)); command.Parameters.Add(m_database.CreateParameter("id", assetID));
using (IDataReader reader = command.ExecuteReader()) using (IDataReader reader = command.ExecuteReader())
{ {
if (reader.Read()) if (reader.Read())
@ -148,7 +148,7 @@ namespace OpenSim.Data.MSSQL
} }
/// <summary> /// <summary>
/// Create asset in database /// Create asset in m_database
/// </summary> /// </summary>
/// <param name="asset">the asset</param> /// <param name="asset">the asset</param>
override public void CreateAsset(AssetBase asset) override public void CreateAsset(AssetBase asset)
@ -158,33 +158,33 @@ namespace OpenSim.Data.MSSQL
return; return;
} }
using (AutoClosingSqlCommand command = database.Query( using (AutoClosingSqlCommand command = m_database.Query(
"INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" + "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" +
" VALUES " + " VALUES " +
"(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)")) "(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)"))
{ {
int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
command.Parameters.Add(database.CreateParameter("id", asset.FullID)); command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
command.Parameters.Add(database.CreateParameter("name", asset.Name)); command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
command.Parameters.Add(database.CreateParameter("description", asset.Description)); command.Parameters.Add(m_database.CreateParameter("description", asset.Description));
command.Parameters.Add(database.CreateParameter("assetType", asset.Type)); command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
command.Parameters.Add(database.CreateParameter("local", asset.Local)); command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary)); command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
command.Parameters.Add(database.CreateParameter("access_time", now)); command.Parameters.Add(m_database.CreateParameter("access_time", now));
command.Parameters.Add(database.CreateParameter("create_time", now)); command.Parameters.Add(m_database.CreateParameter("create_time", now));
command.Parameters.Add(database.CreateParameter("data", asset.Data)); command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }
/// <summary> /// <summary>
/// Update asset in database /// Update asset in m_database
/// </summary> /// </summary>
/// <param name="asset">the asset</param> /// <param name="asset">the asset</param>
override public void UpdateAsset(AssetBase asset) override public void UpdateAsset(AssetBase asset)
{ {
using (AutoClosingSqlCommand command = database.Query("UPDATE assets set id = @id, " + using (AutoClosingSqlCommand command = m_database.Query("UPDATE assets set id = @id, " +
"name = @name, " + "name = @name, " +
"description = @description," + "description = @description," +
"assetType = @assetType," + "assetType = @assetType," +
@ -193,14 +193,14 @@ namespace OpenSim.Data.MSSQL
"data = @data where " + "data = @data where " +
"id = @keyId;")) "id = @keyId;"))
{ {
command.Parameters.Add(database.CreateParameter("id", asset.FullID)); command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
command.Parameters.Add(database.CreateParameter("name", asset.Name)); command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
command.Parameters.Add(database.CreateParameter("description", asset.Description)); command.Parameters.Add(m_database.CreateParameter("description", asset.Description));
command.Parameters.Add(database.CreateParameter("assetType", asset.Type)); command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
command.Parameters.Add(database.CreateParameter("local", asset.Local)); command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary)); command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
command.Parameters.Add(database.CreateParameter("data", asset.Data)); command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
command.Parameters.Add(database.CreateParameter("@keyId", asset.FullID)); command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID));
try try
{ {
@ -216,9 +216,9 @@ namespace OpenSim.Data.MSSQL
// Commented out since currently unused - this probably should be called in FetchAsset() // Commented out since currently unused - this probably should be called in FetchAsset()
// private void UpdateAccessTime(AssetBase asset) // private void UpdateAccessTime(AssetBase asset)
// { // {
// using (AutoClosingSqlCommand cmd = database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id")) // using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
// { // {
// int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); // int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
// cmd.Parameters.AddWithValue("@id", asset.FullID.ToString()); // cmd.Parameters.AddWithValue("@id", asset.FullID.ToString());
// cmd.Parameters.AddWithValue("@access_time", now); // cmd.Parameters.AddWithValue("@access_time", now);
// try // try
@ -233,7 +233,7 @@ namespace OpenSim.Data.MSSQL
// } // }
/// <summary> /// <summary>
/// Check if asset exist in database /// Check if asset exist in m_database
/// </summary> /// </summary>
/// <param name="uuid"></param> /// <param name="uuid"></param>
/// <returns>true if exist.</returns> /// <returns>true if exist.</returns>
@ -258,10 +258,10 @@ namespace OpenSim.Data.MSSQL
{ {
List<AssetMetadata> retList = new List<AssetMetadata>(count); List<AssetMetadata> retList = new List<AssetMetadata>(count);
using (AutoClosingSqlCommand command = database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count")) using (AutoClosingSqlCommand command = m_database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count"))
{ {
command.Parameters.Add(database.CreateParameter("start", start)); command.Parameters.Add(m_database.CreateParameter("start", start));
command.Parameters.Add(database.CreateParameter("count", count)); command.Parameters.Add(m_database.CreateParameter("count", count));
using (IDataReader reader = command.ExecuteReader()) using (IDataReader reader = command.ExecuteReader())
{ {

View File

@ -109,6 +109,24 @@ namespace OpenSim.Data.MySQL
public override void Dispose() { } public override void Dispose() { }
/// <summary>
/// Database provider version
/// </summary>
override public string Version
{
get { return _dbConnection.getVersion(); }
}
/// <summary>
/// The name of this DB provider
/// </summary>
override public string Name
{
get { return "MySQL Asset storage engine"; }
}
#endregion
#region IAssetDataPlugin Members #region IAssetDataPlugin Members
/// <summary> /// <summary>
@ -117,7 +135,7 @@ namespace OpenSim.Data.MySQL
/// <param name="assetID">Asset UUID to fetch</param> /// <param name="assetID">Asset UUID to fetch</param>
/// <returns>Return the asset</returns> /// <returns>Return the asset</returns>
/// <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 AssetBase FetchAsset(UUID assetID) override protected AssetBase FetchStoredAsset(UUID assetID)
{ {
AssetBase asset = null; AssetBase asset = null;
lock (_dbConnection) lock (_dbConnection)
@ -364,22 +382,6 @@ namespace OpenSim.Data.MySQL
#endregion #endregion
/// <summary>
/// Database provider version
/// </summary>
override public string Version
{
get { return _dbConnection.getVersion(); }
}
/// <summary>
/// The name of this DB provider
/// </summary>
override public string Name
{
get { return "MySQL Asset storage engine"; }
}
#endregion
} }
} }

View File

@ -65,7 +65,7 @@ namespace OpenSim.Data.NHibernate
} }
override public AssetBase FetchAsset(UUID uuid) override protected AssetBase FetchStoredAsset(UUID uuid)
{ {
return (AssetBase)manager.Get(typeof(AssetBase), uuid); return (AssetBase)manager.Get(typeof(AssetBase), uuid);
} }

View File

@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite
/// </summary> /// </summary>
/// <param name="uuid">UUID of ... ?</param> /// <param name="uuid">UUID of ... ?</param>
/// <returns>Asset base</returns> /// <returns>Asset base</returns>
override public AssetBase FetchAsset(UUID uuid) override protected AssetBase FetchStoredAsset(UUID uuid)
{ {
lock (this) lock (this)
{ {

View File

@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications.Cache
{ {
AssetInfo assetInf = new AssetInfo(asset); AssetInfo assetInf = new AssetInfo(asset);
ProcessReceivedAsset(IsTexture, assetInf); ProcessReceivedAsset(IsTexture, assetInf, null);
if (!m_memcache.Contains(assetInf.FullID)) if (!m_memcache.Contains(assetInf.FullID))
{ {
@ -391,11 +391,11 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService)
{ {
if(!IsTexture && assetInf.ContainsReferences && false ) if(!IsTexture && assetInf.ContainsReferences && false )
{ {
assetInf.Data = ProcessAssetData(assetInf.Data); assetInf.Data = ProcessAssetData(assetInf.Data, userService );
} }
} }
@ -554,11 +554,11 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
public byte[] ProcessAssetData(byte[] assetData) public byte[] ProcessAssetData(byte[] assetData, IUserService userService)
{ {
string data = Encoding.ASCII.GetString(assetData); string data = Encoding.ASCII.GetString(assetData);
data = ProcessAssetDataString(data, null); data = ProcessAssetDataString(data, userService );
return Encoding.ASCII.GetBytes( data ); return Encoding.ASCII.GetBytes( data );
} }

View File

@ -50,6 +50,8 @@ namespace OpenSim.Framework.Communications
UserProfileData GetUserProfile(Uri uri); UserProfileData GetUserProfile(Uri uri);
Uri GetUserUri(UserProfileData userProfile);
UserAgentData GetAgentByUUID(UUID userId); UserAgentData GetAgentByUUID(UUID userId);
void ClearUserAgent(UUID avatarID); void ClearUserAgent(UUID avatarID);

View File

@ -108,6 +108,11 @@ namespace OpenSim.Framework.Communications.Tests
return userProfile; return userProfile;
} }
public Uri GetUserUri(UserProfileData userProfile)
{
throw new NotImplementedException();
}
public UserAgentData GetAgentByUUID(UUID userId) public UserAgentData GetAgentByUUID(UUID userId)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -124,7 +124,7 @@ namespace OpenSim.Framework.Communications
public UserProfileData GetUserProfile(Uri uri) public UserProfileData GetUserProfile(Uri uri)
{ {
throw new System.NotImplementedException(); throw new NotImplementedException();
} }
public UserAgentData GetAgentByUUID(UUID userId) public UserAgentData GetAgentByUUID(UUID userId)
@ -142,6 +142,11 @@ namespace OpenSim.Framework.Communications
return null; return null;
} }
public Uri GetUserUri(UserProfileData userProfile)
{
throw new NotImplementedException();
}
// see IUserService // see IUserService
public virtual UserProfileData GetUserProfile(UUID uuid) public virtual UserProfileData GetUserProfile(UUID uuid)
{ {
@ -835,6 +840,5 @@ namespace OpenSim.Framework.Communications
} }
#endregion #endregion
} }
} }

View File

@ -29,6 +29,7 @@ using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using log4net; using log4net;
@ -64,9 +65,9 @@ namespace OpenSim.Framework.Servers
OSHttpRequest httpRequest, OSHttpResponse httpResponse) OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{ {
string param = GetParam(path); string param = GetParam(path);
byte[] result = new byte[] {}; byte[] result = new byte[] { };
string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries);
if (p.Length > 0) if (p.Length > 0)
{ {
@ -85,7 +86,12 @@ namespace OpenSim.Framework.Servers
AssetBase asset = m_assetProvider.FetchAsset(assetID); AssetBase asset = m_assetProvider.FetchAsset(assetID);
if (asset != null) if (asset != null)
{ {
XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); if (asset.ContainsReferences && false)
{
asset.Data = ProcessOutgoingAssetData(asset.Data);
}
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
xw.Formatting = Formatting.Indented; xw.Formatting = Formatting.Indented;
@ -97,15 +103,7 @@ namespace OpenSim.Framework.Servers
result = ms.GetBuffer(); result = ms.GetBuffer();
//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there Array.Resize<byte>(ref result, (int)ms.Length);
//are multiple messages in a second and that is usually (in my experience) meaning
//the logging itself is slowing down the program. Leaving the unsuccesful message
//as we need to know about that path.
// m_log.InfoFormat(
// "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
// assetID, asset.Name, result.Length);
Array.Resize<byte>(ref result, (int) ms.Length);
} }
else else
{ {
@ -118,5 +116,50 @@ namespace OpenSim.Framework.Servers
return result; return result;
} }
private byte[] ProcessOutgoingAssetData(byte[] assetData)
{
string data = Encoding.ASCII.GetString(assetData);
data = ProcessAssetDataString(data);
return Encoding.ASCII.GetBytes(data);
}
public string ProcessAssetDataString(string data)
{
Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)");
// IUserService userService = null;
data = regex.Replace(data, delegate(Match m)
{
string result = String.Empty;
string key = m.Groups[1].Captures[0].Value;
string value = m.Groups[2].Captures[0].Value;
Guid userUri;
switch (key)
{
case "creator_id":
userUri = new Guid(value);
// result = "creator_url " + userService(userService, userUri);
break;
case "owner_id":
userUri = new Guid(value);
// result = "owner_url " + ResolveUserUri(userService, userUri);
break;
}
return result;
});
return data;
}
} }
} }

View File

@ -63,6 +63,11 @@ namespace OpenSim.Region.Communications.Hypergrid
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
public Uri GetUserUri(UserProfileData userProfile)
{
throw new NotImplementedException();
}
/// <summary> /// <summary>
/// Get a user agent from the user server /// Get a user agent from the user server
/// </summary> /// </summary>

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml.Serialization;
using log4net; using log4net;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenMetaverse; using OpenMetaverse;
@ -62,46 +63,46 @@ namespace OpenSim.Region.Communications.OGS1
} }
UserProfileData userData = new UserProfileData(); UserProfileData userData = new UserProfileData();
userData.FirstName = (string) data["firstname"]; userData.FirstName = (string)data["firstname"];
userData.SurName = (string) data["lastname"]; userData.SurName = (string)data["lastname"];
userData.ID = new UUID((string) data["uuid"]); userData.ID = new UUID((string)data["uuid"]);
userData.Created = Convert.ToInt32(data["profile_created"]); userData.Created = Convert.ToInt32(data["profile_created"]);
userData.UserInventoryURI = (string) data["server_inventory"]; userData.UserInventoryURI = (string)data["server_inventory"];
userData.UserAssetURI = (string) data["server_asset"]; userData.UserAssetURI = (string)data["server_asset"];
userData.FirstLifeAboutText = (string) data["profile_firstlife_about"]; userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
userData.FirstLifeImage = new UUID((string) data["profile_firstlife_image"]); userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]);
userData.CanDoMask = Convert.ToUInt32((string) data["profile_can_do"]); userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]); userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);
userData.AboutText = (string)data["profile_about"]; userData.AboutText = (string)data["profile_about"];
userData.Image = new UUID((string) data["profile_image"]); userData.Image = new UUID((string)data["profile_image"]);
userData.LastLogin = Convert.ToInt32((string) data["profile_lastlogin"]); userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
userData.HomeRegion = Convert.ToUInt64((string) data["home_region"]); userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]);
if (data.Contains("home_region_id")) if (data.Contains("home_region_id"))
userData.HomeRegionID = new UUID((string)data["home_region_id"]); userData.HomeRegionID = new UUID((string)data["home_region_id"]);
else else
userData.HomeRegionID = UUID.Zero; userData.HomeRegionID = UUID.Zero;
userData.HomeLocation = userData.HomeLocation =
new Vector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]), new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]),
(float) Convert.ToDecimal((string) data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]),
(float) Convert.ToDecimal((string) data["home_coordinates_z"])); (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
userData.HomeLookAt = userData.HomeLookAt =
new Vector3((float) Convert.ToDecimal((string) data["home_look_x"]), new Vector3((float)Convert.ToDecimal((string)data["home_look_x"]),
(float) Convert.ToDecimal((string) data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_y"]),
(float) Convert.ToDecimal((string) data["home_look_z"])); (float)Convert.ToDecimal((string)data["home_look_z"]));
if (data.Contains("user_flags")) if (data.Contains("user_flags"))
userData.UserFlags = Convert.ToInt32((string) data["user_flags"]); userData.UserFlags = Convert.ToInt32((string)data["user_flags"]);
if (data.Contains("god_level")) if (data.Contains("god_level"))
userData.GodLevel = Convert.ToInt32((string) data["god_level"]); userData.GodLevel = Convert.ToInt32((string)data["god_level"]);
if (data.Contains("custom_type")) if (data.Contains("custom_type"))
userData.CustomType = (string) data["custom_type"]; userData.CustomType = (string)data["custom_type"];
else else
userData.CustomType = ""; userData.CustomType = "";
if (userData.CustomType == null) if (userData.CustomType == null)
userData.CustomType = ""; userData.CustomType = "";
if (data.Contains("partner")) if (data.Contains("partner"))
userData.Partner = new UUID((string) data["partner"]); userData.Partner = new UUID((string)data["partner"]);
else else
userData.Partner = UUID.Zero; userData.Partner = UUID.Zero;
@ -110,7 +111,21 @@ namespace OpenSim.Region.Communications.OGS1
public UserProfileData GetUserProfile(Uri uri) public UserProfileData GetUserProfile(Uri uri)
{ {
throw new System.NotImplementedException(); WebRequest request = WebRequest.Create(uri);
WebResponse webResponse = request.GetResponse();
XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse));
XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream());
Hashtable respData = (Hashtable)xmlRpcResponse.Value;
return ConvertXMLRPCDataToUserProfile(respData);
}
public Uri GetUserUri(UserProfileData userProfile)
{
throw new NotImplementedException();
} }
/// <summary> /// <summary>
@ -120,40 +135,42 @@ namespace OpenSim.Region.Communications.OGS1
/// <returns>null if the request fails</returns> /// <returns>null if the request fails</returns>
public UserAgentData GetAgentByUUID(UUID userId) public UserAgentData GetAgentByUUID(UUID userId)
{ {
try try
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["avatar_uuid"] = userId.ToString(); param["avatar_uuid"] = userId.ToString();
IList parameters = new ArrayList(); IList parameters = new ArrayList();
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 6000); string url = m_commsManager.NetworkServersInfo.UserURL;
Hashtable respData = (Hashtable) resp.Value;
if (respData.Contains("error_type"))
{
//m_log.Warn("[GRID]: " +
// "Error sent by user server when trying to get agent: (" +
// (string) respData["error_type"] +
// "): " + (string)respData["error_desc"]);
return null;
}
UUID sessionid = UUID.Zero;
UserAgentData userAgent = new UserAgentData(); XmlRpcResponse resp = req.Send(url, 6000);
userAgent.Handle = Convert.ToUInt64((string)respData["handle"]); Hashtable respData = (Hashtable)resp.Value;
UUID.TryParse((string)respData["sessionid"], out sessionid); if (respData.Contains("error_type"))
userAgent.SessionID = sessionid; {
//m_log.Warn("[GRID]: " +
// "Error sent by user server when trying to get agent: (" +
// (string) respData["error_type"] +
// "): " + (string)respData["error_desc"]);
return null;
}
UUID sessionid = UUID.Zero;
if ((string)respData["agent_online"] == "TRUE") UserAgentData userAgent = new UserAgentData();
{ userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
userAgent.AgentOnline = true; UUID.TryParse((string)respData["sessionid"], out sessionid);
} userAgent.SessionID = sessionid;
else
{
userAgent.AgentOnline = false;
}
return userAgent; if ((string)respData["agent_online"] == "TRUE")
{
userAgent.AgentOnline = true;
}
else
{
userAgent.AgentOnline = false;
}
return userAgent;
} }
catch (Exception e) catch (Exception e)
{ {
@ -192,16 +209,16 @@ namespace OpenSim.Region.Communications.OGS1
public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data) public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
{ {
List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
int pickercount = Convert.ToInt32((string) data["avcount"]); int pickercount = Convert.ToInt32((string)data["avcount"]);
UUID respqueryID = new UUID((string) data["queryid"]); UUID respqueryID = new UUID((string)data["queryid"]);
if (queryID == respqueryID) if (queryID == respqueryID)
{ {
for (int i = 0; i < pickercount; i++) for (int i = 0; i < pickercount; i++)
{ {
AvatarPickerAvatar apicker = new AvatarPickerAvatar(); AvatarPickerAvatar apicker = new AvatarPickerAvatar();
UUID avatarID = new UUID((string) data["avatarid" + i.ToString()]); UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]);
string firstname = (string) data["firstname" + i.ToString()]; string firstname = (string)data["firstname" + i.ToString()];
string lastname = (string) data["lastname" + i.ToString()]; string lastname = (string)data["lastname" + i.ToString()];
apicker.AvatarID = avatarID; apicker.AvatarID = avatarID;
apicker.firstName = firstname; apicker.firstName = firstname;
apicker.lastName = lastname; apicker.lastName = lastname;
@ -298,13 +315,13 @@ namespace OpenSim.Region.Communications.OGS1
try try
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["queryid"] = (string) queryID.ToString(); param["queryid"] = (string)queryID.ToString();
param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty); param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty);
IList parameters = new ArrayList(); IList parameters = new ArrayList();
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters); XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = (Hashtable)resp.Value;
pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData); pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData);
} }
catch (WebException e) catch (WebException e)
@ -331,7 +348,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters); XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = (Hashtable)resp.Value;
return ConvertXMLRPCDataToUserProfile(respData); return ConvertXMLRPCDataToUserProfile(respData);
} }
@ -360,7 +377,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = (Hashtable)resp.Value;
return ConvertXMLRPCDataToUserProfile(respData); return ConvertXMLRPCDataToUserProfile(respData);
} }
@ -423,11 +440,11 @@ namespace OpenSim.Region.Communications.OGS1
{ {
throw new Exception("The method or operation is not implemented."); throw new Exception("The method or operation is not implemented.");
} }
public bool ResetUserPassword(string firstName, string lastName, string newPassword) public bool ResetUserPassword(string firstName, string lastName, string newPassword)
{ {
throw new Exception("The method or operation is not implemented."); throw new Exception("The method or operation is not implemented.");
} }
public bool UpdateUserProfile(UserProfileData userProfile) public bool UpdateUserProfile(UserProfileData userProfile)
{ {
@ -483,7 +500,7 @@ namespace OpenSim.Region.Communications.OGS1
m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
return false; return false;
} }
return true; return true;
} }
@ -659,7 +676,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = (Hashtable)resp.Value;
if (respData != null && respData.Contains("avcount")) if (respData != null && respData.Contains("avcount"))
{ {
@ -676,7 +693,7 @@ namespace OpenSim.Region.Communications.OGS1
return buddylist; return buddylist;
} }
public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
{ {
Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>(); Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>();
@ -697,10 +714,11 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(map); parameters.Add(map);
try { try
{
XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters); XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000);
Hashtable respData = resp != null ? (Hashtable) resp.Value : null; Hashtable respData = resp != null ? (Hashtable)resp.Value : null;
if (respData == null || respData.ContainsKey("faultMessage")) if (respData == null || respData.ContainsKey("faultMessage"))
{ {
@ -748,7 +766,7 @@ namespace OpenSim.Region.Communications.OGS1
{ {
m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message); m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message);
} }
m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count); m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count);
return result; return result;
} }
@ -769,7 +787,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters); XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = (Hashtable)resp.Value;
return ConvertXMLRPCDataToAvatarAppearance(respData); return ConvertXMLRPCDataToAvatarAppearance(respData);
} }
@ -792,7 +810,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param); parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters); XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = (Hashtable)resp.Value;
if (respData != null) if (respData != null)
{ {