diff options
author | Justin Clark-Casey (justincc) | 2011-03-09 01:21:31 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-03-09 01:21:31 +0000 |
commit | 8a2360bf815d4d78fcff34a69dec24782494bd2e (patch) | |
tree | 51c8413aa9263831330273dce964421bc0dd8fb5 /OpenSim/Data | |
parent | Make -m shortcut option for --merge on load iar specific. Correct some log m... (diff) | |
download | opensim-SC_OLD-8a2360bf815d4d78fcff34a69dec24782494bd2e.zip opensim-SC_OLD-8a2360bf815d4d78fcff34a69dec24782494bd2e.tar.gz opensim-SC_OLD-8a2360bf815d4d78fcff34a69dec24782494bd2e.tar.bz2 opensim-SC_OLD-8a2360bf815d4d78fcff34a69dec24782494bd2e.tar.xz |
Simplify TestLoadIarV0_1AbsentUsers() to use common IAR test setup. Make static dictionaries on NullUserAccountData instance instead to stop user accounts being carried over between tests
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/Null/NullUserAccountData.cs | 65 |
1 files changed, 51 insertions, 14 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 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
31 | using OpenMetaverse; | 34 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
33 | using OpenSim.Data; | 36 | using 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++) |