Remove CreateUserAccount. Rename SetUserAccount to StoreUserAccount.

Implement the fetch operations fully. Rename one last UserService file to
UserAccountService
slimupdates
Melanie 2009-12-31 01:16:16 +00:00
parent 96f387ce49
commit 3507005d9d
6 changed files with 79 additions and 66 deletions

View File

@ -159,15 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
// Update all updatable fields // Update all updatable fields
// //
public bool SetUserAccount(UserAccount data) public bool StoreUserAccount(UserAccount data)
{ {
return m_UserService.SetUserAccount(data); return m_UserService.StoreUserAccount(data);
}
// Creates a user data record
public bool CreateUserAccount(UserAccount data)
{
return m_UserService.CreateUserAccount(data);
} }
#endregion #endregion

View File

@ -85,10 +85,8 @@ namespace OpenSim.Server.Handlers.UserAccounts
return GetAccount(request); return GetAccount(request);
case "getaccounts": case "getaccounts":
return GetAccounts(request); return GetAccounts(request);
case "createaccount":
return CreateAccount(request);
case "setaccount": case "setaccount":
return SetAccount(request); return StoreAccount(request);
} }
m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method);
} }
@ -174,24 +172,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
return encoding.GetBytes(xmlString); return encoding.GetBytes(xmlString);
} }
byte[] CreateAccount(Dictionary<string, object> request) byte[] StoreAccount(Dictionary<string, object> request)
{
if (!request.ContainsKey("account"))
return FailureResult();
if (request["account"] == null)
return FailureResult();
if (!(request["account"] is Dictionary<string, object>))
return FailureResult();
UserAccount account = new UserAccount((Dictionary<string, object>) request["account"]);
if (m_UserAccountService.CreateUserAccount(account))
return SuccessResult();
return FailureResult();
}
byte[] SetAccount(Dictionary<string, object> request)
{ {
if (!request.ContainsKey("account")) if (!request.ContainsKey("account"))
return FailureResult(); return FailureResult();
@ -202,7 +183,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
UserAccount account = new UserAccount((Dictionary<string, object>)request["account"]); UserAccount account = new UserAccount((Dictionary<string, object>)request["account"]);
if (m_UserAccountService.SetUserAccount(account)) if (m_UserAccountService.StoreUserAccount(account))
return SuccessResult(); return SuccessResult();
return FailureResult(); return FailureResult();

View File

@ -186,7 +186,7 @@ namespace OpenSim.Services.Connectors
return accounts; return accounts;
} }
public bool SetUserAccount(UserAccount data) public bool StoreUserAccount(UserAccount data)
{ {
Dictionary<string, object> sendData = new Dictionary<string, object>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
//sendData["SCOPEID"] = scopeID.ToString(); //sendData["SCOPEID"] = scopeID.ToString();
@ -199,19 +199,6 @@ namespace OpenSim.Services.Connectors
return SendAndGetBoolReply(sendData); return SendAndGetBoolReply(sendData);
} }
public bool CreateUserAccount(UserAccount data)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
//sendData["SCOPEID"] = scopeID.ToString();
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "createaccount";
sendData["account"] = data.ToKeyValuePairs();
return SendAndGetBoolReply(sendData);
}
private UserAccount SendAndGetReply(Dictionary<string, object> sendData) private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
{ {
string reply = string.Empty; string reply = string.Empty;

View File

@ -95,11 +95,9 @@ namespace OpenSim.Services.Interfaces
// //
List<UserAccount> GetUserAccounts(UUID scopeID, string query); List<UserAccount> GetUserAccounts(UUID scopeID, string query);
// Update all updatable fields // Store the data given, wich replaces the sotred data, therefore
// must be complete.
// //
bool SetUserAccount(UserAccount data); bool StoreUserAccount(UserAccount data);
// Creates a user data record
bool CreateUserAccount(UserAccount data);
} }
} }

View File

@ -62,33 +62,85 @@ namespace OpenSim.Services.UserAccountService
if (d.Length < 1) if (d.Length < 1)
return null; return null;
UserAccount u = new UserAccount(); return MakeUserAccount(d[0]);
u.FirstName = d[0].FirstName; }
u.LastName = d[0].LastName;
u.PrincipalID = d[0].PrincipalID;
u.ScopeID = d[0].ScopeID;
u.Email = d[0].Data["Email"].ToString();
u.Created = Convert.ToInt32(d[0].Data["Created"].ToString());
return null; private UserAccount MakeUserAccount(UserAccountData d)
{
UserAccount u = new UserAccount();
u.FirstName = d.FirstName;
u.LastName = d.LastName;
u.PrincipalID = d.PrincipalID;
u.ScopeID = d.ScopeID;
u.Email = d.Data["Email"].ToString();
u.Created = Convert.ToInt32(d.Data["Created"].ToString());
string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '});
u.ServiceURLs = new Dictionary<string, object>();
foreach(string url in URLs)
{
string[] parts = url.Split(new char[] {'='});
if (parts.Length != 2)
continue;
string name = System.Web.HttpUtility.UrlDecode(parts[0]);
string val = System.Web.HttpUtility.UrlDecode(parts[1]);
u.ServiceURLs[name] = val;
}
return u;
} }
public UserAccount GetUserAccount(UUID scopeID, string email) public UserAccount GetUserAccount(UUID scopeID, string email)
{ {
return null; UserAccountData[] d;
if (scopeID != UUID.Zero)
{
d = m_Database.Get(
new string[] {"ScopeID", "Email"},
new string[] {scopeID.ToString(), email});
}
else
{
d = m_Database.Get(
new string[] {"Email"},
new string[] {email});
}
if (d.Length < 1)
return null;
return MakeUserAccount(d[0]);
} }
public UserAccount GetUserAccount(UUID scopeID, UUID userID) public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
{ {
return null; UserAccountData[] d;
if (scopeID != UUID.Zero)
{
d = m_Database.Get(
new string[] {"ScopeID", "PrincipalID"},
new string[] {scopeID.ToString(), principalID.ToString()});
}
else
{
d = m_Database.Get(
new string[] {"PrincipalID"},
new string[] {principalID.ToString()});
}
if (d.Length < 1)
return null;
return MakeUserAccount(d[0]);
} }
public bool SetUserAccount(UserAccount data) public bool StoreUserAccount(UserAccount data)
{
return false;
}
public bool CreateUserAccount(UserAccount data)
{ {
return false; return false;
} }

View File

@ -1052,6 +1052,7 @@
<ReferencePath>../../../bin/</ReferencePath> <ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/> <Reference name="System"/>
<Reference name="System.Web"/>
<Reference name="OpenMetaverseTypes.dll"/> <Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>