Patch from mcortez: Update groups, add ALPHA Siman grid connector for groups

Signed-off-by: Melanie <melanie@t-data.com>
This commit is contained in:
Melanie
2010-05-05 16:12:52 +01:00
parent a9db266d93
commit 8187fccd25
5 changed files with 316 additions and 546 deletions

View File

@@ -55,9 +55,6 @@ using OpenSim.Services.Interfaces;
* UserID -> Group -> ActiveGroup
* + GroupID
*
* UserID -> GroupSessionDropped -> GroupID
* UserID -> GroupSessionInvited -> GroupID
*
* UserID -> GroupMember -> GroupID
* + SelectedRoleID [UUID]
* + AcceptNotices [bool]
@@ -66,7 +63,6 @@ using OpenSim.Services.Interfaces;
*
* UserID -> GroupRole[GroupID] -> RoleID
*
*
* GroupID -> Group -> GroupName
* + Charter
* + ShowInList
@@ -163,13 +159,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private bool m_connectorEnabled = false;
private string m_groupsServerURI = string.Empty;
private string m_serviceURL = string.Empty;
private bool m_debugEnabled = false;
private ExpiringCache<string, OSDMap> m_memoryCache;
private int m_cacheTimeout = 30;
// private IUserAccountService m_accountService = null;
@@ -206,33 +199,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return;
}
m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
if ((m_groupsServerURI == null) ||
(m_groupsServerURI == string.Empty))
m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty);
if ((m_serviceURL == null) ||
(m_serviceURL == string.Empty))
{
m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
m_log.ErrorFormat("Please specify a valid Simian Server URL for XmlRpcServiceURL in OpenSim.ini, [Groups]");
m_connectorEnabled = false;
return;
}
m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
if (m_cacheTimeout == 0)
{
m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled.");
}
else
{
m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout);
}
m_memoryCache = new ExpiringCache<string,OSDMap>();
// If we got all the config options we need, lets start'er'up
m_connectorEnabled = true;
@@ -243,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public void Close()
{
m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name);
m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name);
}
public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -311,8 +288,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap))
{
AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
@@ -436,7 +413,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
}
}
else if ((groupName != null) && (groupName != string.Empty))
{
{
if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
{
return null;
@@ -445,7 +422,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
GroupRecord GroupInfo = new GroupRecord();
GroupInfo.GroupID = groupID;
GroupInfo.GroupID = groupID;
GroupInfo.GroupName = groupName;
GroupInfo.Charter = GroupInfoMap["Charter"].AsString();
GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean();
@@ -676,7 +653,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
};
OSDMap response = CachedPostRequest(requestArgs);
OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
{
OSDArray entryArray = (OSDArray)response["Entries"];
@@ -774,9 +751,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
{
GroupID = UserActiveGroup["GroupID"].AsUUID();
}
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString());
}
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString());
return GetAgentGroupMembership(requestingAgentID, agentID, GroupID);
}
@@ -804,24 +781,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
List<GroupRolesData> Roles = new List<GroupRolesData>();
Dictionary<string, OSDMap> GroupRoles;
if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
{
Dictionary<string, OSDMap> MemberRoles;
if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles))
{
foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles)
{
GroupRolesData data = new GroupRolesData();
data.RoleID = UUID.Parse(kvp.Key);
data.Name = GroupRoles[kvp.Key]["Name"].AsString();
data.Description = GroupRoles[kvp.Key]["Description"].AsString();
data.Title = GroupRoles[kvp.Key]["Title"].AsString();
data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong();
Roles.Add(data);
}
}
Dictionary<string, OSDMap> GroupRoles;
if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
{
Dictionary<string, OSDMap> MemberRoles;
if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles))
{
foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles)
{
GroupRolesData data = new GroupRolesData();
data.RoleID = UUID.Parse(kvp.Key);
data.Name = GroupRoles[kvp.Key]["Name"].AsString();
data.Description = GroupRoles[kvp.Key]["Description"].AsString();
data.Title = GroupRoles[kvp.Key]["Title"].AsString();
data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong();
Roles.Add(data);
}
}
}
return Roles;
}
@@ -935,8 +912,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{
foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers )
{
GroupRoleMembersData data = new GroupRoleMembersData();
GroupRoleMembersData data = new GroupRoleMembersData();
data.MemberID = GroupRoleMember.Key;
data.RoleID = UUID.Parse(Role.Key);
@@ -1021,52 +998,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
}
#endregion
#region GroupSessionTracking
public void ResetAgentGroupChatSessions(UUID agentID)
{
Dictionary<string, OSDMap> agentSessions;
if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions))
{
foreach (string GroupID in agentSessions.Keys)
{
SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID);
}
}
if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions))
{
foreach (string GroupID in agentSessions.Keys)
{
SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID);
}
}
}
public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
{
OSDMap session;
return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
}
public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
{
SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap());
}
public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
{
SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap());
}
public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
{
OSDMap session;
return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
}
#endregion
private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
{
@@ -1105,7 +1036,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
};
OSDMap Response = CachedPostRequest(RequestArgs);
OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
if (Response["Success"].AsBoolean())
{
return true;
@@ -1132,23 +1063,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
};
OSDMap Response = CachedPostRequest(RequestArgs);
OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
{
OSDArray entryArray = (OSDArray)Response["Entries"];
if (entryArray.Count >= 1)
{
OSDMap entryMap = entryArray[0] as OSDMap;
key = entryMap["Key"].AsString();
map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
return true;
}
else
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
OSDArray entryArray = (OSDArray)Response["Entries"];
if (entryArray.Count >= 1)
{
OSDMap entryMap = entryArray[0] as OSDMap;
key = entryMap["Key"].AsString();
map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
return true;
}
else
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
}
else
@@ -1172,23 +1103,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
};
OSDMap Response = CachedPostRequest(RequestArgs);
OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
{
OSDArray entryArray = (OSDArray)Response["Entries"];
if (entryArray.Count >= 1)
{
OSDMap entryMap = entryArray[0] as OSDMap;
ownerID = entryMap["OwnerID"].AsUUID();
map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
return true;
}
else
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
OSDArray entryArray = (OSDArray)Response["Entries"];
if (entryArray.Count >= 1)
{
OSDMap entryMap = entryArray[0] as OSDMap;
ownerID = entryMap["OwnerID"].AsUUID();
map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
return true;
}
else
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
}
else
@@ -1213,7 +1144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
};
OSDMap Response = CachedPostRequest(RequestArgs);
OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
{
OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1221,16 +1152,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{
OSDMap entryMap = entryArray[0] as OSDMap;
key = entryMap["Key"].AsString();
map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
return true;
}
else
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
}
else
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
}
else
{
@@ -1253,20 +1184,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
OSDMap response = CachedPostRequest(requestArgs);
OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
{
maps = new Dictionary<string, OSDMap>();
OSDArray entryArray = (OSDArray)response["Entries"];
foreach (OSDMap entryMap in entryArray)
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
}
if(maps.Count == 0)
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
if(maps.Count == 0)
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
return true;
@@ -1291,21 +1222,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
OSDMap response = CachedPostRequest(requestArgs);
OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
{
maps = new Dictionary<UUID, OSDMap>();
OSDArray entryArray = (OSDArray)response["Entries"];
foreach (OSDMap entryMap in entryArray)
{
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
}
if (maps.Count == 0)
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
}
if (maps.Count == 0)
{
if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
}
return true;
}
else
@@ -1329,7 +1260,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
};
OSDMap response = CachedPostRequest(requestArgs);
OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
if (response["Success"].AsBoolean())
{
return true;
@@ -1341,49 +1272,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
}
}
#endregion
#region CheesyCache
OSDMap CachedPostRequest(NameValueCollection requestArgs)
{
// Immediately forward the request if the cache is disabled.
if (m_cacheTimeout == 0)
{
return WebUtil.PostToService(m_groupsServerURI, requestArgs);
}
// Check if this is an update or a request
if ( requestArgs["RequestMethod"] == "RemoveGeneric"
|| requestArgs["RequestMethod"] == "AddGeneric"
)
{
// Any and all updates cause the cache to clear
m_memoryCache.Clear();
// Send update to server, return the response without caching it
return WebUtil.PostToService(m_groupsServerURI, requestArgs);
}
// If we're not doing an update, we must be requesting data
// Create the cache key for the request and see if we have it cached
string CacheKey = WebUtil.BuildQueryString(requestArgs);
OSDMap response = null;
if (!m_memoryCache.TryGetValue(CacheKey, out response))
{
// if it wasn't in the cache, pass the request to the Simian Grid Services
response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
// and cache the response
m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
}
// return cached response
return response;
}
#endregion
}
}