From dcaf457bb82221a90d56e4be057766c898f5c2dd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 20 Apr 2008 19:07:42 +0000 Subject: [PATCH] * Change user inventory create from explicit 'create user' command on the console from sync to async * Catch more error conditions and provide more messages when things go wrong --- OpenSim/Grid/UserServer/Main.cs | 36 ++++++++++++++++----- OpenSim/Grid/UserServer/UserLoginService.cs | 9 ++++-- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 19f037feec..0f0104edc0 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -157,7 +157,9 @@ namespace OpenSim.Grid.UserServer if (null != m_userManager.GetUserProfile(tempfirstname, templastname)) { - m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname); + m_log.ErrorFormat( + "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname); + break; } @@ -166,22 +168,40 @@ namespace OpenSim.Grid.UserServer LLUUID userID = new LLUUID(); try { - userID = - m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); - } catch (Exception ex) + userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); + } + catch (Exception ex) { m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString()); } try { - RestObjectPoster.BeginPostObject(m_userManager._config.InventoryUrl + "CreateInventory/", - userID.UUID); + bool created + = SynchronousRestObjectPoster.BeginPostObject( + "POST", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); + + if (!created) + { + 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 (Exception ex) + catch (System.Net.WebException e) { - m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", ex.ToString()); + m_log.ErrorFormat( + "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}", + m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); } + catch (Exception e) + { + m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e); + } + m_lastCreatedUser = userID; break; } diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index e71a2ccaf4..eb548a57bc 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -310,14 +310,15 @@ namespace OpenSim.Grid.UserServer = SynchronousRestObjectPoster.BeginPostObject>( "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); - // In theory, the user will only ever be missing a root folder in situations where a grid - // which didn't previously run a grid wide inventory server is being transitioned to one - // which does. if (null == folders || folders.Count == 0) { m_log.InfoFormat( "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); + // Although the create user function creates a new agent inventory along with a new user profile, some + // tools are creating the user profile directly in the database without creating the inventory. At + // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already + // exist. bool created = SynchronousRestObjectPoster.BeginPostObject( "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID); @@ -340,6 +341,7 @@ namespace OpenSim.Grid.UserServer LLUUID rootID = LLUUID.Zero; ArrayList AgentInventoryArray = new ArrayList(); Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) { // m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); @@ -356,6 +358,7 @@ namespace OpenSim.Grid.UserServer TempHash["folder_id"] = InvFolder.ID.ToString(); AgentInventoryArray.Add(TempHash); } + return new InventoryData(AgentInventoryArray, rootID); } else