From 505cb82dee27fc1b681fd7c4b6f904ef18315995 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 28 May 2010 21:14:15 +0100
Subject: fission UserAccountService.HandleCreateUser() into two methods, one
which handles user command parsing and another which actually does the work
---
.../Archiver/Tests/InventoryArchiverTests.cs | 102 +++++++------
OpenSim/Server/ServerMain.cs | 2 +-
.../UserAccountService/UserAccountService.cs | 18 ++-
OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | 159 ++++++++++-----------
4 files changed, 143 insertions(+), 138 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 9c95e78..e434e46 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -38,7 +38,6 @@ using OpenSim.Framework;
using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External;
using OpenSim.Framework.Communications;
-
using OpenSim.Framework.Communications.Osp;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using OpenSim.Region.CoreModules.World.Serialiser;
@@ -541,56 +540,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
///
/// Test replication of an archive path to the user's inventory.
///
- //[Test]
- //public void TestReplicateArchivePathToUserInventory()
- //{
- // TestHelper.InMethod();
-
- // //log4net.Config.XmlConfigurator.Configure();
-
- // Scene scene = SceneSetupHelpers.SetupScene("inventory");
- // CommunicationsManager commsManager = scene.CommsManager;
- // CachedUserInfo userInfo;
-
- // lock (this)
- // {
- // // !!! REFACTORING PROBLEM. This needs to be rewritten
- // userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
- // Monitor.Wait(this, 60000);
- // }
-
- // //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
-
- // Dictionary foldersCreated = new Dictionary();
- // List nodesLoaded = new List();
-
- // string folder1Name = "a";
- // string folder2Name = "b";
- // string itemName = "c.lsl";
-
- // string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
- // string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
- // string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
-
- // string itemArchivePath
- // = string.Format(
- // "{0}{1}{2}{3}",
- // ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
-
- // //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
-
- // new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null)
- // .ReplicateArchivePathToUserInventory(
- // itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID),
- // foldersCreated, nodesLoaded);
-
- // //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
- // //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
- // InventoryFolderBase folder1
- // = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a");
- // Assert.That(folder1, Is.Not.Null, "Could not find folder a");
- // InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
- // Assert.That(folder2, Is.Not.Null, "Could not find folder b");
- //}
+// [Test]
+// public void TestReplicateArchivePathToUserInventory()
+// {
+// TestHelper.InMethod();
+// //log4net.Config.XmlConfigurator.Configure();
+//
+// Scene scene = SceneSetupHelpers.SetupScene("inventory");
+// CommunicationsManager commsManager = scene.CommsManager;
+// CachedUserInfo userInfo;
+//
+// lock (this)
+// {
+// // !!! REFACTORING PROBLEM. This needs to be rewritten
+// userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
+// Monitor.Wait(this, 60000);
+// }
+//
+// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
+//
+// Dictionary foldersCreated = new Dictionary();
+// List nodesLoaded = new List();
+//
+// string folder1Name = "a";
+// string folder2Name = "b";
+// string itemName = "c.lsl";
+//
+// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
+// string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
+// string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
+//
+// string itemArchivePath
+// = string.Format(
+// "{0}{1}{2}{3}",
+// ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
+//
+// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
+//
+// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null)
+// .ReplicateArchivePathToUserInventory(
+// itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID),
+// foldersCreated, nodesLoaded);
+//
+// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
+// //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
+// InventoryFolderBase folder1
+// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a");
+// Assert.That(folder1, Is.Not.Null, "Could not find folder a");
+// InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
+// Assert.That(folder2, Is.Not.Null, "Could not find folder b");
+// }
}
}
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index d3e65a4..9503c4c 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Server
string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
string[] conns = connList.Split(new char[] {',', ' '});
- int i = 0;
+// int i = 0;
foreach (string c in conns)
{
if (c == String.Empty)
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 6923293..3f1744d 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -277,8 +277,9 @@ namespace OpenSim.Services.UserAccountService
#endregion
#region Console commands
+
///
- /// Create a new user
+ /// Handle the create user command from the console.
///
/// string array with parameters: firstname, lastname, password, locationX, locationY, email
protected void HandleCreateUser(string module, string[] cmdparams)
@@ -304,6 +305,18 @@ namespace OpenSim.Services.UserAccountService
email = MainConsole.Instance.CmdPrompt("Email", "");
else email = cmdparams[5];
+ CreateUser(firstName, lastName, password, email);
+ }
+
+ ///
+ /// Create a user
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void CreateUser(string firstName, string lastName, string password, string email)
+ {
UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
if (null == account)
{
@@ -338,7 +351,6 @@ namespace OpenSim.Services.UserAccountService
else
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
firstName, lastName);
-
}
else
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}.",
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);
}
-
}
protected void HandleResetUserPassword(string module, string[] cmdparams)
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index cd61fa6..2b14d97 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -36,85 +36,82 @@ namespace OpenSim.Tests.Common.Setup
///
public static class UserProfileTestUtils
{
- // REFACTORING PROBLEM
- // This needs to be rewritten
-
- /////
- ///// Create a test user with a standard inventory
- /////
- /////
- /////
- ///// Callback to invoke when inventory has been loaded. This is required because
- ///// loading may be asynchronous, even on standalone
- /////
- /////
- //public static CachedUserInfo CreateUserWithInventory(
- // CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
- //{
- // UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
- // return CreateUserWithInventory(commsManager, userId, callback);
- //}
-
- /////
- ///// Create a test user with a standard inventory
- /////
- /////
- ///// User ID
- /////
- ///// Callback to invoke when inventory has been loaded. This is required because
- ///// loading may be asynchronous, even on standalone
- /////
- /////
- //public static CachedUserInfo CreateUserWithInventory(
- // CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
- //{
- // return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
- //}
-
- /////
- ///// Create a test user with a standard inventory
- /////
- /////
- ///// First name of user
- ///// Last name of user
- ///// User ID
- /////
- ///// Callback to invoke when inventory has been loaded. This is required because
- ///// loading may be asynchronous, even on standalone
- /////
- /////
- //public static CachedUserInfo CreateUserWithInventory(
- // CommunicationsManager commsManager, string firstName, string lastName,
- // UUID userId, OnInventoryReceivedDelegate callback)
- //{
- // return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback);
- //}
-
- /////
- ///// Create a test user with a standard inventory
- /////
- /////
- ///// First name of user
- ///// Last name of user
- ///// Password
- ///// User ID
- /////
- ///// Callback to invoke when inventory has been loaded. This is required because
- ///// loading may be asynchronous, even on standalone
- /////
- /////
- //public static CachedUserInfo CreateUserWithInventory(
- // CommunicationsManager commsManager, string firstName, string lastName, string password,
- // UUID userId, OnInventoryReceivedDelegate callback)
- //{
- // LocalUserServices lus = (LocalUserServices)commsManager.UserService;
- // lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId);
-
- // CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
- // userInfo.OnInventoryReceived += callback;
- // userInfo.FetchInventory();
-
- // return userInfo;
- //}
+// ///
+// /// Create a test user with a standard inventory
+// ///
+// ///
+// ///
+// /// Callback to invoke when inventory has been loaded. This is required because
+// /// loading may be asynchronous, even on standalone
+// ///
+// ///
+// public static CachedUserInfo CreateUserWithInventory(
+// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
+// {
+// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
+// return CreateUserWithInventory(commsManager, userId, callback);
+// }
+//
+// ///
+// /// Create a test user with a standard inventory
+// ///
+// ///
+// /// User ID
+// ///
+// /// Callback to invoke when inventory has been loaded. This is required because
+// /// loading may be asynchronous, even on standalone
+// ///
+// ///
+// public static CachedUserInfo CreateUserWithInventory(
+// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
+// {
+// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
+// }
+//
+// ///
+// /// Create a test user with a standard inventory
+// ///
+// ///
+// /// First name of user
+// /// Last name of user
+// /// User ID
+// ///
+// /// Callback to invoke when inventory has been loaded. This is required because
+// /// loading may be asynchronous, even on standalone
+// ///
+// ///
+// public static CachedUserInfo CreateUserWithInventory(
+// CommunicationsManager commsManager, string firstName, string lastName,
+// UUID userId, OnInventoryReceivedDelegate callback)
+// {
+// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback);
+// }
+//
+// ///
+// /// Create a test user with a standard inventory
+// ///
+// ///
+// /// First name of user
+// /// Last name of user
+// /// Password
+// /// User ID
+// ///
+// /// Callback to invoke when inventory has been loaded. This is required because
+// /// loading may be asynchronous, even on standalone
+// ///
+// ///
+// public static CachedUserInfo CreateUserWithInventory(
+// CommunicationsManager commsManager, string firstName, string lastName, string password,
+// UUID userId, OnInventoryReceivedDelegate callback)
+// {
+// LocalUserServices lus = (LocalUserServices)commsManager.UserService;
+// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId);
+//
+// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
+// userInfo.OnInventoryReceived += callback;
+// userInfo.FetchInventory();
+//
+// return userInfo;
+// }
}
-}
+}
\ No newline at end of file
--
cgit v1.1