aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGridServices.UserServer/UserManager.cs')
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/UserManager.cs51
1 files changed, 51 insertions, 0 deletions
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}