Fixed a few things pertaining to interfacing with the estate service. Specifically, StoreEstateSettings was not being used anywhere; instead EstatSetting.Save was being called, but that method is a trigger to the DB-layer code directly, which, besides being wrong, was making it impossible to replace the service with a remote connector.

Also added more packing/unpacking code.
bullet-2.82
Diva Canto 2014-06-01 10:06:26 -07:00
parent eaf595c008
commit 2ff9ea3f80
10 changed files with 186 additions and 45 deletions

View File

@ -39,6 +39,7 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage;
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
using OpenSim.Region.CoreModules.Scripting.XMLRPC;
using OpenSim.Services.Interfaces;
namespace OpenSim.ApplicationPlugins.LoadRegions
{
@ -130,7 +131,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
createdScenes.Add(scene);
if (changed)
regionsToLoad[i].EstateSettings.Save();
m_openSim.EstateDataService.StoreEstateSettings(regionsToLoad[i].EstateSettings);
}
foreach (IScene scene in createdScenes)

View File

@ -694,7 +694,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
region.EstateSettings.EstateName = (string) requestData["estate_name"];
region.EstateSettings.EstateOwner = userID;
// Persistence does not seem to effect the need to save a new estate
region.EstateSettings.Save();
m_application.EstateDataService.StoreEstateSettings(region.EstateSettings);
if (!m_application.EstateDataService.LinkRegion(region.RegionID, (int) region.EstateSettings.EstateID))
throw new Exception("Failed to join estate.");
@ -724,7 +724,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// If an access specification was provided, use it.
// Otherwise accept the default.
newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, "public", m_publicAccess);
newScene.RegionInfo.EstateSettings.Save();
m_application.EstateDataService.StoreEstateSettings(newScene.RegionInfo.EstateSettings);
// enable voice on newly created region if
// requested by either the XmlRpc request or the
@ -910,7 +910,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
scene.RegionInfo.EstateSettings.PublicAccess =
GetBoolean(requestData,"public", scene.RegionInfo.EstateSettings.PublicAccess);
if (scene.RegionInfo.Persistent)
scene.RegionInfo.EstateSettings.Save();
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
if (requestData.ContainsKey("enable_voice"))
{
@ -1792,7 +1792,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{};
if (scene.RegionInfo.Persistent)
scene.RegionInfo.EstateSettings.Save();
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
m_log.Info("[RADMIN]: Access List Clear Request complete");
}
@ -1838,7 +1838,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
if (scene.RegionInfo.Persistent)
scene.RegionInfo.EstateSettings.Save();
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
}
responseData["added"] = addedUsers;
@ -1887,7 +1887,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
if (scene.RegionInfo.Persistent)
scene.RegionInfo.EstateSettings.Save();
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
}
responseData["removed"] = removedUsers;

View File

@ -25,6 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
namespace OpenSim.Framework
@ -111,5 +115,50 @@ namespace OpenSim.Framework
}
}
public EstateBan() { }
public Dictionary<string, object> ToMap()
{
Dictionary<string, object> map = new Dictionary<string, object>();
PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo p in properties)
map[p.Name] = p.GetValue(this, null);
return map;
}
public EstateBan(Dictionary<string, object> map)
{
foreach (KeyValuePair<string, object> kvp in map)
{
PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
if (p == null)
continue;
object value = p.GetValue(this, null);
if (value is String)
p.SetValue(this, map[p.Name], null);
else if (value is UInt32)
p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
else if (value is Boolean)
p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
else if (value is UUID)
p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
}
}
/// <summary>
/// For debugging
/// </summary>
/// <returns></returns>
public override string ToString()
{
Dictionary<string, object> map = ToMap();
string result = string.Empty;
foreach (KeyValuePair<string, object> kvp in map)
result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value, Environment.NewLine);
return result;
}
}
}

View File

@ -418,17 +418,106 @@ namespace OpenSim.Framework
Dictionary<string, object> map = new Dictionary<string, object>();
PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo p in properties)
map[p.Name] = p.GetValue(this, null);
{
// EstateBans is a complex type, let's treat it as special
if (p.Name == "EstateBans")
continue;
object value = p.GetValue(this, null);
if (value != null)
{
if (p.PropertyType.IsArray) // of UUIDs
{
if (((Array)value).Length > 0)
{
string[] args = new string[((Array)value).Length];
int index = 0;
foreach (object o in (Array)value)
args[index++] = o.ToString();
map[p.Name] = String.Join(",", args);
}
}
else // simple types
map[p.Name] = value;
}
}
// EstateBans are special
Dictionary<string, object> bans = new Dictionary<string, object>();
int i = 0;
foreach (EstateBan ban in EstateBans)
bans["ban" + i++] = ban.ToMap();
map["EstateBans"] = bans;
return map;
}
/// <summary>
/// For debugging
/// </summary>
/// <returns></returns>
public override string ToString()
{
Dictionary<string, object> map = ToMap();
String result = String.Empty;
foreach (KeyValuePair<string, object> kvp in map)
{
if (kvp.Key == "EstateBans")
{
result += "EstateBans:" + Environment.NewLine;
foreach (KeyValuePair<string, object> ban in (Dictionary<string, object>)kvp.Value)
result += ban.Value.ToString();
}
else
result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value.ToString(), Environment.NewLine);
}
return result;
}
public EstateSettings(Dictionary<string, object> map)
{
PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo p in properties)
p.SetValue(this, map[p.Name], null);
foreach (KeyValuePair<string, object> kvp in map)
{
PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
if (p == null)
continue;
// EstateBans is a complex type, let's treat it as special
if (p.Name == "EstateBans")
continue;
if (p.PropertyType.IsArray)
{
string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
UUID[] uuids = new UUID[elements.Length];
int i = 0;
foreach (string e in elements)
uuids[i++] = new UUID(e);
p.SetValue(this, uuids, null);
}
else
{
object value = p.GetValue(this, null);
if (value is String)
p.SetValue(this, map[p.Name], null);
else if (value is UInt32)
p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
else if (value is Boolean)
p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
else if (value is UUID)
p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
}
}
// EstateBans are special
var banData = ((Dictionary<string, object>)map["EstateBans"]).Values;
EstateBan[] bans = new EstateBan[banData.Count];
int b = 0;
foreach (Dictionary<string, object> ban in banData)
bans[b++] = new EstateBan(ban);
PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
bansProperty.SetValue(this, bans, null);
}
}
}

View File

@ -730,7 +730,7 @@ namespace OpenSim
CreateRegion(regInfo, true, out scene);
if (changed)
regInfo.EstateSettings.Save();
m_estateDataService.StoreEstateSettings(regInfo.EstateSettings);
}
/// <summary>

View File

@ -232,13 +232,9 @@ namespace OpenSim
module));
// Load the estate data service
IConfig estateDataConfig = Config.Configs["EstateDataStore"];
if (estateDataConfig == null)
throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
module = Util.GetConfigVarFromSections<string>(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty);
if (String.IsNullOrEmpty(module))
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
if (m_estateDataService == null)
@ -555,7 +551,7 @@ namespace OpenSim
else
{
regionInfo.EstateSettings.EstateOwner = account.PrincipalID;
regionInfo.EstateSettings.Save();
m_estateDataService.StoreEstateSettings(regionInfo.EstateSettings);
}
}
@ -950,7 +946,7 @@ namespace OpenSim
// back to the default. The reloading of estate settings by scene could be eliminated if it
// knows that the passed in settings in RegionInfo are already valid. Also, it might be
// possible to eliminate some additional later saves made by callers of this method.
regInfo.EstateSettings.Save();
EstateDataService.StoreEstateSettings(regInfo.EstateSettings);
return true;
}

View File

@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
else
{
dbSettings.EstateOwner = account.PrincipalID;
dbSettings.Save();
Scene.EstateDataService.StoreEstateSettings(dbSettings);
response = String.Empty;
// make sure there's a log entry to document the change
@ -292,7 +292,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
string oldName = dbSettings.EstateName;
dbSettings.EstateName = newName;
dbSettings.Save();
Scene.EstateDataService.StoreEstateSettings(dbSettings);
response = String.Empty;
// make sure there's a log entry to document the change
@ -367,10 +367,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
else
{
EstateSettings settings = Scene.EstateDataService.CreateNewEstate();
settings.EstateOwner = ownerID;
settings.EstateName = estateName;
settings.Save();
response = String.Empty;
if (settings == null)
response = String.Format("Unable to create estate \"{0}\" at this simulator", estateName);
else
{
settings.EstateOwner = ownerID;
settings.EstateName = estateName;
Scene.EstateDataService.StoreEstateSettings(settings);
response = String.Empty;
}
}
}
return response;
@ -636,13 +641,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddEstateUser(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.AddEstateUser(user);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
@ -669,13 +674,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveEstateUser(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
@ -701,13 +706,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddEstateGroup(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
@ -733,13 +738,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveEstateGroup(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
@ -788,7 +793,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddBan(bitem);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
@ -801,7 +806,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
item.BannedHostIPMask = "0.0.0.0";
Scene.RegionInfo.EstateSettings.AddBan(item);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
@ -864,13 +869,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveBan(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
}
@ -903,13 +908,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.AddEstateManager(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.AddEstateManager(user);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
@ -935,13 +940,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
estateSettings.RemoveEstateManager(user);
estateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(estateSettings);
}
}
}
Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
@ -1415,7 +1420,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
else
Scene.RegionInfo.EstateSettings.DenyMinors = false;
Scene.RegionInfo.EstateSettings.Save();
Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
TriggerEstateInfoChange();
Scene.TriggerEstateSunUpdate();

View File

@ -1246,7 +1246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
World.RegionInfo.EstateSettings.SunPosition = sunHour;
World.RegionInfo.EstateSettings.FixedSun = sunFixed;
World.RegionInfo.EstateSettings.Save();
World.EstateDataService.StoreEstateSettings(World.RegionInfo.EstateSettings);
World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
}

View File

@ -425,7 +425,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
estate.EstateID, admin.Name);
estate.EstateOwner = admin.PrincipalID;
estate.Save();
scene.EstateDataService.StoreEstateSettings(estate);
}
else
{

View File

@ -1835,6 +1835,7 @@
<Reference name="OpenSim.Framework.RegionLoader.Filesystem"/>
<Reference name="OpenSim.Framework.RegionLoader.Web"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="log4net" path="../../../bin/"/>
<Files>