29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
35 using OpenSim.Framework;
38 namespace OpenSim.Data.
Null
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
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>();
74 List<string> fieldsLst =
new List<string>(fields);
75 if (fieldsLst.Contains(
"PrincipalID"))
77 int i = fieldsLst.IndexOf(
"PrincipalID");
79 if (UUID.TryParse(values[i], out
id))
80 if (m_DataByUUID.ContainsKey(
id))
83 else if (fieldsLst.Contains(
"FirstName") && fieldsLst.Contains(
"LastName"))
85 int findex = fieldsLst.IndexOf(
"FirstName");
86 int lindex = fieldsLst.IndexOf(
"LastName");
87 if (m_DataByName.ContainsKey(values[findex] +
" " + values[lindex]))
89 userAccounts =
new UserAccountData[] { m_DataByName[values[findex] +
" " + values[lindex]] };
92 else if (fieldsLst.Contains(
"Email"))
94 int i = fieldsLst.IndexOf(
"Email");
95 if (m_DataByEmail.ContainsKey(values[i]))
118 "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}",
119 data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode());
121 m_DataByUUID[data.PrincipalID] = data;
122 m_DataByName[data.FirstName +
" " + data.LastName] = data;
123 if (data.
Data.ContainsKey(
"Email") && data.Data[
"Email"] != null && data.Data[
"Email"] != string.Empty)
124 m_DataByEmail[data.
Data[
"Email"]] = data;
136 string[] words = query.Split(
new char[] {
' ' });
138 for (
int i = 0; i < words.Length; i++)
140 if (words[i].Length < 3)
142 if (i != words.Length - 1)
143 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
144 Array.Resize(ref words, words.Length - 1);
148 if (words.Length == 0)
151 if (words.Length > 2)
154 List<string> lst =
new List<string>(m_DataByName.Keys);
155 if (words.Length == 1)
157 lst = lst.FindAll(delegate(
string s) {
return s.StartsWith(words[0]); });
161 lst = lst.FindAll(delegate(
string s) {
return s.Contains(words[0]) || s.Contains(words[1]); });
164 if (lst == null || (lst != null && lst.Count == 0))
169 foreach (
string key in lst)
170 result[n++] = m_DataByName[
key];
175 public bool Delete(
string field,
string val)
178 if (field.Equals(
"PrincipalID"))
180 UUID uuid = UUID.Zero;
181 if (UUID.TryParse(val, out uuid) && m_DataByUUID.ContainsKey(uuid))
184 m_DataByUUID.Remove(uuid);
187 if (account.
Data.ContainsKey(
"Email") && account.Data[
"Email"] != string.Empty && m_DataByEmail.ContainsKey(account.Data[
"Email"]))
188 m_DataByEmail.Remove(account.Data[
"Email"]);
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
UserAccountData[] Get(string[] fields, string[] values)
Tries to implement the Get [] semantics, but it cuts corners like crazy. Specifically, it relies on the knowledge that the only Gets used are keyed on PrincipalID, Email, and FirstName+LastName.
Dictionary< string, string > Data
UserAccountData[] GetUsers(UUID scopeID, string query)
bool Store(UserAccountData data)
An interface for connecting to the user accounts datastore
NullUserAccountData(string connectionString, string realm)
UserAccountData[] GetUsersWhere(UUID scopeID, string where)
bool Delete(string field, string val)