come up nicer on startup if the opensim.ini section isn't there
parent
4ddc7d66d6
commit
9082316757
|
@ -1,8 +1,6 @@
|
||||||
// ContentManagementModule.cs
|
// ContentManagementModule.cs
|
||||||
// User: bongiojp
|
// User: bongiojp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
@ -18,86 +16,88 @@ using System.Threading;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.ContentManagement
|
namespace OpenSim.Region.Environment.Modules.ContentManagement
|
||||||
{
|
{
|
||||||
public class ContentManagementModule : IRegionModule
|
public class ContentManagementModule : IRegionModule
|
||||||
{
|
{
|
||||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
CMController m_control = null;
|
CMController m_control = null;
|
||||||
CMModel m_model = null;
|
CMModel m_model = null;
|
||||||
CMView m_view = null;
|
CMView m_view = null;
|
||||||
bool initialised = false;
|
bool initialised = false;
|
||||||
bool m_posted = false;
|
bool m_posted = false;
|
||||||
bool m_enabled = true;
|
bool m_enabled = false;
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource source)
|
public void Initialise(Scene scene, IConfigSource source)
|
||||||
{
|
{
|
||||||
string databaseDir = "./";
|
string databaseDir = "./";
|
||||||
string database = "FilesyStemDatabase";
|
string database = "FileSystemDatabase";
|
||||||
int channel = 345;
|
int channel = 345;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!source.Configs["CMS"].GetBoolean("Enabled", false))
|
if (source.Configs["CMS"] == null)
|
||||||
m_enabled = false;
|
return;
|
||||||
|
|
||||||
databaseDir = source.Configs["CMS"].GetString("Directory", databaseDir);
|
m_enabled = source.Configs["CMS"].GetBoolean("Enabled", false);
|
||||||
database = source.Configs["CMS"].GetString("Database", database);
|
databaseDir = source.Configs["CMS"].GetString("Directory", databaseDir);
|
||||||
channel = source.Configs["CMS"].GetInt("Channel", channel);
|
database = source.Configs["CMS"].GetString("Database", database);
|
||||||
if (database != "FileSystemDatabase" && database != "GitDatabase")
|
channel = source.Configs["CMS"].GetInt("Channel", channel);
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[Content Management]: The Database attribute must be defined as either FileSystemDatabase or GitDatabase");
|
|
||||||
m_enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[Content Management]: Exception thrown while reading parameters from configuration file. Message: " + e);
|
|
||||||
m_enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_enabled)
|
if (database != "FileSystemDatabase" && database != "GitDatabase")
|
||||||
{
|
{
|
||||||
m_log.Info("[Content Management]: Content Management System is not Enabled.");
|
m_log.ErrorFormat("[Content Management]: The Database attribute must be defined as either FileSystemDatabase or GitDatabase");
|
||||||
return;
|
m_enabled = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lock(this)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!initialised) //only init once
|
m_log.ErrorFormat("[Content Management]: Exception thrown while reading parameters from configuration file. Message: " + e);
|
||||||
{
|
m_enabled = false;
|
||||||
m_view = new CMView();
|
}
|
||||||
m_model = new CMModel();
|
|
||||||
m_control = new CMController(m_model, m_view, scene, channel);
|
if (!m_enabled)
|
||||||
m_model.Initialise(database);
|
{
|
||||||
m_view.Initialise(m_model);
|
m_log.Info("[Content Management]: Content Management System is not Enabled.");
|
||||||
|
return;
|
||||||
initialised = true;
|
}
|
||||||
m_model.InitialiseDatabase(scene, databaseDir);
|
|
||||||
}
|
lock(this)
|
||||||
else
|
{
|
||||||
{
|
if (!initialised) //only init once
|
||||||
m_model.InitialiseDatabase(scene, databaseDir);
|
{
|
||||||
m_control.RegisterNewRegion(scene);
|
m_view = new CMView();
|
||||||
}
|
m_model = new CMModel();
|
||||||
}
|
m_control = new CMController(m_model, m_view, scene, channel);
|
||||||
}
|
m_model.Initialise(database);
|
||||||
|
m_view.Initialise(m_model);
|
||||||
|
|
||||||
|
initialised = true;
|
||||||
|
m_model.InitialiseDatabase(scene, databaseDir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_model.InitialiseDatabase(scene, databaseDir);
|
||||||
|
m_control.RegisterNewRegion(scene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
{
|
{
|
||||||
if (! m_enabled)
|
if (! m_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock(this)
|
lock(this)
|
||||||
{
|
{
|
||||||
if (!m_posted) //only post once
|
if (!m_posted) //only post once
|
||||||
{
|
{
|
||||||
m_model.PostInitialise();
|
m_model.PostInitialise();
|
||||||
m_posted = true;
|
m_posted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "ContentManagementModule"; }
|
get { return "ContentManagementModule"; }
|
||||||
|
@ -107,5 +107,5 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue