diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | 292 |
1 files changed, 90 insertions, 202 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 9363205..590753e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -55,9 +55,6 @@ using OpenSim.Services.Interfaces; | |||
55 | * UserID -> Group -> ActiveGroup | 55 | * UserID -> Group -> ActiveGroup |
56 | * + GroupID | 56 | * + GroupID |
57 | * | 57 | * |
58 | * UserID -> GroupSessionDropped -> GroupID | ||
59 | * UserID -> GroupSessionInvited -> GroupID | ||
60 | * | ||
61 | * UserID -> GroupMember -> GroupID | 58 | * UserID -> GroupMember -> GroupID |
62 | * + SelectedRoleID [UUID] | 59 | * + SelectedRoleID [UUID] |
63 | * + AcceptNotices [bool] | 60 | * + AcceptNotices [bool] |
@@ -66,7 +63,6 @@ using OpenSim.Services.Interfaces; | |||
66 | * | 63 | * |
67 | * UserID -> GroupRole[GroupID] -> RoleID | 64 | * UserID -> GroupRole[GroupID] -> RoleID |
68 | * | 65 | * |
69 | * | ||
70 | * GroupID -> Group -> GroupName | 66 | * GroupID -> Group -> GroupName |
71 | * + Charter | 67 | * + Charter |
72 | * + ShowInList | 68 | * + ShowInList |
@@ -163,13 +159,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
163 | 159 | ||
164 | private bool m_connectorEnabled = false; | 160 | private bool m_connectorEnabled = false; |
165 | 161 | ||
166 | private string m_groupsServerURI = string.Empty; | 162 | private string m_serviceURL = string.Empty; |
167 | 163 | ||
168 | private bool m_debugEnabled = false; | 164 | private bool m_debugEnabled = false; |
169 | 165 | ||
170 | private ExpiringCache<string, OSDMap> m_memoryCache; | ||
171 | private int m_cacheTimeout = 30; | ||
172 | |||
173 | // private IUserAccountService m_accountService = null; | 166 | // private IUserAccountService m_accountService = null; |
174 | 167 | ||
175 | 168 | ||
@@ -206,33 +199,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
206 | return; | 199 | return; |
207 | } | 200 | } |
208 | 201 | ||
209 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name); | 202 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); |
210 | 203 | ||
211 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); | 204 | m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); |
212 | if ((m_groupsServerURI == null) || | 205 | if ((m_serviceURL == null) || |
213 | (m_groupsServerURI == string.Empty)) | 206 | (m_serviceURL == string.Empty)) |
214 | { | 207 | { |
215 | m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); | 208 | m_log.ErrorFormat("Please specify a valid Simian Server URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); |
216 | m_connectorEnabled = false; | 209 | m_connectorEnabled = false; |
217 | return; | 210 | return; |
218 | } | 211 | } |
219 | 212 | ||
220 | |||
221 | m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30); | ||
222 | if (m_cacheTimeout == 0) | ||
223 | { | ||
224 | m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled."); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout); | ||
229 | } | ||
230 | |||
231 | |||
232 | |||
233 | m_memoryCache = new ExpiringCache<string,OSDMap>(); | ||
234 | |||
235 | |||
236 | // If we got all the config options we need, lets start'er'up | 213 | // If we got all the config options we need, lets start'er'up |
237 | m_connectorEnabled = true; | 214 | m_connectorEnabled = true; |
238 | 215 | ||
@@ -243,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
243 | 220 | ||
244 | public void Close() | 221 | public void Close() |
245 | { | 222 | { |
246 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name); | 223 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); |
247 | } | 224 | } |
248 | 225 | ||
249 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) | 226 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) |
@@ -311,8 +288,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
311 | 288 | ||
312 | if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap)) | 289 | if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap)) |
313 | { | 290 | { |
314 | AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers); | 291 | AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers); |
315 | AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers); | 292 | AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers); |
316 | 293 | ||
317 | AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID); | 294 | AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID); |
318 | 295 | ||
@@ -436,7 +413,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
436 | } | 413 | } |
437 | } | 414 | } |
438 | else if ((groupName != null) && (groupName != string.Empty)) | 415 | else if ((groupName != null) && (groupName != string.Empty)) |
439 | { | 416 | { |
440 | if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) | 417 | if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) |
441 | { | 418 | { |
442 | return null; | 419 | return null; |
@@ -445,7 +422,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
445 | 422 | ||
446 | GroupRecord GroupInfo = new GroupRecord(); | 423 | GroupRecord GroupInfo = new GroupRecord(); |
447 | 424 | ||
448 | GroupInfo.GroupID = groupID; | 425 | GroupInfo.GroupID = groupID; |
449 | GroupInfo.GroupName = groupName; | 426 | GroupInfo.GroupName = groupName; |
450 | GroupInfo.Charter = GroupInfoMap["Charter"].AsString(); | 427 | GroupInfo.Charter = GroupInfoMap["Charter"].AsString(); |
451 | GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean(); | 428 | GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean(); |
@@ -676,7 +653,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
676 | }; | 653 | }; |
677 | 654 | ||
678 | 655 | ||
679 | OSDMap response = CachedPostRequest(requestArgs); | 656 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); |
680 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 657 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
681 | { | 658 | { |
682 | OSDArray entryArray = (OSDArray)response["Entries"]; | 659 | OSDArray entryArray = (OSDArray)response["Entries"]; |
@@ -774,9 +751,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
774 | if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) | 751 | if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) |
775 | { | 752 | { |
776 | GroupID = UserActiveGroup["GroupID"].AsUUID(); | 753 | GroupID = UserActiveGroup["GroupID"].AsUUID(); |
777 | } | 754 | } |
778 | 755 | ||
779 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString()); | 756 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString()); |
780 | return GetAgentGroupMembership(requestingAgentID, agentID, GroupID); | 757 | return GetAgentGroupMembership(requestingAgentID, agentID, GroupID); |
781 | } | 758 | } |
782 | 759 | ||
@@ -804,24 +781,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
804 | 781 | ||
805 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | 782 | List<GroupRolesData> Roles = new List<GroupRolesData>(); |
806 | 783 | ||
807 | Dictionary<string, OSDMap> GroupRoles; | 784 | Dictionary<string, OSDMap> GroupRoles; |
808 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | 785 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) |
809 | { | 786 | { |
810 | Dictionary<string, OSDMap> MemberRoles; | 787 | Dictionary<string, OSDMap> MemberRoles; |
811 | if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles)) | 788 | if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles)) |
812 | { | 789 | { |
813 | foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles) | 790 | foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles) |
814 | { | 791 | { |
815 | GroupRolesData data = new GroupRolesData(); | 792 | GroupRolesData data = new GroupRolesData(); |
816 | data.RoleID = UUID.Parse(kvp.Key); | 793 | data.RoleID = UUID.Parse(kvp.Key); |
817 | data.Name = GroupRoles[kvp.Key]["Name"].AsString(); | 794 | data.Name = GroupRoles[kvp.Key]["Name"].AsString(); |
818 | data.Description = GroupRoles[kvp.Key]["Description"].AsString(); | 795 | data.Description = GroupRoles[kvp.Key]["Description"].AsString(); |
819 | data.Title = GroupRoles[kvp.Key]["Title"].AsString(); | 796 | data.Title = GroupRoles[kvp.Key]["Title"].AsString(); |
820 | data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong(); | 797 | data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong(); |
821 | 798 | ||
822 | Roles.Add(data); | 799 | Roles.Add(data); |
823 | } | 800 | } |
824 | } | 801 | } |
825 | } | 802 | } |
826 | return Roles; | 803 | return Roles; |
827 | } | 804 | } |
@@ -935,8 +912,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
935 | { | 912 | { |
936 | foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers ) | 913 | foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers ) |
937 | { | 914 | { |
938 | GroupRoleMembersData data = new GroupRoleMembersData(); | 915 | GroupRoleMembersData data = new GroupRoleMembersData(); |
939 | 916 | ||
940 | data.MemberID = GroupRoleMember.Key; | 917 | data.MemberID = GroupRoleMember.Key; |
941 | data.RoleID = UUID.Parse(Role.Key); | 918 | data.RoleID = UUID.Parse(Role.Key); |
942 | 919 | ||
@@ -1021,52 +998,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1021 | } | 998 | } |
1022 | #endregion | 999 | #endregion |
1023 | 1000 | ||
1024 | #region GroupSessionTracking | ||
1025 | |||
1026 | public void ResetAgentGroupChatSessions(UUID agentID) | ||
1027 | { | ||
1028 | Dictionary<string, OSDMap> agentSessions; | ||
1029 | |||
1030 | if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions)) | ||
1031 | { | ||
1032 | foreach (string GroupID in agentSessions.Keys) | ||
1033 | { | ||
1034 | SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID); | ||
1035 | } | ||
1036 | } | ||
1037 | |||
1038 | if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions)) | ||
1039 | { | ||
1040 | foreach (string GroupID in agentSessions.Keys) | ||
1041 | { | ||
1042 | SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID); | ||
1043 | } | ||
1044 | } | ||
1045 | } | ||
1046 | |||
1047 | public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) | ||
1048 | { | ||
1049 | OSDMap session; | ||
1050 | return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); | ||
1051 | } | ||
1052 | |||
1053 | public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) | ||
1054 | { | ||
1055 | SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap()); | ||
1056 | } | ||
1057 | |||
1058 | public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) | ||
1059 | { | ||
1060 | SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap()); | ||
1061 | } | ||
1062 | |||
1063 | public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) | ||
1064 | { | ||
1065 | OSDMap session; | ||
1066 | return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); | ||
1067 | } | ||
1068 | |||
1069 | #endregion | ||
1070 | 1001 | ||
1071 | private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) | 1002 | private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) |
1072 | { | 1003 | { |
@@ -1105,7 +1036,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1105 | }; | 1036 | }; |
1106 | 1037 | ||
1107 | 1038 | ||
1108 | OSDMap Response = CachedPostRequest(RequestArgs); | 1039 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); |
1109 | if (Response["Success"].AsBoolean()) | 1040 | if (Response["Success"].AsBoolean()) |
1110 | { | 1041 | { |
1111 | return true; | 1042 | return true; |
@@ -1132,23 +1063,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1132 | }; | 1063 | }; |
1133 | 1064 | ||
1134 | 1065 | ||
1135 | OSDMap Response = CachedPostRequest(RequestArgs); | 1066 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); |
1136 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | 1067 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) |
1137 | { | 1068 | { |
1138 | OSDArray entryArray = (OSDArray)Response["Entries"]; | 1069 | OSDArray entryArray = (OSDArray)Response["Entries"]; |
1139 | if (entryArray.Count >= 1) | 1070 | if (entryArray.Count >= 1) |
1140 | { | 1071 | { |
1141 | OSDMap entryMap = entryArray[0] as OSDMap; | 1072 | OSDMap entryMap = entryArray[0] as OSDMap; |
1142 | key = entryMap["Key"].AsString(); | 1073 | key = entryMap["Key"].AsString(); |
1143 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | 1074 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); |
1144 | 1075 | ||
1145 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | 1076 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); |
1146 | 1077 | ||
1147 | return true; | 1078 | return true; |
1148 | } | 1079 | } |
1149 | else | 1080 | else |
1150 | { | 1081 | { |
1151 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | 1082 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); |
1152 | } | 1083 | } |
1153 | } | 1084 | } |
1154 | else | 1085 | else |
@@ -1172,23 +1103,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1172 | }; | 1103 | }; |
1173 | 1104 | ||
1174 | 1105 | ||
1175 | OSDMap Response = CachedPostRequest(RequestArgs); | 1106 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); |
1176 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | 1107 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) |
1177 | { | 1108 | { |
1178 | OSDArray entryArray = (OSDArray)Response["Entries"]; | 1109 | OSDArray entryArray = (OSDArray)Response["Entries"]; |
1179 | if (entryArray.Count >= 1) | 1110 | if (entryArray.Count >= 1) |
1180 | { | 1111 | { |
1181 | OSDMap entryMap = entryArray[0] as OSDMap; | 1112 | OSDMap entryMap = entryArray[0] as OSDMap; |
1182 | ownerID = entryMap["OwnerID"].AsUUID(); | 1113 | ownerID = entryMap["OwnerID"].AsUUID(); |
1183 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | 1114 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); |
1184 | 1115 | ||
1185 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | 1116 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); |
1186 | 1117 | ||
1187 | return true; | 1118 | return true; |
1188 | } | 1119 | } |
1189 | else | 1120 | else |
1190 | { | 1121 | { |
1191 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | 1122 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); |
1192 | } | 1123 | } |
1193 | } | 1124 | } |
1194 | else | 1125 | else |
@@ -1213,7 +1144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1213 | }; | 1144 | }; |
1214 | 1145 | ||
1215 | 1146 | ||
1216 | OSDMap Response = CachedPostRequest(RequestArgs); | 1147 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); |
1217 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | 1148 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) |
1218 | { | 1149 | { |
1219 | OSDArray entryArray = (OSDArray)Response["Entries"]; | 1150 | OSDArray entryArray = (OSDArray)Response["Entries"]; |
@@ -1221,16 +1152,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1221 | { | 1152 | { |
1222 | OSDMap entryMap = entryArray[0] as OSDMap; | 1153 | OSDMap entryMap = entryArray[0] as OSDMap; |
1223 | key = entryMap["Key"].AsString(); | 1154 | key = entryMap["Key"].AsString(); |
1224 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | 1155 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); |
1225 | 1156 | ||
1226 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | 1157 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); |
1227 | 1158 | ||
1228 | return true; | 1159 | return true; |
1229 | } | 1160 | } |
1230 | else | 1161 | else |
1231 | { | 1162 | { |
1232 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | 1163 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); |
1233 | } | 1164 | } |
1234 | } | 1165 | } |
1235 | else | 1166 | else |
1236 | { | 1167 | { |
@@ -1253,20 +1184,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1253 | 1184 | ||
1254 | 1185 | ||
1255 | 1186 | ||
1256 | OSDMap response = CachedPostRequest(requestArgs); | 1187 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); |
1257 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 1188 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
1258 | { | 1189 | { |
1259 | maps = new Dictionary<string, OSDMap>(); | 1190 | maps = new Dictionary<string, OSDMap>(); |
1260 | 1191 | ||
1261 | OSDArray entryArray = (OSDArray)response["Entries"]; | 1192 | OSDArray entryArray = (OSDArray)response["Entries"]; |
1262 | foreach (OSDMap entryMap in entryArray) | 1193 | foreach (OSDMap entryMap in entryArray) |
1263 | { | 1194 | { |
1264 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | 1195 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); |
1265 | maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); | 1196 | maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); |
1266 | } | 1197 | } |
1267 | if(maps.Count == 0) | 1198 | if(maps.Count == 0) |
1268 | { | 1199 | { |
1269 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | 1200 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); |
1270 | } | 1201 | } |
1271 | 1202 | ||
1272 | return true; | 1203 | return true; |
@@ -1291,21 +1222,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1291 | 1222 | ||
1292 | 1223 | ||
1293 | 1224 | ||
1294 | OSDMap response = CachedPostRequest(requestArgs); | 1225 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); |
1295 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 1226 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
1296 | { | 1227 | { |
1297 | maps = new Dictionary<UUID, OSDMap>(); | 1228 | maps = new Dictionary<UUID, OSDMap>(); |
1298 | 1229 | ||
1299 | OSDArray entryArray = (OSDArray)response["Entries"]; | 1230 | OSDArray entryArray = (OSDArray)response["Entries"]; |
1300 | foreach (OSDMap entryMap in entryArray) | 1231 | foreach (OSDMap entryMap in entryArray) |
1301 | { | 1232 | { |
1302 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | 1233 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); |
1303 | maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); | 1234 | maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); |
1304 | } | 1235 | } |
1305 | if (maps.Count == 0) | 1236 | if (maps.Count == 0) |
1306 | { | 1237 | { |
1307 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | 1238 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); |
1308 | } | 1239 | } |
1309 | return true; | 1240 | return true; |
1310 | } | 1241 | } |
1311 | else | 1242 | else |
@@ -1329,7 +1260,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1329 | }; | 1260 | }; |
1330 | 1261 | ||
1331 | 1262 | ||
1332 | OSDMap response = CachedPostRequest(requestArgs); | 1263 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); |
1333 | if (response["Success"].AsBoolean()) | 1264 | if (response["Success"].AsBoolean()) |
1334 | { | 1265 | { |
1335 | return true; | 1266 | return true; |
@@ -1341,49 +1272,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1341 | } | 1272 | } |
1342 | } | 1273 | } |
1343 | #endregion | 1274 | #endregion |
1344 | |||
1345 | #region CheesyCache | ||
1346 | OSDMap CachedPostRequest(NameValueCollection requestArgs) | ||
1347 | { | ||
1348 | // Immediately forward the request if the cache is disabled. | ||
1349 | if (m_cacheTimeout == 0) | ||
1350 | { | ||
1351 | return WebUtil.PostToService(m_groupsServerURI, requestArgs); | ||
1352 | } | ||
1353 | |||
1354 | // Check if this is an update or a request | ||
1355 | if ( requestArgs["RequestMethod"] == "RemoveGeneric" | ||
1356 | || requestArgs["RequestMethod"] == "AddGeneric" | ||
1357 | ) | ||
1358 | |||
1359 | { | ||
1360 | // Any and all updates cause the cache to clear | ||
1361 | m_memoryCache.Clear(); | ||
1362 | |||
1363 | // Send update to server, return the response without caching it | ||
1364 | return WebUtil.PostToService(m_groupsServerURI, requestArgs); | ||
1365 | |||
1366 | } | ||
1367 | |||
1368 | // If we're not doing an update, we must be requesting data | ||
1369 | |||
1370 | // Create the cache key for the request and see if we have it cached | ||
1371 | string CacheKey = WebUtil.BuildQueryString(requestArgs); | ||
1372 | OSDMap response = null; | ||
1373 | if (!m_memoryCache.TryGetValue(CacheKey, out response)) | ||
1374 | { | ||
1375 | // if it wasn't in the cache, pass the request to the Simian Grid Services | ||
1376 | response = WebUtil.PostToService(m_groupsServerURI, requestArgs); | ||
1377 | |||
1378 | // and cache the response | ||
1379 | m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout)); | ||
1380 | } | ||
1381 | |||
1382 | // return cached response | ||
1383 | return response; | ||
1384 | } | ||
1385 | #endregion | ||
1386 | |||
1387 | } | 1275 | } |
1388 | 1276 | ||
1389 | } | 1277 | } |