From dbee7fcb21a65b8ff7e6143ac7c7bf6a65520540 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:26:09 +0000 Subject: - implement and load NullMetrics module in AssetInventoryServer - update AssetBase de/serialization in AssetInventoryServer --- .../AssetInventoryServer/AssetInventoryServer.cs | 42 +----- .../AssetInventoryServer/Extensions/NullMetrics.cs | 124 ----------------- OpenSim/Grid/AssetInventoryServer/Interfaces.cs | 6 +- .../AssetInventoryServer/Plugins/NullMetrics.cs | 150 +++++++++++++++++++++ .../Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs | 114 +++++----------- .../Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | 58 ++------ .../AssetInventoryServerPlugins.addin.xml | 13 ++ 7 files changed, 207 insertions(+), 300 deletions(-) delete mode 100644 OpenSim/Grid/AssetInventoryServer/Extensions/NullMetrics.cs create mode 100644 OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs create mode 100644 OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs index 8d71f72..d37c63d 100644 --- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs +++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs @@ -106,41 +106,8 @@ namespace OpenSim.Grid.AssetInventoryServer return false; } - //try - //{ - // // Create a reference list for C# extensions compiled at runtime - // List references = new List(); - // references.Add("OpenMetaverseTypes.dll"); - // references.Add("OpenMetaverse.dll"); - // references.Add("OpenMetaverse.StructuredData.dll"); - // references.Add("OpenMetaverse.Http.dll"); - // references.Add("ExtensionLoader.dll"); - // references.Add("AssetServer.exe"); - - // // Get a list of all of the members of AssetServer that are interfaces - // List assignables = ExtensionLoader.GetInterfaces(this); - - // // Load all of the extensions - // ExtensionLoader.LoadAllExtensions( - // Assembly.GetExecutingAssembly(), - // Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), - // extensionList, - // references, - // "AssetServer.*.dll", - // "AssetServer.*.cs", - // this, - // assignables); - //} - //catch (ExtensionException ex) - //{ - // Logger.Log.Error("Interface loading failed, shutting down: " + ex.Message); - // if (ex.InnerException != null) - // Logger.Log.Error(ex.InnerException.Message, ex.InnerException); - // Stop(); - // return false; - //} - StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider") as IAssetStorageProvider; + MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider") as IMetricsProvider; try { @@ -155,13 +122,6 @@ namespace OpenSim.Grid.AssetInventoryServer frontend = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/Frontend"); - // Start all of the extensions - //foreach (IExtension extension in ExtensionLoader.Extensions) - //{ - // Logger.Log.Info("Starting extension " + extension.GetType().Name); - // extension.Start(this); - //} - return true; } diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/NullMetrics.cs b/OpenSim/Grid/AssetInventoryServer/Extensions/NullMetrics.cs deleted file mode 100644 index ba190c1..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Extensions/NullMetrics.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2008 Intel Corporation - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * -- Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * -- Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * -- Neither the name of the Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using ExtensionLoader; -using OpenMetaverse; - -namespace OpenSim.Grid.AssetInventoryServer.Extensions -{ - public class NullMetrics : IExtension, IMetricsProvider - { - AssetInventoryServer server; - - public NullMetrics() - { - } - - public void Start(AssetInventoryServer server) - { - this.server = server; - } - - public void Stop() - { - } - - public void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time) - { - Logger.Log.DebugFormat("[{0}] AssetMetadataFetch(): AssetID: {1}, Response: {2}", extension, assetID, response); - } - - public void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) - { - Logger.Log.DebugFormat("[{0}] AssetDataFetch(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, - dataSize, response); - } - - public void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) - { - Logger.Log.DebugFormat("[{0}] AssetCreate(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, - dataSize, response); - } - - public void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryFetch(): ObjID: {1}, Folder: {2}, OwnerID: {3}, Response: {4}", extension, - objID, folder, owner, response); - } - - public void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryFetchFolderContents(): FolderID: {1}, OwnerID: {2}, Response: {3}", extension, - folderID, owner, response); - } - - public void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryFetchFolderList(): OwnerID: {1}, Response: {2}", extension, - owner, response); - } - - public void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryFetchInventory(): OwnerID: {1}, Response: {2}", extension, - owner, response); - } - - public void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryFetchActiveGestures(): OwnerID: {1}, Response: {2}", extension, - owner, response); - } - - public void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryCreate(): OwnerID: {1}, Response: {2}", extension, - owner, response); - } - - public void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryCreateInventory(): Response: {1}", extension, - response); - } - - public void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryDelete(): OwnerID: {1}, Folder: {2}, Response: {3}", extension, - owner, folder, response); - } - - public void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) - { - Logger.Log.DebugFormat("[{0}] InventoryPurgeFolder(): OwnerID: {1}, FolderID: {2}, Response: {3}", extension, - owner, response); - } - } -} diff --git a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs index 13b0205..67ffa2f 100644 --- a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs +++ b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs @@ -54,12 +54,12 @@ namespace OpenSim.Grid.AssetInventoryServer { private AssetInventoryServer server; - public AssetInventoryServerPluginInitialiser (AssetInventoryServer server) + public AssetInventoryServerPluginInitialiser(AssetInventoryServer server) { this.server = server; } - public override void Initialise (IPlugin plugin) + public override void Initialise(IPlugin plugin) { IAssetInventoryServerPlugin p = plugin as IAssetInventoryServerPlugin; p.Initialise (server); @@ -136,7 +136,7 @@ namespace OpenSim.Grid.AssetInventoryServer bool IsInventoryWriteAuthorized(UUID authToken, Uri owner); } - public interface IMetricsProvider + public interface IMetricsProvider : IAssetInventoryServerPlugin { void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time); void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time); diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs new file mode 100644 index 0000000..86ae5cd --- /dev/null +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2008 Intel Corporation + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * -- Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * -- Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * -- Neither the name of the Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; + +namespace OpenSim.Grid.AssetInventoryServer.Plugins +{ + public class NullMetrics : IMetricsProvider + { + AssetInventoryServer server; + + public NullMetrics() + { + } + + #region IMetricsProvider implementation + + public void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time) + { + Logger.Log.DebugFormat("[{0}] AssetMetadataFetch(): AssetID: {1}, Response: {2}", extension, assetID, response); + } + + public void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) + { + Logger.Log.DebugFormat("[{0}] AssetDataFetch(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, + dataSize, response); + } + + public void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) + { + Logger.Log.DebugFormat("[{0}] AssetCreate(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, + dataSize, response); + } + + public void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryFetch(): ObjID: {1}, Folder: {2}, OwnerID: {3}, Response: {4}", extension, + objID, folder, owner, response); + } + + public void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryFetchFolderContents(): FolderID: {1}, OwnerID: {2}, Response: {3}", extension, + folderID, owner, response); + } + + public void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryFetchFolderList(): OwnerID: {1}, Response: {2}", extension, + owner, response); + } + + public void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryFetchInventory(): OwnerID: {1}, Response: {2}", extension, + owner, response); + } + + public void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryFetchActiveGestures(): OwnerID: {1}, Response: {2}", extension, + owner, response); + } + + public void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryCreate(): OwnerID: {1}, Response: {2}", extension, + owner, response); + } + + public void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryCreateInventory(): Response: {1}", extension, + response); + } + + public void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryDelete(): OwnerID: {1}, Folder: {2}, Response: {3}", extension, + owner, folder, response); + } + + public void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) + { + Logger.Log.DebugFormat("[{0}] InventoryPurgeFolder(): OwnerID: {1}, FolderID: {2}, Response: {3}", extension, + owner, response); + } + + #endregion IMetricsProvider implementation + + #region IPlugin implementation + + public void Initialise(AssetInventoryServer server) + { + this.server = server; + } + + /// + /// Initialises metrics interface + /// + public void Initialise() + { + this.server = null; + } + + public void Dispose() + { + } + + public string Version + { + // TODO: this should be something meaningful and not hardcoded? + get { return "0.1"; } + } + + public string Name + { + get { return "AssetInventoryServer Null Metrics"; } + } + + #endregion IPlugin implementation + } +} diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs index 1abd3f5..0326771 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs @@ -31,7 +31,9 @@ using System; using System.Collections.Generic; using System.Net; using System.IO; +using System.Text; using System.Xml; +using System.Xml.Serialization; using ExtensionLoader; using OpenMetaverse; using HttpServer; @@ -100,52 +102,29 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins if ((dataResponse = server.StorageProvider.TryFetchDataMetadata(assetID, out metadata, out assetData)) == BackendResponse.Success) { - MemoryStream stream = new MemoryStream(); - - XmlWriterSettings settings = new XmlWriterSettings(); - settings.Indent = true; - XmlWriter writer = XmlWriter.Create(stream, settings); - - writer.WriteStartDocument(); - writer.WriteStartElement("AssetBase"); - writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); - writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema"); - writer.WriteStartElement("FullID"); - writer.WriteStartElement("Guid"); - writer.WriteString(assetID.ToString()); - writer.WriteEndElement(); - writer.WriteEndElement(); - writer.WriteStartElement("ID"); - writer.WriteString(assetID.ToString()); - writer.WriteEndElement(); - writer.WriteStartElement("Data"); - writer.WriteBase64(assetData, 0, assetData.Length); - writer.WriteEndElement(); - writer.WriteStartElement("Type"); - writer.WriteValue(Utils.ContentTypeToSLAssetType(metadata.ContentType)); - writer.WriteEndElement(); - writer.WriteStartElement("Name"); - writer.WriteString(metadata.Name); - writer.WriteEndElement(); - writer.WriteStartElement("Description"); - writer.WriteString(metadata.Description); - writer.WriteEndElement(); - writer.WriteStartElement("Local"); - writer.WriteValue(false); - writer.WriteEndElement(); - writer.WriteStartElement("Temporary"); - writer.WriteValue(metadata.Temporary); - writer.WriteEndElement(); - writer.WriteEndElement(); - writer.WriteEndDocument(); - - writer.Flush(); - byte[] buffer = stream.GetBuffer(); + AssetBase asset = new AssetBase(); + asset.Data = assetData; + asset.Metadata.FullID = metadata.ID; + asset.Metadata.Name = metadata.Name; + asset.Metadata.Description = metadata.Description; + asset.Metadata.CreationDate = metadata.CreationDate; + asset.Metadata.Type = (sbyte) Utils.ContentTypeToSLAssetType(metadata.ContentType); + asset.Metadata.Local = false; + asset.Metadata.Temporary = metadata.Temporary; + + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + MemoryStream ms = new MemoryStream(); + XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); + xs.Serialize(xw, asset); + xw.Flush(); + + ms.Seek(0, SeekOrigin.Begin); + byte[] buffer = ms.GetBuffer(); response.Status = HttpStatusCode.OK; response.ContentType = "application/xml"; - response.ContentLength = stream.Length; - response.Body.Write(buffer, 0, (int)stream.Length); + response.ContentLength = ms.Length; + response.Body.Write(buffer, 0, (int) ms.Length); response.Body.Flush(); } else @@ -164,55 +143,26 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins bool AssetPostHandler(IHttpClientContext client, IHttpRequest request, IHttpResponse response) { - byte[] assetData = null; Metadata metadata = new Metadata(); Logger.Log.Debug("Handling OpenSim asset upload"); try { - using (XmlReader reader = XmlReader.Create(request.Body)) - { - reader.MoveToContent(); - reader.ReadStartElement("AssetBase"); - - reader.ReadStartElement("FullID"); - UUID.TryParse(reader.ReadElementContentAsString("Guid", String.Empty), out metadata.ID); - reader.ReadEndElement(); - reader.ReadStartElement("ID"); - reader.Skip(); - reader.ReadEndElement(); - - // HACK: Broken on Mono. https://bugzilla.novell.com/show_bug.cgi?id=464229 - //int readBytes = 0; - //byte[] buffer = new byte[1024]; - //MemoryStream stream = new MemoryStream(); - //BinaryWriter writer = new BinaryWriter(stream); - //while ((readBytes = reader.ReadElementContentAsBase64(buffer, 0, buffer.Length)) > 0) - // writer.Write(buffer, 0, readBytes); - //writer.Flush(); - //assetData = stream.GetBuffer(); - //Array.Resize(ref assetData, (int)stream.Length); - - assetData = Convert.FromBase64String(reader.ReadElementContentAsString()); - - int type; - Int32.TryParse(reader.ReadElementContentAsString("Type", String.Empty), out type); - metadata.ContentType = Utils.SLAssetTypeToContentType(type); - metadata.Name = reader.ReadElementContentAsString("Name", String.Empty); - metadata.Description = reader.ReadElementContentAsString("Description", String.Empty); - Boolean.TryParse(reader.ReadElementContentAsString("Local", String.Empty), out metadata.Temporary); - Boolean.TryParse(reader.ReadElementContentAsString("Temporary", String.Empty), out metadata.Temporary); - - reader.ReadEndElement(); - } + AssetBase asset = (AssetBase) new XmlSerializer(typeof (AssetBase)).Deserialize(request.Body); - if (assetData != null && assetData.Length > 0) + if (asset.Data != null && asset.Data.Length > 0) { - metadata.SHA1 = OpenMetaverse.Utils.SHA1(assetData); + metadata.ID = asset.Metadata.FullID; + metadata.ContentType = Utils.SLAssetTypeToContentType((int) asset.Metadata.Type); + metadata.Name = asset.Metadata.Name; + metadata.Description = asset.Metadata.Description; + metadata.Temporary = asset.Metadata.Temporary; + + metadata.SHA1 = OpenMetaverse.Utils.SHA1(asset.Data); metadata.CreationDate = DateTime.Now; - BackendResponse storageResponse = server.StorageProvider.TryCreateAsset(metadata, assetData); + BackendResponse storageResponse = server.StorageProvider.TryCreateAsset(metadata, asset.Data); if (storageResponse == BackendResponse.Success) response.Status = HttpStatusCode.Created; diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs index 40959a4..37dd241 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs @@ -145,66 +145,24 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins assetData = null; //BackendResponse ret; - AssetBase asset_base = m_assetProvider.FetchAsset(assetID); + AssetBase asset = m_assetProvider.FetchAsset(assetID); - if (asset_base != null) + if (asset != null) { metadata = new Metadata(); + metadata.ID = asset.Metadata.FullID; metadata.CreationDate = OpenMetaverse.Utils.Epoch; metadata.SHA1 = null; - metadata.Name = asset_base.Name; - metadata.Description = asset_base.Description; - metadata.ContentType = Utils.SLAssetTypeToContentType(asset_base.Type); - metadata.Temporary = asset_base.Temporary; + metadata.Name = asset.Metadata.Name; + metadata.Description = asset.Metadata.Description; + metadata.ContentType = Utils.SLAssetTypeToContentType(asset.Metadata.Type); + metadata.Temporary = asset.Metadata.Temporary; - assetData = asset_base.Data; + assetData = asset.Data; } else return BackendResponse.NotFound; return BackendResponse.Success; - - //using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) - //{ - // IDataReader reader; - - // try - // { - // dbConnection.Open(); - - // IDbCommand command = dbConnection.CreateCommand(); - // command.CommandText = String.Format("SELECT name,description,assetType,temporary,data FROM assets WHERE id='{0}'", assetID.ToString()); - // reader = command.ExecuteReader(); - - // if (reader.Read()) - // { - // metadata = new Metadata(); - // metadata.CreationDate = OpenMetaverse.Utils.Epoch; - // metadata.SHA1 = null; - // metadata.ID = assetID; - // metadata.Name = reader.GetString(0); - // metadata.Description = reader.GetString(1); - // metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); - // metadata.Temporary = reader.GetBoolean(3); - - // assetData = (byte[])reader.GetValue(4); - - // ret = BackendResponse.Success; - // } - // else - // { - // ret = BackendResponse.NotFound; - // } - // } - // catch (MySqlException ex) - // { - // Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); - // ret = BackendResponse.Failure; - // } - //} - - //server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); - //server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); - //return ret; } public BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData, out UUID assetID) diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml new file mode 100644 index 0000000..bca7ee1 --- /dev/null +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.1