From 26b208d738c1e33140442b27ab71bdac685b4c2c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 9 Jun 2007 01:21:53 +0000 Subject: * Sugilite user server can now return user profile information by account name (Hi MingChen) - uses the REST GET /user/name/ method. --- .../OpenGridServices.UserServer/UserManager.cs | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'OpenGridServices/OpenGridServices.UserServer/UserManager.cs') 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 return "OK"; } + public string CreateUnknownUserErrorResponse() + { + return "Unknown user"; + } + + /// + /// Converts a user profile to an XML element which can be returned + /// + /// The user profile + /// A string containing an XML Document of the user profile + 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); + } + } } -- cgit v1.1