aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-06-09 01:21:53 +0000
committerAdam Frisby2007-06-09 01:21:53 +0000
commit26b208d738c1e33140442b27ab71bdac685b4c2c (patch)
treeedf518bc66cc503a04dd864c7356a1fc6eaaedf3
parent*Adding configuration settings for master avatars (diff)
downloadopensim-SC_OLD-26b208d738c1e33140442b27ab71bdac685b4c2c.zip
opensim-SC_OLD-26b208d738c1e33140442b27ab71bdac685b4c2c.tar.gz
opensim-SC_OLD-26b208d738c1e33140442b27ab71bdac685b4c2c.tar.bz2
opensim-SC_OLD-26b208d738c1e33140442b27ab71bdac685b4c2c.tar.xz
* Sugilite user server can now return user profile information by account name (Hi MingChen) - uses the REST GET /user/name/ method.
-rw-r--r--OpenGridServices.suobin139776 -> 139776 bytes
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Main.cs8
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/UserManager.cs51
3 files changed, 55 insertions, 4 deletions
diff --git a/OpenGridServices.suo b/OpenGridServices.suo
index 460303a..acde093 100644
--- a/OpenGridServices.suo
+++ b/OpenGridServices.suo
Binary files differ
diff --git a/OpenGridServices/OpenGridServices.UserServer/Main.cs b/OpenGridServices/OpenGridServices.UserServer/Main.cs
index bb20576..f2cefe5 100644
--- a/OpenGridServices/OpenGridServices.UserServer/Main.cs
+++ b/OpenGridServices/OpenGridServices.UserServer/Main.cs
@@ -53,9 +53,7 @@ namespace OpenGridServices.UserServer
53 private UserConfig Cfg; 53 private UserConfig Cfg;
54 protected IGenericConfig localXMLConfig; 54 protected IGenericConfig localXMLConfig;
55 55
56 public UserManager m_userManager; // Replaces below. 56 public UserManager m_userManager;
57
58 //private UserProfileManager m_userProfileManager; // Depreciated
59 57
60 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); 58 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
61 59
@@ -64,7 +62,7 @@ namespace OpenGridServices.UserServer
64 [STAThread] 62 [STAThread]
65 public static void Main(string[] args) 63 public static void Main(string[] args)
66 { 64 {
67 Console.WriteLine("Starting...\n"); 65 Console.WriteLine("Launching UserServer...");
68 66
69 OpenUser_Main userserver = new OpenUser_Main(); 67 OpenUser_Main userserver = new OpenUser_Main();
70 68
@@ -108,9 +106,11 @@ namespace OpenGridServices.UserServer
108 BaseHttpServer httpServer = new BaseHttpServer(8002); 106 BaseHttpServer httpServer = new BaseHttpServer(8002);
109 107
110 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod); 108 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
109 httpServer.AddRestHandler("GET", "/user/name/", m_userManager.RestGetUserMethodName);
111 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod); 110 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
112 111
113 httpServer.Start(); 112 httpServer.Start();
113 m_console.Status("Userserver 0.3 - Startup complete");
114 } 114 }
115 115
116 116
diff --git a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
index 913d0fc..773fa71 100644
--- a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
+++ b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
@@ -655,5 +655,56 @@ namespace OpenGridServices.UserServer
655 return "OK"; 655 return "OK";
656 } 656 }
657 657
658 public string CreateUnknownUserErrorResponse()
659 {
660 return "<error>Unknown user</error>";
661 }
662
663 /// <summary>
664 /// Converts a user profile to an XML element which can be returned
665 /// </summary>
666 /// <param name="profile">The user profile</param>
667 /// <returns>A string containing an XML Document of the user profile</returns>
668 public string ProfileToXml(UserProfileData profile)
669 {
670 System.IO.StringWriter sw = new System.IO.StringWriter();
671 XmlTextWriter xw = new XmlTextWriter(sw);
672
673 // Header
674 xw.Formatting = Formatting.Indented;
675 xw.WriteStartDocument();
676 xw.WriteDocType("userprofile", null, null, null);
677 xw.WriteComment("Found user profiles matching the request");
678 xw.WriteStartElement("users");
679
680 // User
681 xw.WriteStartElement("user");
682 xw.WriteAttributeString("firstname", profile.username);
683 xw.WriteAttributeString("lastname", profile.surname);
684 xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated());
685 xw.WriteAttributeString("inventory", profile.userInventoryURI);
686 xw.WriteAttributeString("asset", profile.userAssetURI);
687 xw.WriteEndElement();
688
689 // Footer
690 xw.WriteEndElement();
691 xw.Flush();
692 xw.Close();
693
694 return sw.ToString();
695 }
696
697 public string RestGetUserMethodName(string request, string path, string param)
698 {
699 UserProfileData userProfile = getUserProfile(param.Trim());
700
701 if (userProfile == null)
702 {
703 return CreateUnknownUserErrorResponse();
704 }
705
706 return ProfileToXml(userProfile);
707 }
708
658 } 709 }
659} 710}