29 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Server.Base;
40 namespace OpenSim.Groups
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private string m_ServerURI;
47 private object m_Lock =
new object();
52 if (!m_ServerURI.EndsWith(
"/"))
55 m_log.DebugFormat(
"[Groups.HGConnector]: Groups server at {0}", m_ServerURI);
58 public bool CreateProxy(
string RequestingAgentID,
string AgentID,
string accessToken, UUID groupID,
string url,
string name, out
string reason)
60 reason = string.Empty;
62 Dictionary<string, object> sendData =
new Dictionary<string,object>();
63 sendData[
"RequestingAgentID"] = RequestingAgentID;
64 sendData[
"AgentID"] = AgentID.ToString();
65 sendData[
"AccessToken"] = accessToken;
66 sendData[
"GroupID"] = groupID.ToString();
67 sendData[
"Location"] = url;
68 sendData[
"Name"] = name;
69 Dictionary<string, object> ret = MakeRequest(
"POSTGROUP", sendData);
74 if (!ret.ContainsKey(
"RESULT"))
77 if (ret[
"RESULT"].ToString().ToLower() !=
"true")
79 reason = ret[
"REASON"].ToString();
89 Dictionary<string, object> sendData =
new Dictionary<string, object>();
90 sendData[
"AgentID"] = AgentID;
91 sendData[
"GroupID"] = GroupID.ToString();
92 sendData[
"AccessToken"] = GroupsDataUtils.Sanitize(token);
93 MakeRequest(
"REMOVEAGENTFROMGROUP", sendData);
98 if (GroupID == UUID.Zero && (GroupName == null || (GroupName != null && GroupName ==
string.Empty)))
101 Dictionary<string, object> sendData =
new Dictionary<string, object>();
102 if (GroupID != UUID.Zero)
103 sendData[
"GroupID"] = GroupID.ToString();
104 if (!
string.IsNullOrEmpty(GroupName))
107 sendData[
"RequestingAgentID"] = RequestingAgentID;
108 sendData[
"AccessToken"] = GroupsDataUtils.Sanitize(token);
110 Dictionary<string, object> ret = MakeRequest(
"GETGROUP", sendData);
115 if (!ret.ContainsKey(
"RESULT"))
118 if (ret[
"RESULT"].ToString() ==
"NULL")
121 return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret[
"RESULT"]);
124 public List<ExtendedGroupMembersData>
GetGroupMembers(
string RequestingAgentID, UUID GroupID,
string token)
126 List<ExtendedGroupMembersData> members =
new List<ExtendedGroupMembersData>();
128 Dictionary<string, object> sendData =
new Dictionary<string, object>();
129 sendData[
"GroupID"] = GroupID.ToString();
130 sendData[
"RequestingAgentID"] = RequestingAgentID;
131 sendData[
"AccessToken"] = GroupsDataUtils.Sanitize(token);
132 Dictionary<string, object> ret = MakeRequest(
"GETGROUPMEMBERS", sendData);
137 if (!ret.ContainsKey(
"RESULT"))
140 if (ret[
"RESULT"].ToString() ==
"NULL")
142 foreach (
object v
in ((Dictionary<string, object>)ret[
"RESULT"]).Values)
151 public List<GroupRolesData>
GetGroupRoles(
string RequestingAgentID, UUID GroupID,
string token)
153 List<GroupRolesData> roles =
new List<GroupRolesData>();
155 Dictionary<string, object> sendData =
new Dictionary<string, object>();
156 sendData[
"GroupID"] = GroupID.ToString();
157 sendData[
"RequestingAgentID"] = RequestingAgentID;
158 sendData[
"AccessToken"] = GroupsDataUtils.Sanitize(token);
159 Dictionary<string, object> ret = MakeRequest(
"GETGROUPROLES", sendData);
164 if (!ret.ContainsKey(
"RESULT"))
167 if (ret[
"RESULT"].ToString() ==
"NULL")
169 foreach (
object v
in ((Dictionary<string, object>)ret[
"RESULT"]).Values)
171 GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary<string, object>)v);
178 public List<ExtendedGroupRoleMembersData>
GetGroupRoleMembers(
string RequestingAgentID, UUID GroupID,
string token)
180 List<ExtendedGroupRoleMembersData> rmembers =
new List<ExtendedGroupRoleMembersData>();
182 Dictionary<string, object> sendData =
new Dictionary<string, object>();
183 sendData[
"GroupID"] = GroupID.ToString();
184 sendData[
"RequestingAgentID"] = RequestingAgentID;
185 sendData[
"AccessToken"] = GroupsDataUtils.Sanitize(token);
186 Dictionary<string, object> ret = MakeRequest(
"GETROLEMEMBERS", sendData);
191 if (!ret.ContainsKey(
"RESULT"))
194 if (ret[
"RESULT"].ToString() ==
"NULL")
197 foreach (
object v
in ((Dictionary<string, object>)ret[
"RESULT"]).Values)
206 public bool AddNotice(
string RequestingAgentID, UUID groupID, UUID noticeID,
string fromName,
string subject,
string message,
207 bool hasAttachment, byte attType,
string attName, UUID attItemID,
string attOwnerID)
209 Dictionary<string, object> sendData =
new Dictionary<string, object>();
210 sendData[
"GroupID"] = groupID.ToString();
211 sendData[
"NoticeID"] = noticeID.ToString();
212 sendData[
"FromName"] = GroupsDataUtils.Sanitize(fromName);
213 sendData[
"Subject"] = GroupsDataUtils.Sanitize(subject);
214 sendData[
"Message"] = GroupsDataUtils.Sanitize(message);
215 sendData[
"HasAttachment"] = hasAttachment.ToString();
218 sendData[
"AttachmentType"] = attType.ToString();
219 sendData[
"AttachmentName"] = attName.ToString();
220 sendData[
"AttachmentItemID"] = attItemID.ToString();
221 sendData[
"AttachmentOwnerID"] = attOwnerID;
223 sendData[
"RequestingAgentID"] = RequestingAgentID;
225 Dictionary<string, object> ret = MakeRequest(
"ADDNOTICE", sendData);
230 if (!ret.ContainsKey(
"RESULT"))
233 if (ret[
"RESULT"].ToString().ToLower() !=
"true")
241 Dictionary<string, object> sendData =
new Dictionary<string, object>();
242 sendData[
"NoticeID"] = noticeID.ToString();
243 sendData[
"GroupID"] = groupID.ToString();
244 Dictionary<string, object> ret = MakeRequest(
"VERIFYNOTICE", sendData);
249 if (!ret.ContainsKey(
"RESULT"))
252 if (ret[
"RESULT"].ToString().ToLower() !=
"true")
266 private Dictionary<string, object> MakeRequest(
string method, Dictionary<string, object> sendData)
268 sendData[
"METHOD"] = method;
270 string reply = string.Empty;
272 reply = SynchronousRestFormsRequester.MakeRequest("POST",
273 m_ServerURI + "hg-groups",
274 ServerUtils.BuildQueryString(sendData));
278 if (
string.IsNullOrEmpty(reply))
281 Dictionary<
string,
object> replyData = ServerUtils.ParseXmlResponse(
List< ExtendedGroupMembersData > GetGroupMembers(string RequestingAgentID, UUID GroupID, string token)
ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName, string token)
List< GroupRolesData > GetGroupRoles(string RequestingAgentID, UUID GroupID, string token)
bool AddNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
GroupsServiceHGConnector(string url)
static string Sanitize(string s)
List< ExtendedGroupRoleMembersData > GetGroupRoleMembers(string RequestingAgentID, UUID GroupID, string token)
bool VerifyNotice(UUID noticeID, UUID groupID)
void RemoveAgentFromGroup(string AgentID, UUID GroupID, string token)
bool CreateProxy(string RequestingAgentID, string AgentID, string accessToken, UUID groupID, string url, string name, out string reason)