fission UserAccountService.HandleCreateUser() into two methods, one which handles user command parsing and another which actually does the work

soprefactor
Justin Clark-Casey (justincc) 2010-05-28 21:14:15 +01:00
parent 3c0f34bc2b
commit 505cb82dee
4 changed files with 143 additions and 138 deletions

View File

@ -38,7 +38,6 @@ using OpenSim.Framework;
using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Serialization.External;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Communications.Osp;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.World.Serialiser;
@ -541,56 +540,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
/// <summary> /// <summary>
/// Test replication of an archive path to the user's inventory. /// Test replication of an archive path to the user's inventory.
/// </summary> /// </summary>
//[Test] // [Test]
//public void TestReplicateArchivePathToUserInventory() // public void TestReplicateArchivePathToUserInventory()
//{ // {
// TestHelper.InMethod(); // TestHelper.InMethod();
// //log4net.Config.XmlConfigurator.Configure();
// //log4net.Config.XmlConfigurator.Configure(); //
// Scene scene = SceneSetupHelpers.SetupScene("inventory");
// Scene scene = SceneSetupHelpers.SetupScene("inventory"); // CommunicationsManager commsManager = scene.CommsManager;
// CommunicationsManager commsManager = scene.CommsManager; // CachedUserInfo userInfo;
// CachedUserInfo userInfo; //
// lock (this)
// lock (this) // {
// { // // !!! REFACTORING PROBLEM. This needs to be rewritten
// // !!! REFACTORING PROBLEM. This needs to be rewritten // userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
// userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); // Monitor.Wait(this, 60000);
// Monitor.Wait(this, 60000); // }
// } //
// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); //
// Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
// Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); // List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
// List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); //
// string folder1Name = "a";
// string folder1Name = "a"; // string folder2Name = "b";
// string folder2Name = "b"; // string itemName = "c.lsl";
// string itemName = "c.lsl"; //
// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); // string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
// string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); // string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
// string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); //
// string itemArchivePath
// string itemArchivePath // = string.Format(
// = string.Format( // "{0}{1}{2}{3}",
// "{0}{1}{2}{3}", // ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
// ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); //
// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); //
// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null)
// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) // .ReplicateArchivePathToUserInventory(
// .ReplicateArchivePathToUserInventory( // itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID),
// itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), // foldersCreated, nodesLoaded);
// foldersCreated, nodesLoaded); //
// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); // //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
// //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); // InventoryFolderBase folder1
// InventoryFolderBase folder1 // = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a");
// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); // Assert.That(folder1, Is.Not.Null, "Could not find folder a");
// Assert.That(folder1, Is.Not.Null, "Could not find folder a"); // InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
// InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); // Assert.That(folder2, Is.Not.Null, "Could not find folder b");
// Assert.That(folder2, Is.Not.Null, "Could not find folder b"); // }
//}
} }
} }

View File

@ -61,7 +61,7 @@ namespace OpenSim.Server
string connList = serverConfig.GetString("ServiceConnectors", String.Empty); string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
string[] conns = connList.Split(new char[] {',', ' '}); string[] conns = connList.Split(new char[] {',', ' '});
int i = 0; // int i = 0;
foreach (string c in conns) foreach (string c in conns)
{ {
if (c == String.Empty) if (c == String.Empty)

View File

@ -277,8 +277,9 @@ namespace OpenSim.Services.UserAccountService
#endregion #endregion
#region Console commands #region Console commands
/// <summary> /// <summary>
/// Create a new user /// Handle the create user command from the console.
/// </summary> /// </summary>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param> /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
protected void HandleCreateUser(string module, string[] cmdparams) protected void HandleCreateUser(string module, string[] cmdparams)
@ -304,6 +305,18 @@ namespace OpenSim.Services.UserAccountService
email = MainConsole.Instance.CmdPrompt("Email", ""); email = MainConsole.Instance.CmdPrompt("Email", "");
else email = cmdparams[5]; else email = cmdparams[5];
CreateUser(firstName, lastName, password, email);
}
/// <summary>
/// Create a user
/// </summary>
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <param name="password"></param>
/// <param name="email"></param>
public void CreateUser(string firstName, string lastName, string password, string email)
{
UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
if (null == account) if (null == account)
{ {
@ -338,7 +351,6 @@ namespace OpenSim.Services.UserAccountService
else else
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
firstName, lastName); firstName, lastName);
} }
else else
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
@ -350,7 +362,6 @@ namespace OpenSim.Services.UserAccountService
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
firstName, lastName); firstName, lastName);
m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName);
} }
} }
@ -358,7 +369,6 @@ namespace OpenSim.Services.UserAccountService
{ {
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
} }
} }
protected void HandleResetUserPassword(string module, string[] cmdparams) protected void HandleResetUserPassword(string module, string[] cmdparams)

View File

@ -36,85 +36,82 @@ namespace OpenSim.Tests.Common.Setup
/// </summary> /// </summary>
public static class UserProfileTestUtils public static class UserProfileTestUtils
{ {
// REFACTORING PROBLEM // /// <summary>
// This needs to be rewritten // /// Create a test user with a standard inventory
// /// </summary>
///// <summary> // /// <param name="commsManager"></param>
///// Create a test user with a standard inventory // /// <param name="callback">
///// </summary> // /// Callback to invoke when inventory has been loaded. This is required because
///// <param name="commsManager"></param> // /// loading may be asynchronous, even on standalone
///// <param name="callback"> // /// </param>
///// Callback to invoke when inventory has been loaded. This is required because // /// <returns></returns>
///// loading may be asynchronous, even on standalone // public static CachedUserInfo CreateUserWithInventory(
///// </param> // CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
///// <returns></returns> // {
//public static CachedUserInfo CreateUserWithInventory( // UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) // return CreateUserWithInventory(commsManager, userId, callback);
//{ // }
// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); //
// return CreateUserWithInventory(commsManager, userId, callback); // /// <summary>
//} // /// Create a test user with a standard inventory
// /// </summary>
///// <summary> // /// <param name="commsManager"></param>
///// Create a test user with a standard inventory // /// <param name="userId">User ID</param>
///// </summary> // /// <param name="callback">
///// <param name="commsManager"></param> // /// Callback to invoke when inventory has been loaded. This is required because
///// <param name="userId">User ID</param> // /// loading may be asynchronous, even on standalone
///// <param name="callback"> // /// </param>
///// Callback to invoke when inventory has been loaded. This is required because // /// <returns></returns>
///// loading may be asynchronous, even on standalone // public static CachedUserInfo CreateUserWithInventory(
///// </param> // CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
///// <returns></returns> // {
//public static CachedUserInfo CreateUserWithInventory( // return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) // }
//{ //
// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); // /// <summary>
//} // /// Create a test user with a standard inventory
// /// </summary>
///// <summary> // /// <param name="commsManager"></param>
///// Create a test user with a standard inventory // /// <param name="firstName">First name of user</param>
///// </summary> // /// <param name="lastName">Last name of user</param>
///// <param name="commsManager"></param> // /// <param name="userId">User ID</param>
///// <param name="firstName">First name of user</param> // /// <param name="callback">
///// <param name="lastName">Last name of user</param> // /// Callback to invoke when inventory has been loaded. This is required because
///// <param name="userId">User ID</param> // /// loading may be asynchronous, even on standalone
///// <param name="callback"> // /// </param>
///// Callback to invoke when inventory has been loaded. This is required because // /// <returns></returns>
///// loading may be asynchronous, even on standalone // public static CachedUserInfo CreateUserWithInventory(
///// </param> // CommunicationsManager commsManager, string firstName, string lastName,
///// <returns></returns> // UUID userId, OnInventoryReceivedDelegate callback)
//public static CachedUserInfo CreateUserWithInventory( // {
// CommunicationsManager commsManager, string firstName, string lastName, // return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback);
// UUID userId, OnInventoryReceivedDelegate callback) // }
//{ //
// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); // /// <summary>
//} // /// Create a test user with a standard inventory
// /// </summary>
///// <summary> // /// <param name="commsManager"></param>
///// Create a test user with a standard inventory // /// <param name="firstName">First name of user</param>
///// </summary> // /// <param name="lastName">Last name of user</param>
///// <param name="commsManager"></param> // /// <param name="password">Password</param>
///// <param name="firstName">First name of user</param> // /// <param name="userId">User ID</param>
///// <param name="lastName">Last name of user</param> // /// <param name="callback">
///// <param name="password">Password</param> // /// Callback to invoke when inventory has been loaded. This is required because
///// <param name="userId">User ID</param> // /// loading may be asynchronous, even on standalone
///// <param name="callback"> // /// </param>
///// Callback to invoke when inventory has been loaded. This is required because // /// <returns></returns>
///// loading may be asynchronous, even on standalone // public static CachedUserInfo CreateUserWithInventory(
///// </param> // CommunicationsManager commsManager, string firstName, string lastName, string password,
///// <returns></returns> // UUID userId, OnInventoryReceivedDelegate callback)
//public static CachedUserInfo CreateUserWithInventory( // {
// CommunicationsManager commsManager, string firstName, string lastName, string password, // LocalUserServices lus = (LocalUserServices)commsManager.UserService;
// UUID userId, OnInventoryReceivedDelegate callback) // lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId);
//{ //
// LocalUserServices lus = (LocalUserServices)commsManager.UserService; // CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); // userInfo.OnInventoryReceived += callback;
// userInfo.FetchInventory();
// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); //
// userInfo.OnInventoryReceived += callback; // return userInfo;
// userInfo.FetchInventory(); // }
// return userInfo;
//}
} }
} }