diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/UserManager/UserManagerBase.cs (renamed from Common/OpenGrid.Framework.UserManager/UserManagerBase.cs) | 135 |
1 files changed, 64 insertions, 71 deletions
diff --git a/Common/OpenGrid.Framework.UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index 01fbf3a..d06059e 100644 --- a/Common/OpenGrid.Framework.UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs | |||
@@ -29,7 +29,7 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using OpenGrid.Framework.Data; | 32 | using OpenSim.Framework.Data; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | 35 | ||
@@ -41,7 +41,7 @@ using OpenSim.Framework.Utilities; | |||
41 | 41 | ||
42 | using System.Security.Cryptography; | 42 | using System.Security.Cryptography; |
43 | 43 | ||
44 | namespace OpenGrid.Framework.UserManagement | 44 | namespace OpenSim.Framework.UserManagement |
45 | { | 45 | { |
46 | public class UserManagerBase | 46 | public class UserManagerBase |
47 | { | 47 | { |
@@ -468,17 +468,16 @@ namespace OpenGrid.Framework.UserManagement | |||
468 | } | 468 | } |
469 | catch (Exception e) | 469 | catch (Exception e) |
470 | { | 470 | { |
471 | Console.WriteLine(e.ToString()); | 471 | System.Console.WriteLine(e.ToString()); |
472 | return logResponse.CreateDeadRegionResponse(); | 472 | return logResponse.CreateDeadRegionResponse(); |
473 | } | 473 | } |
474 | CommitAgent(ref TheUser); | 474 | CommitAgent(ref TheUser); |
475 | |||
476 | return logResponse.ToXmlRpcResponse(); | 475 | return logResponse.ToXmlRpcResponse(); |
477 | 476 | ||
478 | } | 477 | } |
479 | catch (Exception E) | 478 | catch (Exception E) |
480 | { | 479 | { |
481 | Console.WriteLine(E.ToString()); | 480 | System.Console.WriteLine(E.ToString()); |
482 | } | 481 | } |
483 | //} | 482 | //} |
484 | } | 483 | } |
@@ -537,27 +536,15 @@ namespace OpenGrid.Framework.UserManagement | |||
537 | /// Returns an error message that the user could not be found in the database | 536 | /// Returns an error message that the user could not be found in the database |
538 | /// </summary> | 537 | /// </summary> |
539 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> | 538 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> |
540 | public string CreateUnknownUserErrorResponse() | 539 | public XmlRpcResponse CreateUnknownUserErrorResponse() |
541 | { | 540 | { |
542 | System.IO.StringWriter sw = new System.IO.StringWriter(); | 541 | XmlRpcResponse response = new XmlRpcResponse(); |
543 | XmlTextWriter xw = new XmlTextWriter(sw); | 542 | Hashtable responseData = new Hashtable(); |
544 | 543 | responseData["error_type"] = "unknown_user"; | |
545 | // Header | 544 | responseData["error_desc"] = "The user requested is not in the database"; |
546 | xw.Formatting = Formatting.Indented; | ||
547 | xw.WriteStartDocument(); | ||
548 | xw.WriteDocType("error", null, null, null); | ||
549 | xw.WriteComment("An error occured"); | ||
550 | xw.WriteStartElement("error"); | ||
551 | |||
552 | // User | ||
553 | xw.WriteElementString("unknownuser", "Unable to find a user with that name"); | ||
554 | |||
555 | // Footer | ||
556 | xw.WriteEndElement(); | ||
557 | xw.Flush(); | ||
558 | xw.Close(); | ||
559 | 545 | ||
560 | return sw.ToString(); | 546 | response.Value = responseData; |
547 | return response; | ||
561 | } | 548 | } |
562 | 549 | ||
563 | /// <summary> | 550 | /// <summary> |
@@ -565,75 +552,81 @@ namespace OpenGrid.Framework.UserManagement | |||
565 | /// </summary> | 552 | /// </summary> |
566 | /// <param name="profile">The user profile</param> | 553 | /// <param name="profile">The user profile</param> |
567 | /// <returns>A string containing an XML Document of the user profile</returns> | 554 | /// <returns>A string containing an XML Document of the user profile</returns> |
568 | public string ProfileToXml(UserProfileData profile) | 555 | public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) |
569 | { | 556 | { |
570 | System.IO.StringWriter sw = new System.IO.StringWriter(); | 557 | XmlRpcResponse response = new XmlRpcResponse(); |
571 | XmlTextWriter xw = new XmlTextWriter(sw); | 558 | Hashtable responseData = new Hashtable(); |
572 | 559 | ||
573 | // Header | ||
574 | xw.Formatting = Formatting.Indented; | ||
575 | xw.WriteStartDocument(); | ||
576 | xw.WriteDocType("userprofile", null, null, null); | ||
577 | xw.WriteComment("Found user profiles matching the request"); | ||
578 | xw.WriteStartElement("users"); | ||
579 | |||
580 | // User | ||
581 | xw.WriteStartElement("user"); | ||
582 | // Account information | 560 | // Account information |
583 | xw.WriteAttributeString("firstname", profile.username); | 561 | responseData["firstname"] = profile.username; |
584 | xw.WriteAttributeString("lastname", profile.surname); | 562 | responseData["lastname"] = profile.surname; |
585 | xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated()); | 563 | responseData["uuid"] = profile.UUID.ToStringHyphenated(); |
586 | // Server Information | 564 | // Server Information |
587 | xw.WriteAttributeString("server_inventory", profile.userInventoryURI); | 565 | responseData["server_inventory"] = profile.userInventoryURI; |
588 | xw.WriteAttributeString("server_asset", profile.userAssetURI); | 566 | responseData["server_asset"] = profile.userAssetURI; |
589 | // Profile Information | 567 | // Profile Information |
590 | xw.WriteAttributeString("profile_about", profile.profileAboutText); | 568 | responseData["profile_about"] = profile.profileAboutText; |
591 | xw.WriteAttributeString("profile_firstlife_about", profile.profileFirstText); | 569 | responseData["profile_firstlife_about"] = profile.profileFirstText; |
592 | xw.WriteAttributeString("profile_firstlife_image", profile.profileFirstImage.ToStringHyphenated()); | 570 | responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated(); |
593 | xw.WriteAttributeString("profile_can_do", profile.profileCanDoMask.ToString()); | 571 | responseData["profile_can_do"] = profile.profileCanDoMask.ToString(); |
594 | xw.WriteAttributeString("profile_want_do", profile.profileWantDoMask.ToString()); | 572 | responseData["profile_want_do"] = profile.profileWantDoMask.ToString(); |
595 | xw.WriteAttributeString("profile_image", profile.profileImage.ToStringHyphenated()); | 573 | responseData["profile_image"] = profile.profileImage.ToStringHyphenated(); |
596 | xw.WriteAttributeString("profile_created",profile.created.ToString()); | 574 | responseData["profile_created"] = profile.created.ToString(); |
597 | xw.WriteAttributeString("profile_lastlogin",profile.lastLogin.ToString()); | 575 | responseData["profile_lastlogin"] = profile.lastLogin.ToString(); |
598 | // Home region information | 576 | // Home region information |
599 | xw.WriteAttributeString("home_coordinates", profile.homeLocation.ToString()); | 577 | responseData["home_coordinates"] = profile.homeLocation.ToString(); |
600 | xw.WriteAttributeString("home_region", profile.homeRegion.ToString()); | 578 | responseData["home_region"] = profile.homeRegion.ToString(); |
601 | xw.WriteAttributeString("home_look", profile.homeLookAt.ToString()); | 579 | responseData["home_look"] = profile.homeLookAt.ToString(); |
602 | |||
603 | xw.WriteEndElement(); | ||
604 | 580 | ||
605 | // Footer | 581 | response.Value = responseData; |
606 | xw.WriteEndElement(); | 582 | return response; |
607 | xw.Flush(); | ||
608 | xw.Close(); | ||
609 | |||
610 | return sw.ToString(); | ||
611 | } | 583 | } |
612 | 584 | ||
613 | #region REST Methods | 585 | #region XMLRPC User Methods |
614 | //should most likely move out of here and into the grid's userserver sub class | 586 | //should most likely move out of here and into the grid's userserver sub class |
615 | public string RestGetUserMethodName(string request, string path, string param) | 587 | public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) |
616 | { | 588 | { |
617 | UserProfileData userProfile = getUserProfile(param.Trim()); | 589 | XmlRpcResponse response = new XmlRpcResponse(); |
590 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
591 | UserProfileData userProfile; | ||
618 | 592 | ||
619 | if (userProfile == null) | 593 | if (requestData.Contains("avatar_name")) |
594 | { | ||
595 | userProfile = getUserProfile((string)requestData["avatar_name"]); | ||
596 | if (userProfile == null) | ||
597 | { | ||
598 | return CreateUnknownUserErrorResponse(); | ||
599 | } | ||
600 | } | ||
601 | else | ||
620 | { | 602 | { |
621 | return CreateUnknownUserErrorResponse(); | 603 | return CreateUnknownUserErrorResponse(); |
622 | } | 604 | } |
605 | |||
623 | 606 | ||
624 | return ProfileToXml(userProfile); | 607 | return ProfileToXmlRPCResponse(userProfile); |
625 | } | 608 | } |
626 | 609 | ||
627 | public string RestGetUserMethodUUID(string request, string path, string param) | 610 | public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) |
628 | { | 611 | { |
629 | UserProfileData userProfile = getUserProfile(new LLUUID(param)); | 612 | XmlRpcResponse response = new XmlRpcResponse(); |
630 | 613 | Hashtable requestData = (Hashtable)request.Params[0]; | |
631 | if (userProfile == null) | 614 | UserProfileData userProfile; |
615 | if (requestData.Contains("avatar_uuid")) | ||
616 | { | ||
617 | userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]); | ||
618 | if (userProfile == null) | ||
619 | { | ||
620 | return CreateUnknownUserErrorResponse(); | ||
621 | } | ||
622 | } | ||
623 | else | ||
632 | { | 624 | { |
633 | return CreateUnknownUserErrorResponse(); | 625 | return CreateUnknownUserErrorResponse(); |
634 | } | 626 | } |
635 | 627 | ||
636 | return ProfileToXml(userProfile); | 628 | |
629 | return ProfileToXmlRPCResponse(userProfile); | ||
637 | } | 630 | } |
638 | #endregion | 631 | #endregion |
639 | 632 | ||