diff options
author | mingchen | 2007-06-28 14:45:46 +0000 |
---|---|---|
committer | mingchen | 2007-06-28 14:45:46 +0000 |
commit | bee543300fc812277e9a9478dc05b986e00ed44e (patch) | |
tree | 06282ee383d09a271cc8c7bbeed5dd41b5abee8c /OpenSim/Framework/UserManager | |
parent | Finished removing the old scripting code, Scene.Scripting.cs and OpenSim.Fram... (diff) | |
download | opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.zip opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.tar.gz opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.tar.bz2 opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.tar.xz |
*User Profile requests on OGS UserServer now uses XMLRPC instead of REST
*Added base support for setting up a master user
Diffstat (limited to 'OpenSim/Framework/UserManager')
-rw-r--r-- | OpenSim/Framework/UserManager/UserManagerBase.cs | 126 |
1 files changed, 60 insertions, 66 deletions
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index eb46c14..bc35164 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs | |||
@@ -537,27 +537,15 @@ namespace OpenSim.Framework.UserManagement | |||
537 | /// Returns an error message that the user could not be found in the database | 537 | /// Returns an error message that the user could not be found in the database |
538 | /// </summary> | 538 | /// </summary> |
539 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> | 539 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> |
540 | public string CreateUnknownUserErrorResponse() | 540 | public XmlRpcResponse CreateUnknownUserErrorResponse() |
541 | { | 541 | { |
542 | System.IO.StringWriter sw = new System.IO.StringWriter(); | 542 | XmlRpcResponse response = new XmlRpcResponse(); |
543 | XmlTextWriter xw = new XmlTextWriter(sw); | 543 | Hashtable responseData = new Hashtable(); |
544 | 544 | responseData["error_type"] = "unknown_user"; | |
545 | // Header | 545 | 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 | 546 | ||
560 | return sw.ToString(); | 547 | response.Value = responseData; |
548 | return response; | ||
561 | } | 549 | } |
562 | 550 | ||
563 | /// <summary> | 551 | /// <summary> |
@@ -565,75 +553,81 @@ namespace OpenSim.Framework.UserManagement | |||
565 | /// </summary> | 553 | /// </summary> |
566 | /// <param name="profile">The user profile</param> | 554 | /// <param name="profile">The user profile</param> |
567 | /// <returns>A string containing an XML Document of the user profile</returns> | 555 | /// <returns>A string containing an XML Document of the user profile</returns> |
568 | public string ProfileToXml(UserProfileData profile) | 556 | public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) |
569 | { | 557 | { |
570 | System.IO.StringWriter sw = new System.IO.StringWriter(); | 558 | XmlRpcResponse response = new XmlRpcResponse(); |
571 | XmlTextWriter xw = new XmlTextWriter(sw); | 559 | Hashtable responseData = new Hashtable(); |
572 | 560 | ||
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 | 561 | // Account information |
583 | xw.WriteAttributeString("firstname", profile.username); | 562 | responseData["firstname"] = profile.username; |
584 | xw.WriteAttributeString("lastname", profile.surname); | 563 | responseData["lastname"] = profile.surname; |
585 | xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated()); | 564 | responseData["uuid"] = profile.UUID.ToStringHyphenated(); |
586 | // Server Information | 565 | // Server Information |
587 | xw.WriteAttributeString("server_inventory", profile.userInventoryURI); | 566 | responseData["server_inventory"] = profile.userInventoryURI; |
588 | xw.WriteAttributeString("server_asset", profile.userAssetURI); | 567 | responseData["server_asset"] = profile.userAssetURI; |
589 | // Profile Information | 568 | // Profile Information |
590 | xw.WriteAttributeString("profile_about", profile.profileAboutText); | 569 | responseData["profile_about"] = profile.profileAboutText; |
591 | xw.WriteAttributeString("profile_firstlife_about", profile.profileFirstText); | 570 | responseData["profile_firstlife_about"] = profile.profileFirstText; |
592 | xw.WriteAttributeString("profile_firstlife_image", profile.profileFirstImage.ToStringHyphenated()); | 571 | responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated(); |
593 | xw.WriteAttributeString("profile_can_do", profile.profileCanDoMask.ToString()); | 572 | responseData["profile_can_do"] = profile.profileCanDoMask.ToString(); |
594 | xw.WriteAttributeString("profile_want_do", profile.profileWantDoMask.ToString()); | 573 | responseData["profile_want_do"] = profile.profileWantDoMask.ToString(); |
595 | xw.WriteAttributeString("profile_image", profile.profileImage.ToStringHyphenated()); | 574 | responseData["profile_image"] = profile.profileImage.ToStringHyphenated(); |
596 | xw.WriteAttributeString("profile_created",profile.created.ToString()); | 575 | responseData["profile_created"] = profile.created.ToString(); |
597 | xw.WriteAttributeString("profile_lastlogin",profile.lastLogin.ToString()); | 576 | responseData["profile_lastlogin"] = profile.lastLogin.ToString(); |
598 | // Home region information | 577 | // Home region information |
599 | xw.WriteAttributeString("home_coordinates", profile.homeLocation.ToString()); | 578 | responseData["home_coordinates"] = profile.homeLocation.ToString(); |
600 | xw.WriteAttributeString("home_region", profile.homeRegion.ToString()); | 579 | responseData["home_region"] = profile.homeRegion.ToString(); |
601 | xw.WriteAttributeString("home_look", profile.homeLookAt.ToString()); | 580 | responseData["home_look"] = profile.homeLookAt.ToString(); |
602 | 581 | ||
603 | xw.WriteEndElement(); | 582 | response.Value = responseData; |
604 | 583 | return response; | |
605 | // Footer | ||
606 | xw.WriteEndElement(); | ||
607 | xw.Flush(); | ||
608 | xw.Close(); | ||
609 | |||
610 | return sw.ToString(); | ||
611 | } | 584 | } |
612 | 585 | ||
613 | #region REST Methods | 586 | #region XMLRPC User Methods |
614 | //should most likely move out of here and into the grid's userserver sub class | 587 | //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) | 588 | public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) |
616 | { | 589 | { |
617 | UserProfileData userProfile = getUserProfile(param.Trim()); | 590 | XmlRpcResponse response = new XmlRpcResponse(); |
591 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
592 | UserProfileData userProfile; | ||
618 | 593 | ||
619 | if (userProfile == null) | 594 | if (requestData.Contains("avatar_name")) |
595 | { | ||
596 | userProfile = getUserProfile((string)requestData["avatar_name"]); | ||
597 | if (userProfile == null) | ||
598 | { | ||
599 | return CreateUnknownUserErrorResponse(); | ||
600 | } | ||
601 | } | ||
602 | else | ||
620 | { | 603 | { |
621 | return CreateUnknownUserErrorResponse(); | 604 | return CreateUnknownUserErrorResponse(); |
622 | } | 605 | } |
606 | |||
623 | 607 | ||
624 | return ProfileToXml(userProfile); | 608 | return ProfileToXmlRPCResponse(userProfile); |
625 | } | 609 | } |
626 | 610 | ||
627 | public string RestGetUserMethodUUID(string request, string path, string param) | 611 | public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) |
628 | { | 612 | { |
629 | UserProfileData userProfile = getUserProfile(new LLUUID(param)); | 613 | XmlRpcResponse response = new XmlRpcResponse(); |
630 | 614 | Hashtable requestData = (Hashtable)request.Params[0]; | |
631 | if (userProfile == null) | 615 | UserProfileData userProfile; |
616 | if (requestData.Contains("avatar_uuid")) | ||
617 | { | ||
618 | userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]); | ||
619 | if (userProfile == null) | ||
620 | { | ||
621 | return CreateUnknownUserErrorResponse(); | ||
622 | } | ||
623 | } | ||
624 | else | ||
632 | { | 625 | { |
633 | return CreateUnknownUserErrorResponse(); | 626 | return CreateUnknownUserErrorResponse(); |
634 | } | 627 | } |
635 | 628 | ||
636 | return ProfileToXml(userProfile); | 629 | |
630 | return ProfileToXmlRPCResponse(userProfile); | ||
637 | } | 631 | } |
638 | #endregion | 632 | #endregion |
639 | 633 | ||