XmlRpcGroupsServicesConnectorModule.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  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.Framework.Communications;
  40. using OpenSim.Region.Framework.Interfaces;
  41. using OpenSim.Services.Interfaces;
  42. namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
  43. {
  44. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
  45. public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
  46. {
  47. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  48. private bool m_debugEnabled = false;
  49. public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
  50. GroupPowers.Accountable |
  51. GroupPowers.JoinChat |
  52. GroupPowers.AllowVoiceChat |
  53. GroupPowers.ReceiveNotices |
  54. GroupPowers.StartProposal |
  55. GroupPowers.VoteOnProposal;
  56. private bool m_connectorEnabled = false;
  57. private string m_groupsServerURI = string.Empty;
  58. private bool m_disableKeepAlive = false;
  59. private string m_groupReadKey = string.Empty;
  60. private string m_groupWriteKey = string.Empty;
  61. private IUserAccountService m_accountService = null;
  62. private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
  63. private int m_cacheTimeout = 30;
  64. // Used to track which agents are have dropped from a group chat session
  65. // Should be reset per agent, on logon
  66. // TODO: move this to Flotsam XmlRpc Service
  67. // SessionID, List<AgentID>
  68. private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
  69. private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
  70. #region IRegionModuleBase Members
  71. public string Name
  72. {
  73. get { return "XmlRpcGroupsServicesConnector"; }
  74. }
  75. // this module is not intended to be replaced, but there should only be 1 of them.
  76. public Type ReplaceableInterface
  77. {
  78. get { return null; }
  79. }
  80. public void Initialise(IConfigSource config)
  81. {
  82. IConfig groupsConfig = config.Configs["Groups"];
  83. if (groupsConfig == null)
  84. {
  85. // Do not run this module by default.
  86. return;
  87. }
  88. else
  89. {
  90. // if groups aren't enabled, we're not needed.
  91. // if we're not specified as the connector to use, then we're not wanted
  92. if ((groupsConfig.GetBoolean("Enabled", false) == false)
  93. || (groupsConfig.GetString("ServicesConnectorModule", "XmlRpcGroupsServicesConnector") != Name))
  94. {
  95. m_connectorEnabled = false;
  96. return;
  97. }
  98. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
  99. m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
  100. if ((m_groupsServerURI == null) ||
  101. (m_groupsServerURI == string.Empty))
  102. {
  103. m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
  104. m_connectorEnabled = false;
  105. return;
  106. }
  107. m_disableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false);
  108. m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
  109. m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
  110. m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
  111. if (m_cacheTimeout == 0)
  112. {
  113. m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
  114. }
  115. else
  116. {
  117. m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
  118. }
  119. m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", false);
  120. // If we got all the config options we need, lets start'er'up
  121. m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
  122. m_connectorEnabled = true;
  123. }
  124. }
  125. public void Close()
  126. {
  127. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
  128. }
  129. public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
  130. {
  131. if (m_connectorEnabled)
  132. {
  133. if (m_accountService == null)
  134. {
  135. m_accountService = scene.UserAccountService;
  136. }
  137. scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
  138. }
  139. }
  140. public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
  141. {
  142. if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
  143. {
  144. scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
  145. }
  146. }
  147. public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
  148. {
  149. // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
  150. // scene.EventManager.OnNewClient += OnNewClient;
  151. }
  152. #endregion
  153. #region ISharedRegionModule Members
  154. public void PostInitialise()
  155. {
  156. // NoOp
  157. }
  158. #endregion
  159. #region IGroupsServicesConnector Members
  160. /// <summary>
  161. /// 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.
  162. /// </summary>
  163. public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
  164. int membershipFee, bool openEnrollment, bool allowPublish,
  165. bool maturePublish, UUID founderID)
  166. {
  167. UUID GroupID = UUID.Random();
  168. UUID OwnerRoleID = UUID.Random();
  169. Hashtable param = new Hashtable();
  170. param["GroupID"] = GroupID.ToString();
  171. param["Name"] = name;
  172. param["Charter"] = charter;
  173. param["ShowInList"] = showInList == true ? 1 : 0;
  174. param["InsigniaID"] = insigniaID.ToString();
  175. param["MembershipFee"] = 0;
  176. param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
  177. param["AllowPublish"] = allowPublish == true ? 1 : 0;
  178. param["MaturePublish"] = maturePublish == true ? 1 : 0;
  179. param["FounderID"] = founderID.ToString();
  180. param["EveryonePowers"] = ((ulong)m_DefaultEveryonePowers).ToString();
  181. param["OwnerRoleID"] = OwnerRoleID.ToString();
  182. // Would this be cleaner as (GroupPowers)ulong.MaxValue;
  183. GroupPowers OwnerPowers = GroupPowers.Accountable
  184. | GroupPowers.AllowEditLand
  185. | GroupPowers.AllowFly
  186. | GroupPowers.AllowLandmark
  187. | GroupPowers.AllowRez
  188. | GroupPowers.AllowSetHome
  189. | GroupPowers.AllowVoiceChat
  190. | GroupPowers.AssignMember
  191. | GroupPowers.AssignMemberLimited
  192. | GroupPowers.ChangeActions
  193. | GroupPowers.ChangeIdentity
  194. | GroupPowers.ChangeMedia
  195. | GroupPowers.ChangeOptions
  196. | GroupPowers.CreateRole
  197. | GroupPowers.DeedObject
  198. | GroupPowers.DeleteRole
  199. | GroupPowers.Eject
  200. | GroupPowers.FindPlaces
  201. | GroupPowers.Invite
  202. | GroupPowers.JoinChat
  203. | GroupPowers.LandChangeIdentity
  204. | GroupPowers.LandDeed
  205. | GroupPowers.LandDivideJoin
  206. | GroupPowers.LandEdit
  207. | GroupPowers.LandEjectAndFreeze
  208. | GroupPowers.LandGardening
  209. | GroupPowers.LandManageAllowed
  210. | GroupPowers.LandManageBanned
  211. | GroupPowers.LandManagePasses
  212. | GroupPowers.LandOptions
  213. | GroupPowers.LandRelease
  214. | GroupPowers.LandSetSale
  215. | GroupPowers.ModerateChat
  216. | GroupPowers.ObjectManipulate
  217. | GroupPowers.ObjectSetForSale
  218. | GroupPowers.ReceiveNotices
  219. | GroupPowers.RemoveMember
  220. | GroupPowers.ReturnGroupOwned
  221. | GroupPowers.ReturnGroupSet
  222. | GroupPowers.ReturnNonGroup
  223. | GroupPowers.RoleProperties
  224. | GroupPowers.SendNotices
  225. | GroupPowers.SetLandingPoint
  226. | GroupPowers.StartProposal
  227. | GroupPowers.VoteOnProposal;
  228. param["OwnersPowers"] = ((ulong)OwnerPowers).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 ((GroupName != null) && (GroupName != string.Empty))
  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(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(Hashtable respData)
  842. {
  843. m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:");
  844. foreach (string key in respData.Keys)
  845. {
  846. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key);
  847. string[] lines = respData[key].ToString().Split(new char[] { '\n' });
  848. foreach (string line in lines)
  849. {
  850. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line);
  851. }
  852. }
  853. }
  854. /// <summary>
  855. /// Group Request Tokens are an attempt to allow the groups service to authenticate
  856. /// requests.
  857. /// TODO: This broke after the big grid refactor, either find a better way, or discard this
  858. /// </summary>
  859. /// <param name="client"></param>
  860. /// <returns></returns>
  861. private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
  862. {
  863. UserServiceURL = "";
  864. SessionID = UUID.Zero;
  865. // Need to rework this based on changes to User Services
  866. /*
  867. UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
  868. if (userAccount == null)
  869. {
  870. // This should be impossible. If I've been passed a reference to a client
  871. // that client should be registered with the UserService. So something
  872. // is horribly wrong somewhere.
  873. m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
  874. }
  875. else if (userProfile is ForeignUserProfileData)
  876. {
  877. // They aren't from around here
  878. ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
  879. UserServiceURL = fupd.UserServerURI;
  880. SessionID = fupd.CurrentAgent.SessionID;
  881. }
  882. else
  883. {
  884. // They're a local user, use this:
  885. UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
  886. SessionID = userProfile.CurrentAgent.SessionID;
  887. }
  888. */
  889. }
  890. }
  891. }
  892. namespace Nwc.XmlRpc
  893. {
  894. using System;
  895. using System.Collections;
  896. using System.IO;
  897. using System.Xml;
  898. using System.Net;
  899. using System.Text;
  900. using System.Reflection;
  901. /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
  902. public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
  903. {
  904. private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
  905. private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
  906. private bool _disableKeepAlive = true;
  907. public string RequestResponse = String.Empty;
  908. /// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
  909. /// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
  910. /// should be directed to.</param>
  911. /// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
  912. public ConfigurableKeepAliveXmlRpcRequest(String methodName, IList parameters, bool disableKeepAlive)
  913. {
  914. MethodName = methodName;
  915. _params = parameters;
  916. _disableKeepAlive = disableKeepAlive;
  917. }
  918. /// <summary>Send the request to the server.</summary>
  919. /// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
  920. /// <returns><c>XmlRpcResponse</c> The response generated.</returns>
  921. public XmlRpcResponse Send(String url)
  922. {
  923. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  924. if (request == null)
  925. throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
  926. XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
  927. request.Method = "POST";
  928. request.ContentType = "text/xml";
  929. request.AllowWriteStreamBuffering = true;
  930. request.KeepAlive = !_disableKeepAlive;
  931. Stream stream = request.GetRequestStream();
  932. XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII);
  933. _serializer.Serialize(xml, this);
  934. xml.Flush();
  935. xml.Close();
  936. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  937. StreamReader input = new StreamReader(response.GetResponseStream());
  938. string inputXml = input.ReadToEnd();
  939. XmlRpcResponse resp;
  940. try
  941. {
  942. resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
  943. }
  944. catch (Exception e)
  945. {
  946. RequestResponse = inputXml;
  947. throw e;
  948. }
  949. input.Close();
  950. response.Close();
  951. return resp;
  952. }
  953. }
  954. }