aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Data/Null/NullUserAccountData.cs65
-rw-r--r--OpenSim/Framework/Serialization/External/OspResolver.cs19
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs65
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs6
5 files changed, 89 insertions, 68 deletions
diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs
index ede23fb..ec54dba 100644
--- a/OpenSim/Data/Null/NullUserAccountData.cs
+++ b/OpenSim/Data/Null/NullUserAccountData.cs
@@ -28,6 +28,9 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using System.Text;
33using log4net;
31using OpenMetaverse; 34using OpenMetaverse;
32using OpenSim.Framework; 35using OpenSim.Framework;
33using OpenSim.Data; 36using OpenSim.Data;
@@ -36,12 +39,17 @@ namespace OpenSim.Data.Null
36{ 39{
37 public class NullUserAccountData : IUserAccountData 40 public class NullUserAccountData : IUserAccountData
38 { 41 {
39 private static Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>(); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 private static Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>(); 43
41 private static Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>(); 44 private Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>();
45 private Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>();
46 private Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>();
42 47
43 public NullUserAccountData(string connectionString, string realm) 48 public NullUserAccountData(string connectionString, string realm)
44 { 49 {
50// m_log.DebugFormat(
51// "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]",
52// connectionString, realm);
45 } 53 }
46 54
47 /// <summary> 55 /// <summary>
@@ -54,6 +62,15 @@ namespace OpenSim.Data.Null
54 /// <returns></returns> 62 /// <returns></returns>
55 public UserAccountData[] Get(string[] fields, string[] values) 63 public UserAccountData[] Get(string[] fields, string[] values)
56 { 64 {
65// if (m_log.IsDebugEnabled)
66// {
67// m_log.DebugFormat(
68// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]",
69// string.Join(", ", fields), string.Join(", ", values));
70// }
71
72 UserAccountData[] userAccounts = new UserAccountData[0];
73
57 List<string> fieldsLst = new List<string>(fields); 74 List<string> fieldsLst = new List<string>(fields);
58 if (fieldsLst.Contains("PrincipalID")) 75 if (fieldsLst.Contains("PrincipalID"))
59 { 76 {
@@ -61,41 +78,61 @@ namespace OpenSim.Data.Null
61 UUID id = UUID.Zero; 78 UUID id = UUID.Zero;
62 if (UUID.TryParse(values[i], out id)) 79 if (UUID.TryParse(values[i], out id))
63 if (m_DataByUUID.ContainsKey(id)) 80 if (m_DataByUUID.ContainsKey(id))
64 return new UserAccountData[] { m_DataByUUID[id] }; 81 userAccounts = new UserAccountData[] { m_DataByUUID[id] };
65 } 82 }
66 if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) 83 else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName"))
67 { 84 {
68 int findex = fieldsLst.IndexOf("FirstName"); 85 int findex = fieldsLst.IndexOf("FirstName");
69 int lindex = fieldsLst.IndexOf("LastName"); 86 int lindex = fieldsLst.IndexOf("LastName");
70 if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex])) 87 if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex]))
71 return new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; 88 {
72 } 89 userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] };
73 if (fieldsLst.Contains("Email")) 90 }
91 }
92 else if (fieldsLst.Contains("Email"))
74 { 93 {
75 int i = fieldsLst.IndexOf("Email"); 94 int i = fieldsLst.IndexOf("Email");
76 if (m_DataByEmail.ContainsKey(values[i])) 95 if (m_DataByEmail.ContainsKey(values[i]))
77 return new UserAccountData[] { m_DataByEmail[values[i]] }; 96 userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] };
78 } 97 }
79 98
80 // Fail 99// if (m_log.IsDebugEnabled)
81 return new UserAccountData[0]; 100// {
101// StringBuilder sb = new StringBuilder();
102// foreach (UserAccountData uad in userAccounts)
103// sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID);
104//
105// m_log.DebugFormat(
106// "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb);
107// }
108
109 return userAccounts;
82 } 110 }
83 111
84 public bool Store(UserAccountData data) 112 public bool Store(UserAccountData data)
85 { 113 {
86 if (data == null) 114 if (data == null)
87 return false; 115 return false;
88 116
117 m_log.DebugFormat(
118 "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}",
119 data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode());
120
89 m_DataByUUID[data.PrincipalID] = data; 121 m_DataByUUID[data.PrincipalID] = data;
90 m_DataByName[data.FirstName + " " + data.LastName] = data; 122 m_DataByName[data.FirstName + " " + data.LastName] = data;
91 if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty) 123 if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty)
92 m_DataByEmail[data.Data["Email"]] = data; 124 m_DataByEmail[data.Data["Email"]] = data;
125
126// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count);
93 127
94 return true; 128 return true;
95 } 129 }
96 130
97 public UserAccountData[] GetUsers(UUID scopeID, string query) 131 public UserAccountData[] GetUsers(UUID scopeID, string query)
98 { 132 {
133// m_log.DebugFormat(
134// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query);
135
99 string[] words = query.Split(new char[] { ' ' }); 136 string[] words = query.Split(new char[] { ' ' });
100 137
101 for (int i = 0; i < words.Length; i++) 138 for (int i = 0; i < words.Length; i++)
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
index 7e3dd1b..d31d27c 100644
--- a/OpenSim/Framework/Serialization/External/OspResolver.cs
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -66,6 +66,8 @@ namespace OpenSim.Framework.Serialization
66 UserAccount account = userService.GetUserAccount(UUID.Zero, userId); 66 UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
67 if (account != null) 67 if (account != null)
68 return MakeOspa(account.FirstName, account.LastName); 68 return MakeOspa(account.FirstName, account.LastName);
69// else
70// m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId);
69 71
70 return null; 72 return null;
71 } 73 }
@@ -77,6 +79,8 @@ namespace OpenSim.Framework.Serialization
77 /// <returns></returns> 79 /// <returns></returns>
78 public static string MakeOspa(string firstName, string lastName) 80 public static string MakeOspa(string firstName, string lastName)
79 { 81 {
82// m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName);
83
80 return 84 return
81 OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; 85 OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
82 } 86 }
@@ -97,7 +101,10 @@ namespace OpenSim.Framework.Serialization
97 public static UUID ResolveOspa(string ospa, IUserAccountService userService) 101 public static UUID ResolveOspa(string ospa, IUserAccountService userService)
98 { 102 {
99 if (!ospa.StartsWith(OSPA_PREFIX)) 103 if (!ospa.StartsWith(OSPA_PREFIX))
100 return UUID.Zero; 104 {
105// m_log.DebugFormat("[OSP RESOLVER]: ResolveOspa() got unrecognized format [{0}]", ospa);
106 return UUID.Zero;
107 }
101 108
102// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); 109// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa);
103 110
@@ -161,7 +168,17 @@ namespace OpenSim.Framework.Serialization
161 168
162 UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); 169 UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName);
163 if (account != null) 170 if (account != null)
171 {
172// m_log.DebugFormat(
173// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}",
174// account.PrincipalID, firstName, lastName);
175
164 return account.PrincipalID; 176 return account.PrincipalID;
177 }
178// else
179// {
180// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name);
181// }
165 182
166 // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc 183 // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
167 /* 184 /*
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 6030706..7849d88 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -400,6 +400,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
401 if (UUID.Zero != ospResolvedId) // The user exists in this grid 401 if (UUID.Zero != ospResolvedId) // The user exists in this grid
402 { 402 {
403// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId);
404
403 item.CreatorIdAsUuid = ospResolvedId; 405 item.CreatorIdAsUuid = ospResolvedId;
404 406
405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 407 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 8a84c7a..de95505 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -97,6 +97,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
97 97
98 protected void ConstructDefaultIarBytesForTestLoad() 98 protected void ConstructDefaultIarBytesForTestLoad()
99 { 99 {
100// log4net.Config.XmlConfigurator.Configure();
101
102 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
103 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
104
100 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random()); 105 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
101 106
102 MemoryStream archiveWriteStream = new MemoryStream(); 107 MemoryStream archiveWriteStream = new MemoryStream();
@@ -106,14 +111,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
106 item1.Name = m_item1Name; 111 item1.Name = m_item1Name;
107 item1.AssetID = UUID.Random(); 112 item1.AssetID = UUID.Random();
108 item1.GroupID = UUID.Random(); 113 item1.GroupID = UUID.Random();
109 //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); 114 item1.CreatorIdAsUuid = m_ua2.PrincipalID;
110 //item1.CreatorId = userUuid.ToString();
111 item1.CreatorId = m_ua2.PrincipalID.ToString();
112 item1.Owner = UUID.Zero; 115 item1.Owner = UUID.Zero;
113 116
114 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
115 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
116
117 string item1FileName 117 string item1FileName
118 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 118 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
119 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService)); 119 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
@@ -390,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
390 public void TestLoadIarV0_1ExistingUsers() 390 public void TestLoadIarV0_1ExistingUsers()
391 { 391 {
392 TestHelper.InMethod(); 392 TestHelper.InMethod();
393 //log4net.Config.XmlConfigurator.Configure(); 393// log4net.Config.XmlConfigurator.Configure();
394 394
395 SerialiserModule serialiserModule = new SerialiserModule(); 395 SerialiserModule serialiserModule = new SerialiserModule();
396 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 396 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
@@ -414,9 +414,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
414// Assert.That( 414// Assert.That(
415// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), 415// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
416// "Loaded item non-uuid creator doesn't match original"); 416// "Loaded item non-uuid creator doesn't match original");
417 Assert.That( 417// Assert.That(
418 foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), 418// foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()),
419 "Loaded item non-uuid creator doesn't match original"); 419// "Loaded item non-uuid creator doesn't match original");
420 420
421 Assert.That( 421 Assert.That(
422 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), 422 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID),
@@ -529,64 +529,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
529 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 529 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
530 /// embedded creators do not exist in the system 530 /// embedded creators do not exist in the system
531 /// </summary> 531 /// </summary>
532 ///
533 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
534 /// (as tested in the a later commented out test)
535 /// This test is currently disabled
536 [Test] 532 [Test]
537 public void TestLoadIarV0_1AbsentUsers() 533 public void TestLoadIarV0_1AbsentUsers()
538 { 534 {
539 TestHelper.InMethod(); 535 TestHelper.InMethod();
540 //log4net.Config.XmlConfigurator.Configure(); 536// log4net.Config.XmlConfigurator.Configure();
541
542 string userFirstName = "Charlie";
543 string userLastName = "Chan";
544 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
545 string userItemCreatorFirstName = "Bat";
546 string userItemCreatorLastName = "Man";
547 //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
548
549 string itemName = "b.lsl";
550 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
551
552 MemoryStream archiveWriteStream = new MemoryStream();
553 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
554
555 InventoryItemBase item1 = new InventoryItemBase();
556 item1.Name = itemName;
557 item1.AssetID = UUID.Random();
558 item1.GroupID = UUID.Random();
559 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
560 //item1.CreatorId = userUuid.ToString();
561 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
562 item1.Owner = UUID.Zero;
563 537
564 string item1FileName
565 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
566 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
567 tar.Close();
568
569 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
570 SerialiserModule serialiserModule = new SerialiserModule(); 538 SerialiserModule serialiserModule = new SerialiserModule();
571 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 539 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
572
573 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
574 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 540 Scene scene = SceneSetupHelpers.SetupScene("inventory");
575
576 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 541 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
577 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
578 542
579 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 543 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
544 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "password", m_iarStream);
580 545
581 InventoryItemBase foundItem1 546 InventoryItemBase foundItem1
582 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); 547 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name);
583 548
584 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 549 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
585// Assert.That( 550// Assert.That(
586// foundItem1.CreatorId, Is.EqualTo(userUuid), 551// foundItem1.CreatorId, Is.EqualTo(userUuid),
587// "Loaded item non-uuid creator doesn't match that of the loading user"); 552// "Loaded item non-uuid creator doesn't match that of the loading user");
588 Assert.That( 553 Assert.That(
589 foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), 554 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua1.PrincipalID),
590 "Loaded item uuid creator doesn't match that of the loading user"); 555 "Loaded item uuid creator doesn't match that of the loading user");
591 } 556 }
592 557
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index 5be70bc..08cc7c5 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -304,12 +304,12 @@ namespace OpenSim.Tests.Common.Setup
304 config.Configs["UserAccountService"].Set( 304 config.Configs["UserAccountService"].Set(
305 "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); 305 "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
306 306
307 if (m_userAccountService == null) 307// if (m_userAccountService == null)
308 { 308// {
309 ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector(); 309 ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector();
310 userAccountService.Initialise(config); 310 userAccountService.Initialise(config);
311 m_userAccountService = userAccountService; 311 m_userAccountService = userAccountService;
312 } 312// }
313 313
314 m_userAccountService.AddRegion(testScene); 314 m_userAccountService.AddRegion(testScene);
315 m_userAccountService.RegionLoaded(testScene); 315 m_userAccountService.RegionLoaded(testScene);