* Allow plugins to play nicely in UserManagerBase

* Some methods were returning the value of the first plugin queried, even if the return was null
* Other methods are probably best off querying more than one plugin and aggregating results
0.6.5-rc1
Justin Clarke Casey 2009-04-22 19:26:18 +00:00
parent e0160e5640
commit 4c80685563
2 changed files with 26 additions and 24 deletions

View File

@ -64,7 +64,7 @@ namespace OpenSim.Data
/// </summary> /// </summary>
/// <param name="queryID">ID associated with the user's query. This must match what the client sent</param> /// <param name="queryID">ID associated with the user's query. This must match what the client sent</param>
/// <param name="query">The filtered contents of the search box when the user hit search.</param> /// <param name="query">The filtered contents of the search box when the user hit search.</param>
/// <returns>The user data profile</returns> /// <returns>A list of user details. If there are no results than either an empty list or null can be returned</returns>
List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query); List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query);
/// <summary> /// <summary>

View File

@ -174,44 +174,46 @@ namespace OpenSim.Framework.Communications
public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
{ {
List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); List<AvatarPickerAvatar> allPickerList = new List<AvatarPickerAvatar>();
foreach (IUserDataPlugin plugin in m_plugins) foreach (IUserDataPlugin plugin in m_plugins)
{ {
try try
{ {
pickerlist = plugin.GeneratePickerResults(queryID, query); List<AvatarPickerAvatar> pickerList = plugin.GeneratePickerResults(queryID, query);
if (pickerList != null)
allPickerList.AddRange(pickerList);
} }
catch (Exception) catch (Exception)
{ {
m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); m_log.Error(
return new List<AvatarPickerAvatar>(); "[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")");
} }
} }
return pickerlist; return allPickerList;
} }
/// <summary>
/// Updates a user profile from data object
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public virtual bool UpdateUserProfile(UserProfileData data) public virtual bool UpdateUserProfile(UserProfileData data)
{ {
bool result = false;
foreach (IUserDataPlugin plugin in m_plugins) foreach (IUserDataPlugin plugin in m_plugins)
{ {
try try
{ {
plugin.UpdateUserProfile(data); plugin.UpdateUserProfile(data);
return true; result = true;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, m_log.InfoFormat(
plugin.Name, e.ToString()); "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}",
data.FirstName, data.SurName, plugin.Name, e.ToString());
} }
} }
return false;
return result;
} }
#endregion #endregion
@ -232,10 +234,8 @@ namespace OpenSim.Framework.Communications
UserAgentData result = plugin.GetAgentByUUID(uuid); UserAgentData result = plugin.GetAgentByUUID(uuid);
if (result != null) if (result != null)
{
return result; return result;
} }
}
catch (Exception e) catch (Exception e)
{ {
m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")");
@ -256,7 +256,10 @@ namespace OpenSim.Framework.Communications
{ {
try try
{ {
return plugin.GetAgentByName(name); UserAgentData result = plugin.GetAgentByName(name);
if (result != null)
return result;
} }
catch (Exception e) catch (Exception e)
{ {
@ -279,7 +282,10 @@ namespace OpenSim.Framework.Communications
{ {
try try
{ {
return plugin.GetAgentByName(fname, lname); UserAgentData result = plugin.GetAgentByName(fname, lname);
if (result != null)
return result;
} }
catch (Exception e) catch (Exception e)
{ {
@ -304,10 +310,8 @@ namespace OpenSim.Framework.Communications
List<FriendListItem> result = plugin.GetUserFriendList(ownerID); List<FriendListItem> result = plugin.GetUserFriendList(ownerID);
if (result != null) if (result != null)
{
return result; return result;
} }
}
catch (Exception e) catch (Exception e)
{ {
m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")");
@ -326,10 +330,8 @@ namespace OpenSim.Framework.Communications
Dictionary<UUID, FriendRegionInfo> result = plugin.GetFriendRegionInfos(uuids); Dictionary<UUID, FriendRegionInfo> result = plugin.GetFriendRegionInfos(uuids);
if (result != null) if (result != null)
{
return result; return result;
} }
}
catch (Exception e) catch (Exception e)
{ {
m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")");