Asset server implementation. Again one of these "plumbing" releases, where no real functionality has been introduced, but ground work has been made, enabling the asset server, and preparing the sim server to query the asset server.
Introduced an "IPlugin" interface, which plugins can inherit from.afrisby
parent
a0b1ab2258
commit
1232eb1c58
|
@ -44,16 +44,16 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
private IAssetReceiver _receiver;
|
||||
private BlockingQueue<ARequest> _assetRequests;
|
||||
private Thread _localAssetServerThread;
|
||||
protected IAssetProvider m_plugin;
|
||||
protected IAssetProvider m_assetProviderPlugin;
|
||||
private object syncLock = new object();
|
||||
|
||||
|
||||
public SQLAssetServer()
|
||||
public SQLAssetServer(string pluginName)
|
||||
{
|
||||
System.Console.WriteLine("Starting sqlite asset storage system");
|
||||
_assetRequests = new BlockingQueue<ARequest>();
|
||||
AddPlugin("OpenSim.Framework.Data.SQLite.dll");
|
||||
this.SetUpAssetDatabase();
|
||||
AddPlugin(pluginName);
|
||||
|
||||
SetUpAssetDatabase();
|
||||
|
||||
this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
|
||||
this._localAssetServerThread.IsBackground = true;
|
||||
|
@ -63,7 +63,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
|
||||
public void AddPlugin(string FileName)
|
||||
{
|
||||
//MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName);
|
||||
MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName);
|
||||
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
|
||||
|
||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||
|
@ -75,10 +75,10 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
if (typeInterface != null)
|
||||
{
|
||||
IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
m_plugin = plug;
|
||||
m_plugin.Initialise("AssetStorage.db", "");
|
||||
m_assetProviderPlugin = plug;
|
||||
m_assetProviderPlugin.Initialise();
|
||||
|
||||
//MainLog.Instance.Verbose("AssetStorage: Added IAssetProvider Interface");
|
||||
MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version);
|
||||
}
|
||||
|
||||
typeInterface = null;
|
||||
|
@ -105,8 +105,8 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
m_plugin.UpdateAsset(asset);
|
||||
m_plugin.CommitAssets();
|
||||
m_assetProviderPlugin.UpdateAsset(asset);
|
||||
m_assetProviderPlugin.CommitAssets();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,8 +114,8 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
m_plugin.CreateAsset(asset);
|
||||
m_plugin.CommitAssets();
|
||||
m_assetProviderPlugin.CreateAsset(asset);
|
||||
m_assetProviderPlugin.CommitAssets();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
}
|
||||
public void Close()
|
||||
{
|
||||
m_plugin.CommitAssets();
|
||||
m_assetProviderPlugin.CommitAssets();
|
||||
}
|
||||
|
||||
private void RunRequests()
|
||||
|
@ -140,7 +140,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
AssetBase asset = null;
|
||||
lock (syncLock)
|
||||
{
|
||||
asset = m_plugin.FetchAsset(req.AssetID);
|
||||
asset = m_assetProviderPlugin.FetchAsset(req.AssetID);
|
||||
}
|
||||
if (asset != null)
|
||||
{
|
||||
|
@ -163,67 +163,67 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
|
||||
Image.Name = "Bricks";
|
||||
this.LoadAsset(Image, true, "bricks.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
|
||||
Image.Name = "Plywood";
|
||||
this.LoadAsset(Image, true, "plywood.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
|
||||
Image.Name = "Rocks";
|
||||
this.LoadAsset(Image, true, "rocks.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
|
||||
Image.Name = "Granite";
|
||||
this.LoadAsset(Image, true, "granite.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
|
||||
Image.Name = "Hardwood";
|
||||
this.LoadAsset(Image, true, "hardwood.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
|
||||
Image.Name = "Prim Base Texture";
|
||||
this.LoadAsset(Image, true, "plywood.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
|
||||
Image.Name = "Map Base Texture";
|
||||
this.LoadAsset(Image, true, "map_base.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
|
||||
Image.Name = "Map Texture";
|
||||
this.LoadAsset(Image, true, "map1.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010");
|
||||
Image.Name = "Female Body Texture";
|
||||
this.LoadAsset(Image, true, "femalebody.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011");
|
||||
Image.Name = "Female Bottom Texture";
|
||||
this.LoadAsset(Image, true, "femalebottom.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012");
|
||||
Image.Name = "Female Face Texture";
|
||||
this.LoadAsset(Image, true, "femaleface.jp2");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb");
|
||||
|
@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
Image.Type = 13;
|
||||
Image.InvType = 13;
|
||||
this.LoadAsset(Image, false, "base_skin.dat");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||
|
@ -239,7 +239,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
Image.Type = 13;
|
||||
Image.InvType = 13;
|
||||
this.LoadAsset(Image, false, "base_shape.dat");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110");
|
||||
|
@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
Image.Type = 5;
|
||||
Image.InvType = 18;
|
||||
this.LoadAsset(Image, false, "newshirt.dat");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120");
|
||||
|
@ -255,7 +255,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
Image.Type = 5;
|
||||
Image.InvType = 18;
|
||||
this.LoadAsset(Image, false, "newpants.dat");
|
||||
m_plugin.CreateAsset(Image);
|
||||
m_assetProviderPlugin.CreateAsset(Image);
|
||||
|
||||
string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
|
||||
if (File.Exists(filePath))
|
||||
|
@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
ReadAssetDetails(source);
|
||||
}
|
||||
|
||||
m_plugin.CommitAssets();
|
||||
m_assetProviderPlugin.CommitAssets();
|
||||
}
|
||||
|
||||
protected void ReadAssetDetails(IConfigSource source)
|
||||
|
@ -282,7 +282,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
{
|
||||
MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name);
|
||||
this.LoadAsset(newAsset, false, fileName);
|
||||
m_plugin.CreateAsset(newAsset);
|
||||
m_assetProviderPlugin.CreateAsset(newAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Types;
|
||||
|
||||
namespace OpenSim.Framework.Data.MySQL
|
||||
{
|
||||
class MySQLAssetData : IAssetProvider
|
||||
{
|
||||
MySQLManager _dbConnection;
|
||||
#region IAssetProvider Members
|
||||
|
||||
private void UpgradeAssetsTable(string oldVersion)
|
||||
{
|
||||
// null as the version, indicates that the table didn't exist
|
||||
if (oldVersion == null)
|
||||
{
|
||||
MainLog.Instance.Notice("ASSETS", "Creating new database tables");
|
||||
_dbConnection.ExecuteResourceSql("CreateAssetsTable.sql");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure that the assets related tables exists and are at the latest version
|
||||
/// </summary>
|
||||
private void TestTables()
|
||||
{
|
||||
|
||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||
|
||||
tableList["assets"] = null;
|
||||
_dbConnection.GetTableVersion(tableList);
|
||||
|
||||
UpgradeAssetsTable(tableList["assets"]);
|
||||
|
||||
}
|
||||
|
||||
public AssetBase FetchAsset(LLUUID uuid)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void CreateAsset(AssetBase asset)
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
|
||||
"VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection);
|
||||
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
|
||||
p.Value = asset.FullID.GetBytes();
|
||||
cmd.Parameters.AddWithValue("?name", asset.Name);
|
||||
cmd.Parameters.AddWithValue("?description", asset.Description);
|
||||
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
||||
cmd.Parameters.AddWithValue("?invType", asset.InvType);
|
||||
cmd.Parameters.AddWithValue("?local", asset.Local);
|
||||
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
||||
cmd.Parameters.AddWithValue("?data", asset.Data);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
CreateAsset(asset);
|
||||
}
|
||||
|
||||
public bool ExistsAsset(LLUUID uuid)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All writes are immediately commited to the database, so this is a no-op
|
||||
/// </summary>
|
||||
public void CommitAssets()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
||||
string database = GridDataMySqlFile.ParseFileReadValue("database");
|
||||
string username = GridDataMySqlFile.ParseFileReadValue("username");
|
||||
string password = GridDataMySqlFile.ParseFileReadValue("password");
|
||||
string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
||||
string port = GridDataMySqlFile.ParseFileReadValue("port");
|
||||
|
||||
_dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
|
||||
|
||||
TestTables();
|
||||
}
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return _dbConnection.getVersion(); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "MySQL Asset storage engine"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -28,7 +28,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Types;
|
||||
|
@ -65,41 +64,13 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
}
|
||||
|
||||
#region Test and initialization code
|
||||
/// <summary>
|
||||
/// Extract a named string resource from the embedded resources
|
||||
/// </summary>
|
||||
/// <param name="name">name of embedded resource</param>
|
||||
/// <returns>string contained within the embedded resource</returns>
|
||||
private string getResourceString(string name)
|
||||
{
|
||||
Assembly assem = this.GetType().Assembly;
|
||||
string[] names = assem.GetManifestResourceNames();
|
||||
|
||||
foreach(string s in names)
|
||||
if(s.EndsWith(name))
|
||||
using (Stream resource = assem.GetManifestResourceStream(s))
|
||||
{
|
||||
using (StreamReader resourceReader = new StreamReader(resource))
|
||||
{
|
||||
string resourceString = resourceReader.ReadToEnd();
|
||||
return resourceString;
|
||||
}
|
||||
}
|
||||
throw new Exception(string.Format("Resource '{0}' was not found", name));
|
||||
}
|
||||
|
||||
private void ExecuteResourceSql(MySqlConnection conn, string name)
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand(getResourceString(name), conn);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private void UpgradeFoldersTable(MySqlConnection conn, string oldVersion)
|
||||
private void UpgradeFoldersTable(string oldVersion)
|
||||
{
|
||||
// null as the version, indicates that the table didn't exist
|
||||
if (oldVersion == null)
|
||||
{
|
||||
ExecuteResourceSql(conn, "CreateFoldersTable.sql");
|
||||
database.ExecuteResourceSql("CreateFoldersTable.sql");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -107,15 +78,15 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
if (oldVersion == "Rev. 2")
|
||||
return;
|
||||
|
||||
ExecuteResourceSql(conn, "UpgradeFoldersTableToVersion2.sql");
|
||||
database.ExecuteResourceSql("UpgradeFoldersTableToVersion2.sql");
|
||||
}
|
||||
|
||||
private void UpgradeItemsTable(MySqlConnection conn, string oldVersion)
|
||||
private void UpgradeItemsTable(string oldVersion)
|
||||
{
|
||||
// null as the version, indicates that the table didn't exist
|
||||
if (oldVersion == null)
|
||||
{
|
||||
ExecuteResourceSql(conn, "CreateItemsTable.sql");
|
||||
database.ExecuteResourceSql("CreateItemsTable.sql");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -123,7 +94,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
if (oldVersion == "Rev. 2")
|
||||
return;
|
||||
|
||||
ExecuteResourceSql(conn, "UpgradeItemsTableToVersion2.sql");
|
||||
database.ExecuteResourceSql("UpgradeItemsTableToVersion2.sql");
|
||||
}
|
||||
|
||||
private void TestTables(MySqlConnection conn)
|
||||
|
@ -134,25 +105,10 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
tableList["inventoryfolders"] = null;
|
||||
tableList["inventoryitems"] = null;
|
||||
|
||||
MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='opensim'", conn);
|
||||
MySqlDataReader tables = tablesCmd.ExecuteReader();
|
||||
while (tables.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string tableName = (string)tables["TABLE_NAME"];
|
||||
string comment = (string)tables["TABLE_COMMENT"];
|
||||
tableList[tableName] = comment;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainLog.Instance.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
tables.Close();
|
||||
database.GetTableVersion(tableList);
|
||||
|
||||
UpgradeFoldersTable(conn, tableList["inventoryfolders"]);
|
||||
UpgradeItemsTable(conn, tableList["inventoryitems"]);
|
||||
UpgradeFoldersTable(tableList["inventoryfolders"]);
|
||||
UpgradeItemsTable(tableList["inventoryitems"]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -179,12 +135,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
/// <returns>A string containing the DB provider</returns>
|
||||
public string getVersion()
|
||||
{
|
||||
System.Reflection.Module module = this.GetType().Module;
|
||||
string dllName = module.Assembly.ManifestModule.Name;
|
||||
Version dllVersion = module.Assembly.GetName().Version;
|
||||
|
||||
|
||||
return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
|
||||
return database.getVersion();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -201,7 +152,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
List<InventoryItemBase> items = new List<InventoryItemBase>();
|
||||
|
||||
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection);
|
||||
result.Parameters.Add("?uuid", folderID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
while(reader.Read())
|
||||
|
@ -233,8 +184,8 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
lock (database)
|
||||
{
|
||||
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection);
|
||||
result.Parameters.Add("?uuid", user.ToStringHyphenated());
|
||||
result.Parameters.Add("?zero", LLUUID.Zero.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
|
@ -267,13 +218,9 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
{
|
||||
lock (database)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["?uuid"] = user.ToStringHyphenated();
|
||||
param["?zero"] = LLUUID.Zero.ToStringHyphenated();
|
||||
|
||||
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection);
|
||||
result.Parameters.Add("?uuid", user.ToStringHyphenated());
|
||||
result.Parameters.Add("?zero", LLUUID.Zero.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated());
|
||||
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
|
@ -308,7 +255,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
lock (database)
|
||||
{
|
||||
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection);
|
||||
result.Parameters.Add("?uuid", parentID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
|
@ -378,7 +325,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
|
||||
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
|
||||
result.Parameters.Add("?uuid", itemID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
InventoryItemBase item = null;
|
||||
|
@ -438,7 +385,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
lock (database)
|
||||
{
|
||||
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection);
|
||||
result.Parameters.Add("?uuid", folderID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
reader.Read();
|
||||
|
@ -469,19 +416,19 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
try
|
||||
{
|
||||
MySqlCommand result = new MySqlCommand(sql, database.Connection);
|
||||
result.Parameters.Add("?inventoryID", item.inventoryID.ToStringHyphenated());
|
||||
result.Parameters.Add("?assetID", item.assetID.ToStringHyphenated());
|
||||
result.Parameters.Add("?assetType", item.assetType.ToString());
|
||||
result.Parameters.Add("?parentFolderID", item.parentFolderID.ToStringHyphenated());
|
||||
result.Parameters.Add("?avatarID", item.avatarID.ToStringHyphenated());
|
||||
result.Parameters.Add("?inventoryName", item.inventoryName);
|
||||
result.Parameters.Add("?inventoryDescription", item.inventoryDescription);
|
||||
result.Parameters.Add("?inventoryNextPermissions", item.inventoryNextPermissions.ToString());
|
||||
result.Parameters.Add("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString());
|
||||
result.Parameters.Add("?invType", item.invType);
|
||||
result.Parameters.Add("?creatorID", item.creatorsID.ToStringHyphenated());
|
||||
result.Parameters.Add("?inventoryBasePermissions", item.inventoryBasePermissions);
|
||||
result.Parameters.Add("?inventoryEveryOnePermissions", item.inventoryEveryOnePermissions);
|
||||
result.Parameters.AddWithValue("?inventoryID", item.inventoryID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?assetID", item.assetID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?assetType", item.assetType.ToString());
|
||||
result.Parameters.AddWithValue("?parentFolderID", item.parentFolderID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?avatarID", item.avatarID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?inventoryName", item.inventoryName);
|
||||
result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription);
|
||||
result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString());
|
||||
result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString());
|
||||
result.Parameters.AddWithValue("?invType", item.invType);
|
||||
result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated());
|
||||
result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions);
|
||||
result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.inventoryEveryOnePermissions);
|
||||
result.ExecuteNonQuery();
|
||||
result.Dispose();
|
||||
}
|
||||
|
@ -509,7 +456,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
try
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection);
|
||||
cmd.Parameters.Add("?uuid", itemID.ToStringHyphenated());
|
||||
cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated());
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (MySqlException e)
|
||||
|
@ -529,12 +476,12 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(sql, database.Connection);
|
||||
cmd.Parameters.Add("?folderID", folder.folderID.ToStringHyphenated());
|
||||
cmd.Parameters.Add("?agentID", folder.agentID.ToStringHyphenated());
|
||||
cmd.Parameters.Add("?parentFolderID", folder.parentID.ToStringHyphenated());
|
||||
cmd.Parameters.Add("?folderName", folder.name);
|
||||
cmd.Parameters.Add("?type", (short)folder.type);
|
||||
cmd.Parameters.Add("?version", folder.version);
|
||||
cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToStringHyphenated());
|
||||
cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated());
|
||||
cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated());
|
||||
cmd.Parameters.AddWithValue("?folderName", folder.name);
|
||||
cmd.Parameters.AddWithValue("?type", (short)folder.type);
|
||||
cmd.Parameters.AddWithValue("?version", folder.version);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -590,7 +537,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
try
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
|
||||
cmd.Parameters.Add("?uuid", folderID.ToStringHyphenated());
|
||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (MySqlException e)
|
||||
|
@ -605,7 +552,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
try
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
|
||||
cmd.Parameters.Add("?uuid", folderID.ToStringHyphenated());
|
||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (MySqlException e)
|
||||
|
|
|
@ -26,10 +26,14 @@
|
|||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
|
@ -113,6 +117,88 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the DB provider</returns>
|
||||
public string getVersion()
|
||||
{
|
||||
System.Reflection.Module module = this.GetType().Module;
|
||||
string dllName = module.Assembly.ManifestModule.Name;
|
||||
Version dllVersion = module.Assembly.GetName().Version;
|
||||
|
||||
|
||||
return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extract a named string resource from the embedded resources
|
||||
/// </summary>
|
||||
/// <param name="name">name of embedded resource</param>
|
||||
/// <returns>string contained within the embedded resource</returns>
|
||||
private string getResourceString(string name)
|
||||
{
|
||||
Assembly assem = this.GetType().Assembly;
|
||||
string[] names = assem.GetManifestResourceNames();
|
||||
|
||||
foreach (string s in names)
|
||||
if (s.EndsWith(name))
|
||||
using (Stream resource = assem.GetManifestResourceStream(s))
|
||||
{
|
||||
using (StreamReader resourceReader = new StreamReader(resource))
|
||||
{
|
||||
string resourceString = resourceReader.ReadToEnd();
|
||||
return resourceString;
|
||||
}
|
||||
}
|
||||
throw new Exception(string.Format("Resource '{0}' was not found", name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a SQL statement stored in a resource, as a string
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public void ExecuteResourceSql(string name)
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a list of tables, return the version of the tables, as seen in the database
|
||||
/// </summary>
|
||||
/// <param name="tableList"></param>
|
||||
public void GetTableVersion(Dictionary<string, string> tableList)
|
||||
{
|
||||
lock (dbcon)
|
||||
{
|
||||
MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon);
|
||||
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
||||
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
||||
{
|
||||
while (tables.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string tableName = (string)tables["TABLE_NAME"];
|
||||
string comment = (string)tables["TABLE_COMMENT"];
|
||||
if(tableList.ContainsKey(tableName))
|
||||
tableList[tableName] = comment;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainLog.Instance.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
tables.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// at some time this code should be cleaned up
|
||||
|
||||
/// <summary>
|
||||
/// Runs a query with protection against SQL Injection by using parameterised input.
|
||||
/// </summary>
|
||||
|
@ -127,7 +213,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
dbcommand.CommandText = sql;
|
||||
foreach (KeyValuePair<string, string> param in parameters)
|
||||
{
|
||||
dbcommand.Parameters.Add(param.Key, param.Value);
|
||||
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||
}
|
||||
|
||||
return (IDbCommand)dbcommand;
|
||||
|
@ -161,7 +247,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
dbcommand.CommandText = sql;
|
||||
foreach (KeyValuePair<string, string> param in parameters)
|
||||
{
|
||||
dbcommand.Parameters.Add(param.Key, param.Value);
|
||||
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||
}
|
||||
|
||||
return (IDbCommand)dbcommand;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
CREATE TABLE `assets` (
|
||||
`id` binary(16) NOT NULL,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`description` varchar(64) NOT NULL,
|
||||
`assetType` smallint(5) unsigned NOT NULL,
|
||||
`invType` smallint(5) unsigned NOT NULL,
|
||||
`local` tinyint(1) NOT NULL,
|
||||
`temporary` tinyint(1) NOT NULL,
|
||||
`data` longblob NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1';
|
|
@ -275,5 +275,26 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
return true;
|
||||
}
|
||||
|
||||
#region IPlugin interface
|
||||
public string Version {
|
||||
get
|
||||
{
|
||||
System.Reflection.Module module = this.GetType().Module;
|
||||
string dllName = module.Assembly.ManifestModule.Name;
|
||||
Version dllVersion = module.Assembly.GetName().Version;
|
||||
|
||||
return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
Initialise("AssetStorage.db", "");
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return "SQLite Asset storage engine"; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// UserConfig -- For User Server Configuration
|
||||
/// </summary>
|
||||
public class AssetConfig
|
||||
{
|
||||
public string DefaultStartupMsg = "";
|
||||
|
||||
public string DatabaseProvider = "";
|
||||
|
||||
public uint HttpPort = 8003;
|
||||
|
||||
private ConfigurationMember configMember;
|
||||
|
||||
public AssetConfig(string description, string filename)
|
||||
{
|
||||
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||
configMember.performConfigurationRetrieve();
|
||||
}
|
||||
|
||||
public void loadConfigurationOptions()
|
||||
{
|
||||
configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS", false);
|
||||
|
||||
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||
|
||||
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", "8003", false);
|
||||
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
{
|
||||
switch (configuration_key)
|
||||
{
|
||||
case "default_startup_message":
|
||||
this.DefaultStartupMsg = (string)configuration_result;
|
||||
break;
|
||||
case "database_provider":
|
||||
this.DatabaseProvider = (string)configuration_result;
|
||||
break;
|
||||
case "http_port":
|
||||
HttpPort = (uint)configuration_result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,9 +6,8 @@ using libsecondlife;
|
|||
|
||||
namespace OpenSim.Framework.Interfaces
|
||||
{
|
||||
public interface IAssetProvider
|
||||
public interface IAssetProvider : IPlugin
|
||||
{
|
||||
void Initialise(string dbfile, string dbname);
|
||||
AssetBase FetchAsset(LLUUID uuid);
|
||||
void CreateAsset(AssetBase asset);
|
||||
void UpdateAsset(AssetBase asset);
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface, describes a generic plugin
|
||||
/// </summary>
|
||||
public interface IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the plugin version
|
||||
/// </summary>
|
||||
/// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
|
||||
string Version { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the plugin name
|
||||
/// </summary>
|
||||
/// <returns>Plugin name, eg MySQL User Provider</returns>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the plugin (artificial constructor)
|
||||
/// </summary>
|
||||
void Initialise();
|
||||
}
|
||||
}
|
|
@ -28,14 +28,21 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Db4objects.Db4o;
|
||||
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Configuration;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Utilities;
|
||||
|
||||
using OpenSim.Framework.Communications.Caches;
|
||||
/*
|
||||
using System.Text;
|
||||
using Db4objects.Db4o;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Communications.Caches;
|
||||
*/
|
||||
namespace OpenSim.Grid.AssetServer
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -43,11 +50,11 @@ namespace OpenSim.Grid.AssetServer
|
|||
/// </summary>
|
||||
public class OpenAsset_Main : conscmd_callback
|
||||
{
|
||||
private IObjectContainer db;
|
||||
|
||||
public static OpenAsset_Main assetserver;
|
||||
|
||||
private LogBase m_console;
|
||||
private AssetConfig m_config;
|
||||
private IAssetServer m_assetServer;
|
||||
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
|
@ -82,8 +89,10 @@ namespace OpenSim.Grid.AssetServer
|
|||
|
||||
public void Startup()
|
||||
{
|
||||
m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml")));
|
||||
|
||||
m_console.Verbose("ASSET", "Setting up asset DB");
|
||||
setupDB();
|
||||
setupDB(m_config);
|
||||
|
||||
m_console.Verbose("ASSET", "Starting HTTP process");
|
||||
BaseHttpServer httpServer = new BaseHttpServer(8003);
|
||||
|
@ -97,180 +106,22 @@ namespace OpenSim.Grid.AssetServer
|
|||
|
||||
public byte[] GetAssetData(LLUUID assetID, bool isTexture)
|
||||
{
|
||||
bool found = false;
|
||||
AssetStorage foundAsset = null;
|
||||
|
||||
IObjectSet result = db.Get(new AssetStorage(assetID));
|
||||
if (result.Count > 0)
|
||||
{
|
||||
foundAsset = (AssetStorage)result.Next();
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
return foundAsset.Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setupDB()
|
||||
{
|
||||
string yappath=(Path.Combine(Util.dataDir(),"gridassets.yap"));
|
||||
bool yapfile = File.Exists(yappath);
|
||||
try
|
||||
{
|
||||
db = Db4oFactory.OpenFile(yappath);
|
||||
MainLog.Instance.Verbose("storage", "Main.cs:setupDB() - creation");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
db.Close();
|
||||
MainLog.Instance.Warn("storage", "Main.cs:setupDB() - Exception occured");
|
||||
MainLog.Instance.Warn("storage", e.ToString());
|
||||
}
|
||||
if (!yapfile)
|
||||
{
|
||||
this.LoadDB();
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadDB()
|
||||
public void setupDB(AssetConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Console.WriteLine("setting up Asset database");
|
||||
|
||||
AssetBase Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
|
||||
Image.Name = "Bricks";
|
||||
this.LoadAsset(Image, true, "bricks.jp2");
|
||||
AssetStorage store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
|
||||
Image.Name = "Plywood";
|
||||
this.LoadAsset(Image, true, "plywood.jp2");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
|
||||
Image.Name = "Rocks";
|
||||
this.LoadAsset(Image, true, "rocks.jp2");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
|
||||
Image.Name = "Granite";
|
||||
this.LoadAsset(Image, true, "granite.jp2");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
|
||||
Image.Name = "Hardwood";
|
||||
this.LoadAsset(Image, true, "hardwood.jp2");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
|
||||
Image.Name = "Prim Base Texture";
|
||||
this.LoadAsset(Image, true, "plywood.jp2");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("13371337-1337-1337-1337-133713371337");
|
||||
Image.Name = "Peaches";
|
||||
this.LoadAsset(Image, true, "peaches.jp2");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
|
||||
Image = new AssetBase();
|
||||
Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||
Image.Name = "Shape";
|
||||
this.LoadAsset(Image, false, "base_shape.dat");
|
||||
store = new AssetStorage();
|
||||
store.Data = Image.Data;
|
||||
store.Name = Image.Name;
|
||||
store.UUID = Image.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
m_assetServer = new SQLAssetServer(config.DatabaseProvider);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
MainLog.Instance.Warn("ASSET", "setupDB() - Exception occured");
|
||||
MainLog.Instance.Warn("ASSET", e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAsset(AssetBase info, bool image, string filename)
|
||||
{
|
||||
|
||||
|
||||
string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
|
||||
string fileName = Path.Combine(dataPath, filename);
|
||||
FileInfo fInfo = new FileInfo(fileName);
|
||||
long numBytes = fInfo.Length;
|
||||
FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
||||
byte[] idata = new byte[numBytes];
|
||||
BinaryReader br = new BinaryReader(fStream);
|
||||
idata = br.ReadBytes((int)numBytes);
|
||||
br.Close();
|
||||
fStream.Close();
|
||||
info.Data = idata;
|
||||
//info.loaded=true;
|
||||
}
|
||||
|
||||
public void CreateAsset(LLUUID assetId, byte[] assetData)
|
||||
{
|
||||
AssetBase asset = new AssetBase();
|
||||
asset.Name = "";
|
||||
asset.FullID = assetId;
|
||||
asset.Data = assetData;
|
||||
|
||||
AssetStorage store = new AssetStorage();
|
||||
store.Data = asset.Data;
|
||||
store.Name = asset.Name;
|
||||
store.UUID = asset.FullID;
|
||||
db.Set(store);
|
||||
db.Commit();
|
||||
}
|
||||
|
||||
public void RunCmd(string cmd, string[] cmdparams)
|
||||
{
|
||||
|
@ -339,7 +190,7 @@ namespace OpenSim.Grid.AssetServer
|
|||
|
||||
byte[] assetData = memoryStream.ToArray();
|
||||
|
||||
m_assetManager.CreateAsset(assetId, assetData);
|
||||
// m_assetManager.CreateAsset(assetId, assetData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ namespace OpenSim
|
|||
}
|
||||
else
|
||||
{
|
||||
assetServer = new SQLAssetServer();
|
||||
assetServer = new SQLAssetServer("OpenSim.Framework.Data.SQLite.dll");
|
||||
}
|
||||
assetServer.SetServerInfo(m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
|
||||
m_assetCache = new AssetCache(assetServer);
|
||||
|
|
|
@ -30,7 +30,6 @@ using System.Threading;
|
|||
using System.Collections.Generic;
|
||||
|
||||
using libsecondlife;
|
||||
using libsecondlife.Utilities;
|
||||
|
||||
using Axiom.Math;
|
||||
using Ode.NET;
|
||||
|
|
|
@ -804,6 +804,7 @@
|
|||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="OpenSim.Framework.Servers"/>
|
||||
<Reference name="OpenSim.Framework.Communications"/>
|
||||
<Reference name="libsecondlife.dll"/>
|
||||
<Reference name="Db4objects.Db4o.dll"/>
|
||||
<Reference name="XMLRPC.dll"/>
|
||||
|
|
Loading…
Reference in New Issue