* This allows configuration of the assetset and library control file paths to be other than ./inventory/Libraries.xml and ./assets/AssetSets.xml
* This is controlled via the LibrariesXMLFile and AssetSetsXMLFile configuration settings in [StandAlone] in OpenSim.ini (in standalone)
and via the user and asset config xml files for grid mode
* Thanks to SirKimba for the patch
This commit is contained in:
Justin Clarke Casey
2008-12-29 16:56:48 +00:00
parent 817a10d0aa
commit 266d0fbaae
12 changed files with 87 additions and 42 deletions

View File

@@ -40,6 +40,7 @@ namespace OpenSim.Framework
public string DatabaseConnect = String.Empty;
public string DatabaseProvider = String.Empty;
public uint HttpPort = DefaultHttpPort;
public string AssetSetsLocation = string.Empty;
public AssetConfig(string description, string filename)
{
@@ -58,6 +59,10 @@ namespace OpenSim.Framework
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false);
configMember.addConfigurationOption("assetset_location", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Location of 'AssetSets.xml'",
string.Format(".{0}assets{0}AssetSets.xml", System.IO.Path.DirectorySeparatorChar), false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@@ -70,6 +75,9 @@ namespace OpenSim.Framework
case "database_connect":
DatabaseConnect = (string) configuration_result;
break;
case "assetset_location":
AssetSetsLocation = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
@@ -78,4 +86,4 @@ namespace OpenSim.Framework
return true;
}
}
}
}

View File

@@ -86,12 +86,6 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
}
}
public void ForEachDefaultXmlAsset(Action<AssetBase> action)
{
string assetSetFilename = Path.Combine(Util.assetsDir(), "AssetSets.xml");
ForEachDefaultXmlAsset(assetSetFilename, action);
}
public void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action)
{
@@ -99,16 +93,18 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
if (File.Exists(assetSetFilename))
{
string assetSetPath = "ERROR";
string assetRootPath = "";
try
{
XmlConfigSource source = new XmlConfigSource(assetSetFilename);
assetRootPath = Path.GetFullPath(source.SavePath);
assetRootPath = Path.GetDirectoryName(assetRootPath);
for (int i = 0; i < source.Configs.Count; i++)
{
assetSetPath = source.Configs[i].GetString("file", String.Empty);
LoadXmlAssetSet(Path.Combine(Util.assetsDir(), assetSetPath), assets);
LoadXmlAssetSet(Path.Combine(assetRootPath, assetSetPath), assets);
}
}
catch (XmlException e)
@@ -118,7 +114,7 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
}
else
{
m_log.Error("[ASSETS]: Asset set control file assets/AssetSets.xml does not exist! No assets loaded.");
m_log.ErrorFormat("[ASSETS]: Asset set control file {0} does not exist! No assets loaded.", assetSetFilename);
}
assets.ForEach(action);

View File

@@ -106,11 +106,11 @@ namespace OpenSim.Framework.Communications.Cache
}
}
public virtual void LoadDefaultAssets()
public virtual void LoadDefaultAssets(string pAssetSetsXml)
{
m_log.Info("[ASSET SERVER]: Setting up asset database");
assetLoader.ForEachDefaultXmlAsset(StoreAsset);
assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset);
}
public AssetServerBase()

View File

@@ -52,11 +52,9 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary>
protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
= new Dictionary<UUID, InventoryFolderImpl>();
public LibraryRootFolder()
public LibraryRootFolder(string pLibrariesLocation)
{
m_log.Info("[LIBRARY INVENTORY]: Loading library inventory");
Owner = libOwner;
ID = new UUID("00000112-000f-0000-0000-000100bba000");
Name = "OpenSim Library";
@@ -66,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache
libraryFolders.Add(ID, this);
LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml"));
LoadLibraries(pLibrariesLocation);
}
public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description,
@@ -96,9 +94,7 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="assets"></param>
protected void LoadLibraries(string librariesControlPath)
{
m_log.InfoFormat(
"[LIBRARY INVENTORY]: Loading libraries control file {0}", librariesControlPath);
m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath);
LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
}
@@ -106,17 +102,18 @@ namespace OpenSim.Framework.Communications.Cache
/// Read a library set from config
/// </summary>
/// <param name="config"></param>
protected void ReadLibraryFromConfig(IConfig config)
protected void ReadLibraryFromConfig(IConfig config, string path)
{
string basePath = Path.GetDirectoryName(path);
string foldersPath
= Path.Combine(
Util.inventoryDir(), config.GetString("foldersFile", String.Empty));
basePath, config.GetString("foldersFile", String.Empty));
LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
string itemsPath
= Path.Combine(
Util.inventoryDir(), config.GetString("itemsFile", String.Empty));
basePath, config.GetString("itemsFile", String.Empty));
LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
}
@@ -125,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
/// Read a library inventory folder from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadFolderFromConfig(IConfig config)
private void ReadFolderFromConfig(IConfig config, string path)
{
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
@@ -158,7 +155,7 @@ namespace OpenSim.Framework.Communications.Cache
/// Read a library inventory item metadata from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadItemFromConfig(IConfig config)
private void ReadItemFromConfig(IConfig config, string path)
{
InventoryItemBase item = new InventoryItemBase();
item.Owner = libOwner;
@@ -195,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache
}
}
private delegate void ConfigAction(IConfig config);
private delegate void ConfigAction(IConfig config, string path);
/// <summary>
/// Load the given configuration at a path and perform an action on each Config contained within it
@@ -213,7 +210,7 @@ namespace OpenSim.Framework.Communications.Cache
for (int i = 0; i < source.Configs.Count; i++)
{
action(source.Configs[i]);
action(source.Configs[i], path);
}
}
catch (XmlException e)

View File

@@ -179,5 +179,30 @@ namespace OpenSim.Framework
get { return m_dumpAssetsToFile; }
set { m_dumpAssetsToFile = value; }
}
protected string m_librariesXMLFile;
public string LibrariesXMLFile
{
get
{
return m_librariesXMLFile;
}
set
{
m_librariesXMLFile = value;
}
}
protected string m_assetSetsXMLFile;
public string AssetSetsXMLFile
{
get
{
return m_assetSetsXMLFile;
}
set
{
m_assetSetsXMLFile = value;
}
}
}
}

View File

@@ -31,7 +31,6 @@ namespace OpenSim.Framework
{
public interface IAssetLoader
{
void ForEachDefaultXmlAsset(Action<AssetBase> action);
void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action);
}
}

View File

@@ -47,6 +47,7 @@ namespace OpenSim.Framework
public uint HttpPort = DefaultHttpPort;
public bool HttpSSL = DefaultHttpSSL;
public uint DefaultUserLevel = 0;
public string LibraryXmlfile = "";
private Uri m_inventoryUrl;
@@ -109,6 +110,11 @@ namespace OpenSim.Framework
"Default Inventory Server URI",
"http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/",
false);
configMember.addConfigurationOption("library_location",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Path to library control file",
string.Format(".{0}inventory{0}Libraries.xml", System.IO.Path.DirectorySeparatorChar), false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Data.MySQL.dll", false);
configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
@@ -173,7 +179,10 @@ namespace OpenSim.Framework
case "default_loginLevel":
DefaultUserLevel = (uint)configuration_result;
break;
break;
case "library_location":
LibraryXmlfile = (string)configuration_result;
break;
}
return true;