XmlRpcGroupsServicesConnectorModule.cs 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Reflection;
  31. using System.Text;
  32. using Nwc.XmlRpc;
  33. using log4net;
  34. using Mono.Addins;
  35. using Nini.Config;
  36. using OpenMetaverse;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Services.Interfaces;
  41. namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
  42. {
  43. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGroupsServicesConnectorModule")]
  44. public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
  45. {
  46. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  47. private bool m_debugEnabled = false;
  48. public const GroupPowers DefaultEveryonePowers
  49. = GroupPowers.AllowSetHome
  50. | GroupPowers.Accountable
  51. | GroupPowers.JoinChat
  52. | GroupPowers.AllowVoiceChat
  53. | GroupPowers.ReceiveNotices
  54. | GroupPowers.StartProposal
  55. | GroupPowers.VoteOnProposal;
  56. // Would this be cleaner as (GroupPowers)ulong.MaxValue?
  57. public const GroupPowers DefaultOwnerPowers
  58. = GroupPowers.Accountable
  59. | GroupPowers.AllowEditLand
  60. | GroupPowers.AllowFly
  61. | GroupPowers.AllowLandmark
  62. | GroupPowers.AllowRez
  63. | GroupPowers.AllowSetHome
  64. | GroupPowers.AllowVoiceChat
  65. | GroupPowers.AssignMember
  66. | GroupPowers.AssignMemberLimited
  67. | GroupPowers.ChangeActions
  68. | GroupPowers.ChangeIdentity
  69. | GroupPowers.ChangeMedia
  70. | GroupPowers.ChangeOptions
  71. | GroupPowers.CreateRole
  72. | GroupPowers.DeedObject
  73. | GroupPowers.DeleteRole
  74. | GroupPowers.Eject
  75. | GroupPowers.FindPlaces
  76. | GroupPowers.Invite
  77. | GroupPowers.JoinChat
  78. | GroupPowers.LandChangeIdentity
  79. | GroupPowers.LandDeed
  80. | GroupPowers.LandDivideJoin
  81. | GroupPowers.LandEdit
  82. | GroupPowers.LandEjectAndFreeze
  83. | GroupPowers.LandGardening
  84. | GroupPowers.LandManageAllowed
  85. | GroupPowers.LandManageBanned
  86. | GroupPowers.LandManagePasses
  87. | GroupPowers.LandOptions
  88. | GroupPowers.LandRelease
  89. | GroupPowers.LandSetSale
  90. | GroupPowers.ModerateChat
  91. | GroupPowers.ObjectManipulate
  92. | GroupPowers.ObjectSetForSale
  93. | GroupPowers.ReceiveNotices
  94. | GroupPowers.RemoveMember
  95. | GroupPowers.ReturnGroupOwned
  96. | GroupPowers.ReturnGroupSet
  97. | GroupPowers.ReturnNonGroup
  98. | GroupPowers.RoleProperties
  99. | GroupPowers.SendNotices
  100. | GroupPowers.SetLandingPoint
  101. | GroupPowers.StartProposal
  102. | GroupPowers.VoteOnProposal;
  103. private bool m_connectorEnabled = false;
  104. private string m_groupsServerURI = string.Empty;
  105. private bool m_disableKeepAlive = false;
  106. private string m_groupReadKey = string.Empty;
  107. private string m_groupWriteKey = string.Empty;
  108. private IUserAccountService m_accountService = null;
  109. private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
  110. private int m_cacheTimeout = 30;
  111. // Used to track which agents are have dropped from a group chat session
  112. // Should be reset per agent, on logon
  113. // TODO: move this to Flotsam XmlRpc Service
  114. // SessionID, List<AgentID>
  115. private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
  116. private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
  117. #region Region Module interfaceBase Members
  118. public string Name
  119. {
  120. get { return "XmlRpcGroupsServicesConnector"; }
  121. }
  122. // this module is not intended to be replaced, but there should only be 1 of them.
  123. public Type ReplaceableInterface
  124. {
  125. get { return null; }
  126. }
  127. public void Initialise(IConfigSource config)
  128. {
  129. IConfig groupsConfig = config.Configs["Groups"];
  130. if (groupsConfig == null)
  131. {
  132. // Do not run this module by default.
  133. return;
  134. }
  135. else
  136. {
  137. // if groups aren't enabled, we're not needed.
  138. // if we're not specified as the connector to use, then we're not wanted
  139. if ((groupsConfig.GetBoolean("Enabled", false) == false)
  140. || (groupsConfig.GetString("ServicesConnectorModule", "XmlRpcGroupsServicesConnector") != Name))
  141. {
  142. m_connectorEnabled = false;
  143. return;
  144. }
  145. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
  146. m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
  147. if (string.IsNullOrEmpty(m_groupsServerURI))
  148. {
  149. m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
  150. m_connectorEnabled = false;
  151. return;
  152. }
  153. m_disableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false);
  154. m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
  155. m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
  156. m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
  157. if (m_cacheTimeout == 0)
  158. {
  159. m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
  160. }
  161. else
  162. {
  163. m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
  164. }
  165. m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", false);
  166. // If we got all the config options we need, lets start'er'up
  167. m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
  168. m_connectorEnabled = true;
  169. }
  170. }
  171. public void Close()
  172. {
  173. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
  174. }
  175. public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
  176. {
  177. if (m_connectorEnabled)
  178. {
  179. if (m_accountService == null)
  180. {
  181. m_accountService = scene.UserAccountService;
  182. }
  183. scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
  184. }
  185. }
  186. public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
  187. {
  188. if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
  189. {
  190. scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
  191. }
  192. }
  193. public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
  194. {
  195. // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
  196. // scene.EventManager.OnNewClient += OnNewClient;
  197. }
  198. #endregion
  199. #region ISharedRegionModule Members
  200. public void PostInitialise()
  201. {
  202. // NoOp
  203. }
  204. #endregion
  205. #region IGroupsServicesConnector Members
  206. /// <summary>
  207. /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role.
  208. /// </summary>
  209. public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
  210. int membershipFee, bool openEnrollment, bool allowPublish,
  211. bool maturePublish, UUID founderID)
  212. {
  213. UUID GroupID = UUID.Random();
  214. UUID OwnerRoleID = UUID.Random();
  215. Hashtable param = new Hashtable();
  216. param["GroupID"] = GroupID.ToString();
  217. param["Name"] = name;
  218. param["Charter"] = charter;
  219. param["ShowInList"] = showInList == true ? 1 : 0;
  220. param["InsigniaID"] = insigniaID.ToString();
  221. param["MembershipFee"] = membershipFee;
  222. param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
  223. param["AllowPublish"] = allowPublish == true ? 1 : 0;
  224. param["MaturePublish"] = maturePublish == true ? 1 : 0;
  225. param["FounderID"] = founderID.ToString();
  226. param["EveryonePowers"] = ((ulong)DefaultEveryonePowers).ToString();
  227. param["OwnerRoleID"] = OwnerRoleID.ToString();
  228. param["OwnersPowers"] = ((ulong)DefaultOwnerPowers).ToString();
  229. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param);
  230. if (respData.Contains("error"))
  231. {
  232. // UUID is not nullable
  233. return UUID.Zero;
  234. }
  235. return UUID.Parse((string)respData["GroupID"]);
  236. }
  237. public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
  238. UUID insigniaID, int membershipFee, bool openEnrollment,
  239. bool allowPublish, bool maturePublish)
  240. {
  241. Hashtable param = new Hashtable();
  242. param["GroupID"] = groupID.ToString();
  243. param["Charter"] = charter;
  244. param["ShowInList"] = showInList == true ? 1 : 0;
  245. param["InsigniaID"] = insigniaID.ToString();
  246. param["MembershipFee"] = membershipFee;
  247. param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
  248. param["AllowPublish"] = allowPublish == true ? 1 : 0;
  249. param["MaturePublish"] = maturePublish == true ? 1 : 0;
  250. XmlRpcCall(requestingAgentID, "groups.updateGroup", param);
  251. }
  252. public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
  253. string title, ulong powers)
  254. {
  255. Hashtable param = new Hashtable();
  256. param["GroupID"] = groupID.ToString();
  257. param["RoleID"] = roleID.ToString();
  258. param["Name"] = name;
  259. param["Description"] = description;
  260. param["Title"] = title;
  261. param["Powers"] = powers.ToString();
  262. XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param);
  263. }
  264. public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
  265. {
  266. Hashtable param = new Hashtable();
  267. param["GroupID"] = groupID.ToString();
  268. param["RoleID"] = roleID.ToString();
  269. XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param);
  270. }
  271. public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
  272. string title, ulong powers)
  273. {
  274. Hashtable param = new Hashtable();
  275. param["GroupID"] = groupID.ToString();
  276. param["RoleID"] = roleID.ToString();
  277. if (name != null)
  278. {
  279. param["Name"] = name;
  280. }
  281. if (description != null)
  282. {
  283. param["Description"] = description;
  284. }
  285. if (title != null)
  286. {
  287. param["Title"] = title;
  288. }
  289. param["Powers"] = powers.ToString();
  290. XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param);
  291. }
  292. public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
  293. {
  294. Hashtable param = new Hashtable();
  295. if (GroupID != UUID.Zero)
  296. {
  297. param["GroupID"] = GroupID.ToString();
  298. }
  299. if (!string.IsNullOrEmpty(GroupName))
  300. {
  301. param["Name"] = GroupName.ToString();
  302. }
  303. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
  304. if (respData.Contains("error"))
  305. {
  306. return null;
  307. }
  308. return GroupProfileHashtableToGroupRecord(respData);
  309. }
  310. public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
  311. {
  312. Hashtable param = new Hashtable();
  313. param["GroupID"] = GroupID.ToString();
  314. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
  315. if (respData.Contains("error"))
  316. {
  317. // GroupProfileData is not nullable
  318. return new GroupProfileData();
  319. }
  320. GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
  321. GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
  322. MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
  323. MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
  324. return MemberGroupProfile;
  325. }
  326. public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  327. {
  328. Hashtable param = new Hashtable();
  329. param["AgentID"] = AgentID.ToString();
  330. param["GroupID"] = GroupID.ToString();
  331. XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param);
  332. }
  333. public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  334. {
  335. Hashtable param = new Hashtable();
  336. param["AgentID"] = AgentID.ToString();
  337. param["GroupID"] = GroupID.ToString();
  338. param["SelectedRoleID"] = RoleID.ToString();
  339. XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
  340. }
  341. public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
  342. {
  343. Hashtable param = new Hashtable();
  344. param["AgentID"] = AgentID.ToString();
  345. param["GroupID"] = GroupID.ToString();
  346. param["AcceptNotices"] = AcceptNotices ? "1" : "0";
  347. param["ListInProfile"] = ListInProfile ? "1" : "0";
  348. XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
  349. }
  350. public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
  351. {
  352. Hashtable param = new Hashtable();
  353. param["InviteID"] = inviteID.ToString();
  354. param["AgentID"] = agentID.ToString();
  355. param["RoleID"] = roleID.ToString();
  356. param["GroupID"] = groupID.ToString();
  357. XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param);
  358. }
  359. public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
  360. {
  361. Hashtable param = new Hashtable();
  362. param["InviteID"] = inviteID.ToString();
  363. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param);
  364. if (respData.Contains("error"))
  365. {
  366. return null;
  367. }
  368. GroupInviteInfo inviteInfo = new GroupInviteInfo();
  369. inviteInfo.InviteID = inviteID;
  370. inviteInfo.GroupID = UUID.Parse((string)respData["GroupID"]);
  371. inviteInfo.RoleID = UUID.Parse((string)respData["RoleID"]);
  372. inviteInfo.AgentID = UUID.Parse((string)respData["AgentID"]);
  373. return inviteInfo;
  374. }
  375. public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
  376. {
  377. Hashtable param = new Hashtable();
  378. param["InviteID"] = inviteID.ToString();
  379. XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param);
  380. }
  381. public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  382. {
  383. Hashtable param = new Hashtable();
  384. param["AgentID"] = AgentID.ToString();
  385. param["GroupID"] = GroupID.ToString();
  386. param["RoleID"] = RoleID.ToString();
  387. XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param);
  388. }
  389. public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  390. {
  391. Hashtable param = new Hashtable();
  392. param["AgentID"] = AgentID.ToString();
  393. param["GroupID"] = GroupID.ToString();
  394. XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param);
  395. }
  396. public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  397. {
  398. Hashtable param = new Hashtable();
  399. param["AgentID"] = AgentID.ToString();
  400. param["GroupID"] = GroupID.ToString();
  401. param["RoleID"] = RoleID.ToString();
  402. XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param);
  403. }
  404. public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  405. {
  406. Hashtable param = new Hashtable();
  407. param["AgentID"] = AgentID.ToString();
  408. param["GroupID"] = GroupID.ToString();
  409. param["RoleID"] = RoleID.ToString();
  410. XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param);
  411. }
  412. public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
  413. {
  414. Hashtable param = new Hashtable();
  415. param["Search"] = search;
  416. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);
  417. List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
  418. if (!respData.Contains("error"))
  419. {
  420. Hashtable results = (Hashtable)respData["results"];
  421. foreach (Hashtable groupFind in results.Values)
  422. {
  423. DirGroupsReplyData data = new DirGroupsReplyData();
  424. data.groupID = new UUID((string)groupFind["GroupID"]); ;
  425. data.groupName = (string)groupFind["Name"];
  426. data.members = int.Parse((string)groupFind["Members"]);
  427. // data.searchOrder = order;
  428. findings.Add(data);
  429. }
  430. }
  431. return findings;
  432. }
  433. public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  434. {
  435. Hashtable param = new Hashtable();
  436. param["AgentID"] = AgentID.ToString();
  437. param["GroupID"] = GroupID.ToString();
  438. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param);
  439. if (respData.Contains("error"))
  440. {
  441. return null;
  442. }
  443. GroupMembershipData data = HashTableToGroupMembershipData(respData);
  444. return data;
  445. }
  446. public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
  447. {
  448. Hashtable param = new Hashtable();
  449. param["AgentID"] = AgentID.ToString();
  450. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param);
  451. if (respData.Contains("error"))
  452. {
  453. return null;
  454. }
  455. return HashTableToGroupMembershipData(respData);
  456. }
  457. public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
  458. {
  459. Hashtable param = new Hashtable();
  460. param["AgentID"] = AgentID.ToString();
  461. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param);
  462. List<GroupMembershipData> memberships = new List<GroupMembershipData>();
  463. if (!respData.Contains("error"))
  464. {
  465. foreach (object membership in respData.Values)
  466. {
  467. memberships.Add(HashTableToGroupMembershipData((Hashtable)membership));
  468. }
  469. }
  470. return memberships;
  471. }
  472. public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  473. {
  474. Hashtable param = new Hashtable();
  475. param["AgentID"] = AgentID.ToString();
  476. param["GroupID"] = GroupID.ToString();
  477. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param);
  478. List<GroupRolesData> Roles = new List<GroupRolesData>();
  479. if (respData.Contains("error"))
  480. {
  481. return Roles;
  482. }
  483. foreach (Hashtable role in respData.Values)
  484. {
  485. GroupRolesData data = new GroupRolesData();
  486. data.RoleID = new UUID((string)role["RoleID"]);
  487. data.Name = (string)role["Name"];
  488. data.Description = (string)role["Description"];
  489. data.Powers = ulong.Parse((string)role["Powers"]);
  490. data.Title = (string)role["Title"];
  491. Roles.Add(data);
  492. }
  493. return Roles;
  494. }
  495. public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
  496. {
  497. Hashtable param = new Hashtable();
  498. param["GroupID"] = GroupID.ToString();
  499. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param);
  500. List<GroupRolesData> Roles = new List<GroupRolesData>();
  501. if (respData.Contains("error"))
  502. {
  503. return Roles;
  504. }
  505. foreach (Hashtable role in respData.Values)
  506. {
  507. GroupRolesData data = new GroupRolesData();
  508. data.Description = (string)role["Description"];
  509. data.Members = int.Parse((string)role["Members"]);
  510. data.Name = (string)role["Name"];
  511. data.Powers = ulong.Parse((string)role["Powers"]);
  512. data.RoleID = new UUID((string)role["RoleID"]);
  513. data.Title = (string)role["Title"];
  514. Roles.Add(data);
  515. }
  516. return Roles;
  517. }
  518. public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
  519. {
  520. Hashtable param = new Hashtable();
  521. param["GroupID"] = GroupID.ToString();
  522. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param);
  523. List<GroupMembersData> members = new List<GroupMembersData>();
  524. if (respData.Contains("error"))
  525. {
  526. return members;
  527. }
  528. foreach (Hashtable membership in respData.Values)
  529. {
  530. GroupMembersData data = new GroupMembersData();
  531. data.AcceptNotices = ((string)membership["AcceptNotices"]) == "1";
  532. data.AgentID = new UUID((string)membership["AgentID"]);
  533. data.Contribution = int.Parse((string)membership["Contribution"]);
  534. data.IsOwner = ((string)membership["IsOwner"]) == "1";
  535. data.ListInProfile = ((string)membership["ListInProfile"]) == "1";
  536. data.AgentPowers = ulong.Parse((string)membership["AgentPowers"]);
  537. data.Title = (string)membership["Title"];
  538. members.Add(data);
  539. }
  540. return members;
  541. }
  542. public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
  543. {
  544. Hashtable param = new Hashtable();
  545. param["GroupID"] = GroupID.ToString();
  546. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
  547. List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
  548. if (!respData.Contains("error"))
  549. {
  550. foreach (Hashtable membership in respData.Values)
  551. {
  552. GroupRoleMembersData data = new GroupRoleMembersData();
  553. data.MemberID = new UUID((string)membership["AgentID"]);
  554. data.RoleID = new UUID((string)membership["RoleID"]);
  555. members.Add(data);
  556. }
  557. }
  558. return members;
  559. }
  560. public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
  561. {
  562. Hashtable param = new Hashtable();
  563. param["GroupID"] = GroupID.ToString();
  564. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
  565. List<GroupNoticeData> values = new List<GroupNoticeData>();
  566. if (!respData.Contains("error"))
  567. {
  568. foreach (Hashtable value in respData.Values)
  569. {
  570. GroupNoticeData data = new GroupNoticeData();
  571. data.NoticeID = UUID.Parse((string)value["NoticeID"]);
  572. data.Timestamp = uint.Parse((string)value["Timestamp"]);
  573. data.FromName = (string)value["FromName"];
  574. data.Subject = (string)value["Subject"];
  575. data.HasAttachment = false;
  576. data.AssetType = 0;
  577. values.Add(data);
  578. }
  579. }
  580. return values;
  581. }
  582. public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
  583. {
  584. Hashtable param = new Hashtable();
  585. param["NoticeID"] = noticeID.ToString();
  586. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
  587. if (respData.Contains("error"))
  588. {
  589. return null;
  590. }
  591. GroupNoticeInfo data = new GroupNoticeInfo();
  592. data.GroupID = UUID.Parse((string)respData["GroupID"]);
  593. data.Message = (string)respData["Message"];
  594. data.BinaryBucket = Utils.HexStringToBytes((string)respData["BinaryBucket"], true);
  595. data.noticeData.NoticeID = UUID.Parse((string)respData["NoticeID"]);
  596. data.noticeData.Timestamp = uint.Parse((string)respData["Timestamp"]);
  597. data.noticeData.FromName = (string)respData["FromName"];
  598. data.noticeData.Subject = (string)respData["Subject"];
  599. data.noticeData.HasAttachment = false;
  600. data.noticeData.AssetType = 0;
  601. if (data.Message == null)
  602. {
  603. data.Message = string.Empty;
  604. }
  605. return data;
  606. }
  607. public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
  608. {
  609. string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
  610. Hashtable param = new Hashtable();
  611. param["GroupID"] = groupID.ToString();
  612. param["NoticeID"] = noticeID.ToString();
  613. param["FromName"] = fromName;
  614. param["Subject"] = subject;
  615. param["Message"] = message;
  616. param["BinaryBucket"] = binBucket;
  617. param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
  618. XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
  619. }
  620. #endregion
  621. #region GroupSessionTracking
  622. public void ResetAgentGroupChatSessions(UUID agentID)
  623. {
  624. foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
  625. {
  626. agentList.Remove(agentID);
  627. }
  628. }
  629. public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
  630. {
  631. // If we're tracking this group, and we can find them in the tracking, then they've been invited
  632. return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
  633. && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
  634. }
  635. public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
  636. {
  637. // If we're tracking drops for this group,
  638. // and we find them, well... then they've dropped
  639. return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
  640. && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
  641. }
  642. public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
  643. {
  644. if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
  645. {
  646. // If not in dropped list, add
  647. if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
  648. {
  649. m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
  650. }
  651. }
  652. }
  653. public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
  654. {
  655. // Add Session Status if it doesn't exist for this session
  656. CreateGroupChatSessionTracking(groupID);
  657. // If nessesary, remove from dropped list
  658. if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
  659. {
  660. m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
  661. }
  662. }
  663. private void CreateGroupChatSessionTracking(UUID groupID)
  664. {
  665. if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
  666. {
  667. m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
  668. m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
  669. }
  670. }
  671. #endregion
  672. #region XmlRpcHashtableMarshalling
  673. private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
  674. {
  675. GroupProfileData group = new GroupProfileData();
  676. group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
  677. group.Name = (string)groupProfile["Name"];
  678. if (groupProfile["Charter"] != null)
  679. {
  680. group.Charter = (string)groupProfile["Charter"];
  681. }
  682. group.ShowInList = ((string)groupProfile["ShowInList"]) == "1";
  683. group.InsigniaID = UUID.Parse((string)groupProfile["InsigniaID"]);
  684. group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]);
  685. group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1";
  686. group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1";
  687. group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1";
  688. group.FounderID = UUID.Parse((string)groupProfile["FounderID"]);
  689. group.OwnerRole = UUID.Parse((string)groupProfile["OwnerRoleID"]);
  690. group.GroupMembershipCount = int.Parse((string)groupProfile["GroupMembershipCount"]);
  691. group.GroupRolesCount = int.Parse((string)groupProfile["GroupRolesCount"]);
  692. return group;
  693. }
  694. private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
  695. {
  696. GroupRecord group = new GroupRecord();
  697. group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
  698. group.GroupName = groupProfile["Name"].ToString();
  699. if (groupProfile["Charter"] != null)
  700. {
  701. group.Charter = (string)groupProfile["Charter"];
  702. }
  703. group.ShowInList = ((string)groupProfile["ShowInList"]) == "1";
  704. group.GroupPicture = UUID.Parse((string)groupProfile["InsigniaID"]);
  705. group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]);
  706. group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1";
  707. group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1";
  708. group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1";
  709. group.FounderID = UUID.Parse((string)groupProfile["FounderID"]);
  710. group.OwnerRoleID = UUID.Parse((string)groupProfile["OwnerRoleID"]);
  711. return group;
  712. }
  713. private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
  714. {
  715. GroupMembershipData data = new GroupMembershipData();
  716. data.AcceptNotices = ((string)respData["AcceptNotices"] == "1");
  717. data.Contribution = int.Parse((string)respData["Contribution"]);
  718. data.ListInProfile = ((string)respData["ListInProfile"] == "1");
  719. data.ActiveRole = new UUID((string)respData["SelectedRoleID"]);
  720. data.GroupTitle = (string)respData["Title"];
  721. data.GroupPowers = ulong.Parse((string)respData["GroupPowers"]);
  722. // Is this group the agent's active group
  723. data.GroupID = new UUID((string)respData["GroupID"]);
  724. UUID ActiveGroup = new UUID((string)respData["ActiveGroupID"]);
  725. data.Active = data.GroupID.Equals(ActiveGroup);
  726. data.AllowPublish = ((string)respData["AllowPublish"] == "1");
  727. if (respData["Charter"] != null)
  728. {
  729. data.Charter = (string)respData["Charter"];
  730. }
  731. data.FounderID = new UUID((string)respData["FounderID"]);
  732. data.GroupID = new UUID((string)respData["GroupID"]);
  733. data.GroupName = (string)respData["GroupName"];
  734. data.GroupPicture = new UUID((string)respData["InsigniaID"]);
  735. data.MaturePublish = ((string)respData["MaturePublish"] == "1");
  736. data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
  737. data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
  738. data.ShowInList = ((string)respData["ShowInList"] == "1");
  739. return data;
  740. }
  741. #endregion
  742. /// <summary>
  743. /// Encapsulate the XmlRpc call to standardize security and error handling.
  744. /// </summary>
  745. private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
  746. {
  747. XmlRpcResponse resp = null;
  748. string CacheKey = null;
  749. // Only bother with the cache if it isn't disabled.
  750. if (m_cacheTimeout > 0)
  751. {
  752. if (!function.StartsWith("groups.get"))
  753. {
  754. // Any and all updates cause the cache to clear
  755. m_memoryCache.Clear();
  756. }
  757. else
  758. {
  759. StringBuilder sb = new StringBuilder(requestingAgentID + function);
  760. foreach (object key in param.Keys)
  761. {
  762. if (param[key] != null)
  763. {
  764. sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
  765. }
  766. }
  767. CacheKey = sb.ToString();
  768. m_memoryCache.TryGetValue(CacheKey, out resp);
  769. }
  770. }
  771. if (resp == null)
  772. {
  773. if (m_debugEnabled)
  774. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Cache miss for key {0}", CacheKey);
  775. string UserService;
  776. UUID SessionID;
  777. GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
  778. param.Add("RequestingAgentID", requestingAgentID.ToString());
  779. param.Add("RequestingAgentUserService", UserService);
  780. param.Add("RequestingSessionID", SessionID.ToString());
  781. param.Add("ReadKey", m_groupReadKey);
  782. param.Add("WriteKey", m_groupWriteKey);
  783. IList parameters = new ArrayList();
  784. parameters.Add(param);
  785. ConfigurableKeepAliveXmlRpcRequest req;
  786. req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
  787. try
  788. {
  789. resp = req.Send(m_groupsServerURI, 10000);
  790. if ((m_cacheTimeout > 0) && (CacheKey != null))
  791. {
  792. m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
  793. }
  794. }
  795. catch (Exception e)
  796. {
  797. m_log.ErrorFormat(
  798. "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}",
  799. function, m_groupsServerURI);
  800. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}{1}", e.Message, e.StackTrace);
  801. foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
  802. {
  803. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
  804. }
  805. foreach (string key in param.Keys)
  806. {
  807. m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
  808. }
  809. Hashtable respData = new Hashtable();
  810. respData.Add("error", e.ToString());
  811. return respData;
  812. }
  813. }
  814. if (resp.Value is Hashtable)
  815. {
  816. Hashtable respData = (Hashtable)resp.Value;
  817. if (respData.Contains("error") && !respData.Contains("succeed"))
  818. {
  819. LogRespDataToConsoleError(requestingAgentID, function, param, respData);
  820. }
  821. return respData;
  822. }
  823. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());
  824. if (resp.Value is ArrayList)
  825. {
  826. ArrayList al = (ArrayList)resp.Value;
  827. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
  828. foreach (object o in al)
  829. {
  830. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString());
  831. }
  832. }
  833. else
  834. {
  835. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
  836. }
  837. Hashtable error = new Hashtable();
  838. error.Add("error", "invalid return value");
  839. return error;
  840. }
  841. private void LogRespDataToConsoleError(UUID requestingAgentID, string function, Hashtable param, Hashtable respData)
  842. {
  843. m_log.ErrorFormat(
  844. "[XMLRPC-GROUPS-CONNECTOR]: Error when calling {0} for {1} with params {2}. Response params are {3}",
  845. function, requestingAgentID, Util.PrettyFormatToSingleLine(param), Util.PrettyFormatToSingleLine(respData));
  846. }
  847. /// <summary>
  848. /// Group Request Tokens are an attempt to allow the groups service to authenticate
  849. /// requests.
  850. /// TODO: This broke after the big grid refactor, either find a better way, or discard this
  851. /// </summary>
  852. /// <param name="client"></param>
  853. /// <returns></returns>
  854. private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
  855. {
  856. UserServiceURL = "";
  857. SessionID = UUID.Zero;
  858. // Need to rework this based on changes to User Services
  859. /*
  860. UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
  861. if (userAccount == null)
  862. {
  863. // This should be impossible. If I've been passed a reference to a client
  864. // that client should be registered with the UserService. So something
  865. // is horribly wrong somewhere.
  866. m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
  867. }
  868. else if (userProfile is ForeignUserProfileData)
  869. {
  870. // They aren't from around here
  871. ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
  872. UserServiceURL = fupd.UserServerURI;
  873. SessionID = fupd.CurrentAgent.SessionID;
  874. }
  875. else
  876. {
  877. // They're a local user, use this:
  878. UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
  879. SessionID = userProfile.CurrentAgent.SessionID;
  880. }
  881. */
  882. }
  883. }
  884. }
  885. namespace Nwc.XmlRpc
  886. {
  887. using System;
  888. using System.Collections;
  889. using System.IO;
  890. using System.Xml;
  891. using System.Net;
  892. using System.Text;
  893. using System.Reflection;
  894. /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
  895. public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
  896. {
  897. private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
  898. private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
  899. private bool _disableKeepAlive = true;
  900. public string RequestResponse = String.Empty;
  901. /// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
  902. /// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
  903. /// should be directed to.</param>
  904. /// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
  905. public ConfigurableKeepAliveXmlRpcRequest(String methodName, IList parameters, bool disableKeepAlive)
  906. {
  907. MethodName = methodName;
  908. _params = parameters;
  909. _disableKeepAlive = disableKeepAlive;
  910. }
  911. /// <summary>Send the request to the server.</summary>
  912. /// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
  913. /// <returns><c>XmlRpcResponse</c> The response generated.</returns>
  914. public XmlRpcResponse Send(String url)
  915. {
  916. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  917. if (request == null)
  918. throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
  919. XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
  920. request.Method = "POST";
  921. request.ContentType = "text/xml";
  922. request.AllowWriteStreamBuffering = true;
  923. request.KeepAlive = !_disableKeepAlive;
  924. using (Stream stream = request.GetRequestStream())
  925. {
  926. using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII))
  927. {
  928. _serializer.Serialize(xml, this);
  929. xml.Flush();
  930. }
  931. }
  932. XmlRpcResponse resp;
  933. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  934. {
  935. using (Stream s = response.GetResponseStream())
  936. {
  937. using (StreamReader input = new StreamReader(s))
  938. {
  939. string inputXml = input.ReadToEnd();
  940. try
  941. {
  942. resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
  943. }
  944. catch (Exception e)
  945. {
  946. RequestResponse = inputXml;
  947. throw e;
  948. }
  949. }
  950. }
  951. }
  952. return resp;
  953. }
  954. }
  955. }