From 0862627b341641ec0223bb4191dfee8d85724c9e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Nov 2008 15:34:30 +0000 Subject: * refactor: move CreateUser into UserServiceAdmin --- OpenSim/Grid/MessagingServer/UserManager.cs | 11 ++++- OpenSim/Grid/UserServer/Main.cs | 64 +++++++++-------------------- OpenSim/Grid/UserServer/UserLoginService.cs | 6 ++- OpenSim/Grid/UserServer/UserManager.cs | 8 ++++ 4 files changed, 40 insertions(+), 49 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/MessagingServer/UserManager.cs b/OpenSim/Grid/MessagingServer/UserManager.cs index 6fa5113..fc8f703 100644 --- a/OpenSim/Grid/MessagingServer/UserManager.cs +++ b/OpenSim/Grid/MessagingServer/UserManager.cs @@ -41,6 +41,15 @@ namespace OpenSim.Grid.MessagingServer { class UserManager : UserManagerBase { + /// + /// Constructor. + /// + /// Passing null to parent because we never use any function that requires an interservice inventory call. + public UserManager() + : base(null) + { + } + public UserAgentData GetUserAgentData(UUID AgentID) { UserProfileData userProfile = GetUserProfile(AgentID); @@ -53,8 +62,6 @@ namespace OpenSim.Grid.MessagingServer return null; } - - public override UserProfileData SetupMasterUser(string firstName, string lastName) { //throw new Exception("The method or operation is not implemented."); diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 9c8fe23..cab5860 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -56,7 +56,6 @@ namespace OpenSim.Grid.UserServer public UserLoginService m_loginService; public GridInfoService m_gridInfoService; public MessageServersConnector m_messagesService; - protected IInterServiceInventoryServices m_interServiceInventoryService; private UUID m_lastCreatedUser = UUID.Random(); @@ -94,17 +93,16 @@ namespace OpenSim.Grid.UserServer m_stats = StatsManager.StartCollectingUserStats(); - m_log.Info("[REGION]: Establishing data connection"); - - StartupUserManager(); + m_log.Info("[STARTUP]: Establishing data connection"); + + IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); + StartupUserManager(inventoryService); m_userManager.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); m_gridInfoService = new GridInfoService(); - m_interServiceInventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); - - StartupLoginService(); + StartupLoginService(inventoryService); m_messagesService = new MessageServersConnector(); @@ -116,22 +114,30 @@ namespace OpenSim.Grid.UserServer m_messagesService.OnRegionStartup += HandleRegionStartup; m_messagesService.OnRegionShutdown += HandleRegionShutdown; - m_log.Info("[REGION]: Starting HTTP process"); + m_log.Info("[STARTUP]: Starting HTTP process"); m_httpServer = new BaseHttpServer(Cfg.HttpPort); AddHttpHandlers(); m_httpServer.Start(); } - protected virtual void StartupUserManager() + /// + /// Start up the user manager + /// + /// + protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService) { - m_userManager = new UserManager(); + m_userManager = new UserManager(new OGS1InterServiceInventoryService(Cfg.InventoryUrl)); } - protected virtual void StartupLoginService() + /// + /// Start up the login service + /// + /// + protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) { m_loginService = new UserLoginService( - m_userManager, m_interServiceInventoryService, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); + m_userManager, inventoryService, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); } protected virtual void AddHttpHandlers() @@ -256,39 +262,7 @@ namespace OpenSim.Grid.UserServer if (null == m_userManager.GetUserProfile(firstName, lastName)) { - password = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - - UUID userID = new UUID(); - - try - { - userID = m_userManager.AddUserProfile(firstName, lastName, password, email, regX, regY); - } - catch (Exception ex) - { - m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString()); - } - - try - { - if (!m_interServiceInventoryService.CreateNewUserInventory(userID)) - { - throw new Exception( - String.Format("The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", userID)); - } - } - catch (WebException) - { - m_log.ErrorFormat("[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}", - Cfg.InventoryUrl + "CreateInventory/", userID); - } - catch (Exception e) - { - m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e); - } - - m_lastCreatedUser = userID; + m_lastCreatedUser = m_userManager.AddUser(firstName, lastName, password, email, regX, regY); } else { diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 82d5af5..2308910 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -44,6 +44,9 @@ namespace OpenSim.Grid.UserServer ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname); + /// + /// Login service used in grid mode. + /// public class UserLoginService : LoginService { protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -65,17 +68,16 @@ namespace OpenSim.Grid.UserServer m_config = config; m_inventoryService = inventoryService; } + public void setloginlevel(int level) { m_minLoginLevel = level; m_log.InfoFormat("[GRID] Login Level set to {0} ", level); - } public void setwelcometext(string text) { m_welcomeMessage = text; m_log.InfoFormat("[GRID] Login text set to {0} ", text); - } public override void LogOffUser(UserProfileData theUser, string message) diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 76f83b7..377ff3a 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -46,6 +46,14 @@ namespace OpenSim.Grid.UserServer public event logOffUser OnLogOffUser; private logOffUser handlerLogOffUser; + + /// + /// Constructor + /// + /// + public UserManager(IInterServiceInventoryServices interServiceInventoryService) + : base(interServiceInventoryService) + {} /// /// Deletes an active agent session -- cgit v1.1