* Sugilite user server can now return user profile information by account name (Hi MingChen) - uses the REST GET /user/name/ method.

Sugilite
Adam Frisby 2007-06-09 01:21:53 +00:00
parent 09dac6b558
commit 26b208d738
3 changed files with 55 additions and 4 deletions

Binary file not shown.

View File

@ -53,9 +53,7 @@ namespace OpenGridServices.UserServer
private UserConfig Cfg; private UserConfig Cfg;
protected IGenericConfig localXMLConfig; protected IGenericConfig localXMLConfig;
public UserManager m_userManager; // Replaces below. public UserManager m_userManager;
//private UserProfileManager m_userProfileManager; // Depreciated
public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
@ -64,7 +62,7 @@ namespace OpenGridServices.UserServer
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Starting...\n"); Console.WriteLine("Launching UserServer...");
OpenUser_Main userserver = new OpenUser_Main(); OpenUser_Main userserver = new OpenUser_Main();
@ -108,9 +106,11 @@ namespace OpenGridServices.UserServer
BaseHttpServer httpServer = new BaseHttpServer(8002); BaseHttpServer httpServer = new BaseHttpServer(8002);
httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod); httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
httpServer.AddRestHandler("GET", "/user/name/", m_userManager.RestGetUserMethodName);
httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod); httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
httpServer.Start(); httpServer.Start();
m_console.Status("Userserver 0.3 - Startup complete");
} }

View File

@ -655,5 +655,56 @@ namespace OpenGridServices.UserServer
return "OK"; return "OK";
} }
public string CreateUnknownUserErrorResponse()
{
return "<error>Unknown user</error>";
}
/// <summary>
/// Converts a user profile to an XML element which can be returned
/// </summary>
/// <param name="profile">The user profile</param>
/// <returns>A string containing an XML Document of the user profile</returns>
public string ProfileToXml(UserProfileData profile)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
// Header
xw.Formatting = Formatting.Indented;
xw.WriteStartDocument();
xw.WriteDocType("userprofile", null, null, null);
xw.WriteComment("Found user profiles matching the request");
xw.WriteStartElement("users");
// User
xw.WriteStartElement("user");
xw.WriteAttributeString("firstname", profile.username);
xw.WriteAttributeString("lastname", profile.surname);
xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated());
xw.WriteAttributeString("inventory", profile.userInventoryURI);
xw.WriteAttributeString("asset", profile.userAssetURI);
xw.WriteEndElement();
// Footer
xw.WriteEndElement();
xw.Flush();
xw.Close();
return sw.ToString();
}
public string RestGetUserMethodName(string request, string path, string param)
{
UserProfileData userProfile = getUserProfile(param.Trim());
if (userProfile == null)
{
return CreateUnknownUserErrorResponse();
}
return ProfileToXml(userProfile);
}
} }
} }