diff options
-rw-r--r-- | OpenSim/Data/AssetDataBase.cs | 3 | ||||
-rw-r--r-- | OpenSim/Data/IAssetData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 36 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAssetData.cs | 51 | ||||
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateAssetData.cs | 15 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAssetData.cs | 50 | ||||
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs | 185 | ||||
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | 48 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs | 2 |
9 files changed, 256 insertions, 136 deletions
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index 2cdbbe1..d699f17 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | 31 | ||
@@ -37,6 +38,8 @@ namespace OpenSim.Data | |||
37 | public abstract void UpdateAsset(AssetBase asset); | 38 | public abstract void UpdateAsset(AssetBase asset); |
38 | public abstract bool ExistsAsset(UUID uuid); | 39 | public abstract bool ExistsAsset(UUID uuid); |
39 | 40 | ||
41 | public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count); | ||
42 | |||
40 | public abstract string Version { get; } | 43 | public abstract string Version { get; } |
41 | public abstract string Name { get; } | 44 | public abstract string Name { get; } |
42 | public abstract void Initialise(string connect); | 45 | public abstract void Initialise(string connect); |
diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs index 47e25f3..ddbc10f 100644 --- a/OpenSim/Data/IAssetData.cs +++ b/OpenSim/Data/IAssetData.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | 31 | ||
@@ -36,6 +37,7 @@ namespace OpenSim.Data | |||
36 | void CreateAsset(AssetBase asset); | 37 | void CreateAsset(AssetBase asset); |
37 | void UpdateAsset(AssetBase asset); | 38 | void UpdateAsset(AssetBase asset); |
38 | bool ExistsAsset(UUID uuid); | 39 | bool ExistsAsset(UUID uuid); |
40 | List<AssetMetadata> FetchAssetMetadataSet(int start, int count); | ||
39 | void Initialise(string connect); | 41 | void Initialise(string connect); |
40 | } | 42 | } |
41 | 43 | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 61db8f5..edacf08 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using log4net; | 33 | using log4net; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -245,6 +246,41 @@ namespace OpenSim.Data.MSSQL | |||
245 | return false; | 246 | return false; |
246 | } | 247 | } |
247 | 248 | ||
249 | /// <summary> | ||
250 | /// Returns a list of AssetMetadata objects. The list is a subset of | ||
251 | /// the entire data set offset by <paramref name="start" /> containing | ||
252 | /// <paramref name="count" /> elements. | ||
253 | /// </summary> | ||
254 | /// <param name="start">The number of results to discard from the total data set.</param> | ||
255 | /// <param name="count">The number of rows the returned list should contain.</param> | ||
256 | /// <returns>A list of AssetMetadata objects.</returns> | ||
257 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | ||
258 | { | ||
259 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | ||
260 | |||
261 | using (AutoClosingSqlCommand command = database.Query("SELECT name,description,assetType,temporary,id FROM assets LIMIT @start, @count")) | ||
262 | { | ||
263 | command.Parameters.Add(database.CreateParameter("start", start)); | ||
264 | command.Parameters.Add(database.CreateParameter("count", count)); | ||
265 | |||
266 | using (IDataReader reader = command.ExecuteReader()) | ||
267 | { | ||
268 | while (reader.Read()) | ||
269 | { | ||
270 | AssetMetadata metadata = new AssetMetadata(); | ||
271 | // Region Main | ||
272 | metadata.FullID = new UUID((Guid)reader["id"]); | ||
273 | metadata.Name = (string)reader["name"]; | ||
274 | metadata.Description = (string)reader["description"]; | ||
275 | metadata.Type = Convert.ToSByte(reader["assetType"]); | ||
276 | metadata.Temporary = Convert.ToBoolean(reader["temporary"]); | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | return retList; | ||
282 | } | ||
283 | |||
248 | #endregion | 284 | #endregion |
249 | } | 285 | } |
250 | } | 286 | } |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 2211d4c..466f5db 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
31 | using log4net; | 32 | using log4net; |
32 | using MySql.Data.MySqlClient; | 33 | using MySql.Data.MySqlClient; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
@@ -311,6 +312,56 @@ namespace OpenSim.Data.MySQL | |||
311 | return assetExists; | 312 | return assetExists; |
312 | } | 313 | } |
313 | 314 | ||
315 | /// <summary> | ||
316 | /// Returns a list of AssetMetadata objects. The list is a subset of | ||
317 | /// the entire data set offset by <paramref name="start" /> containing | ||
318 | /// <paramref name="count" /> elements. | ||
319 | /// </summary> | ||
320 | /// <param name="start">The number of results to discard from the total data set.</param> | ||
321 | /// <param name="count">The number of rows the returned list should contain.</param> | ||
322 | /// <returns>A list of AssetMetadata objects.</returns> | ||
323 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | ||
324 | { | ||
325 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | ||
326 | |||
327 | lock (_dbConnection) | ||
328 | { | ||
329 | _dbConnection.CheckConnection(); | ||
330 | |||
331 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection); | ||
332 | cmd.Parameters.AddWithValue("?start", start); | ||
333 | cmd.Parameters.AddWithValue("?count", count); | ||
334 | |||
335 | try | ||
336 | { | ||
337 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
338 | { | ||
339 | while (dbReader.Read()) | ||
340 | { | ||
341 | AssetMetadata metadata = new AssetMetadata(); | ||
342 | metadata.Name = (string) dbReader["name"]; | ||
343 | metadata.Description = (string) dbReader["description"]; | ||
344 | metadata.Type = (sbyte) dbReader["assetType"]; | ||
345 | metadata.Temporary = (bool) dbReader["temporary"]; // Not sure if this is correct. | ||
346 | metadata.FullID = new UUID((string) dbReader["id"]); | ||
347 | |||
348 | // Current SHA1s are not stored/computed. | ||
349 | metadata.SHA1 = new byte[] {}; | ||
350 | |||
351 | retList.Add(metadata); | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | catch (Exception e) | ||
356 | { | ||
357 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection"); | ||
358 | _dbConnection.Reconnect(); | ||
359 | } | ||
360 | } | ||
361 | |||
362 | return retList; | ||
363 | } | ||
364 | |||
314 | #endregion | 365 | #endregion |
315 | 366 | ||
316 | /// <summary> | 367 | /// <summary> |
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs index 387d3d4..4e8f708 100644 --- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs +++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using System.Collections.Generic; | ||
29 | using log4net; | 30 | using log4net; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
@@ -109,6 +110,20 @@ namespace OpenSim.Data.NHibernate | |||
109 | return (FetchAsset(uuid) != null); | 110 | return (FetchAsset(uuid) != null); |
110 | } | 111 | } |
111 | 112 | ||
113 | /// <summary> | ||
114 | /// Returns a list of AssetMetadata objects. The list is a subset of | ||
115 | /// the entire data set offset by <paramref name="start" /> containing | ||
116 | /// <paramref name="count" /> elements. | ||
117 | /// </summary> | ||
118 | /// <param name="start">The number of results to discard from the total data set.</param> | ||
119 | /// <param name="count">The number of rows the returned list should contain.</param> | ||
120 | /// <returns>A list of AssetMetadata objects.</returns> | ||
121 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | ||
122 | { | ||
123 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | ||
124 | return retList; | ||
125 | } | ||
126 | |||
112 | public void DeleteAsset(UUID uuid) | 127 | public void DeleteAsset(UUID uuid) |
113 | { | 128 | { |
114 | 129 | ||
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 1b42198..6a323e1 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
31 | using log4net; | 32 | using log4net; |
32 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.SqliteClient; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
@@ -49,6 +50,7 @@ namespace OpenSim.Data.SQLite | |||
49 | /// Artificial constructor called upon plugin load | 50 | /// Artificial constructor called upon plugin load |
50 | /// </summary> | 51 | /// </summary> |
51 | private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; | 52 | private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; |
53 | private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; | ||
52 | private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; | 54 | private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; |
53 | private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; | 55 | private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; |
54 | private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; | 56 | private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; |
@@ -256,6 +258,54 @@ namespace OpenSim.Data.SQLite | |||
256 | return asset; | 258 | return asset; |
257 | } | 259 | } |
258 | 260 | ||
261 | private static AssetMetadata buildAssetMetadata(IDataReader row) | ||
262 | { | ||
263 | AssetMetadata metadata = new AssetMetadata(); | ||
264 | |||
265 | metadata.FullID = new UUID((string) row["UUID"]); | ||
266 | metadata.Name = (string) row["Name"]; | ||
267 | metadata.Description = (string) row["Description"]; | ||
268 | metadata.Type = Convert.ToSByte(row["Type"]); | ||
269 | metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. | ||
270 | |||
271 | // Current SHA1s are not stored/computed. | ||
272 | metadata.SHA1 = new byte[] {}; | ||
273 | |||
274 | return metadata; | ||
275 | } | ||
276 | |||
277 | /// <summary> | ||
278 | /// Returns a list of AssetMetadata objects. The list is a subset of | ||
279 | /// the entire data set offset by <paramref name="start" /> containing | ||
280 | /// <paramref name="count" /> elements. | ||
281 | /// </summary> | ||
282 | /// <param name="start">The number of results to discard from the total data set.</param> | ||
283 | /// <param name="count">The number of rows the returned list should contain.</param> | ||
284 | /// <returns>A list of AssetMetadata objects.</returns> | ||
285 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | ||
286 | { | ||
287 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | ||
288 | |||
289 | lock (this) | ||
290 | { | ||
291 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetMetadataSQL, m_conn)) | ||
292 | { | ||
293 | cmd.Parameters.Add(new SqliteParameter(":start", start)); | ||
294 | cmd.Parameters.Add(new SqliteParameter(":count", count)); | ||
295 | |||
296 | using (IDataReader reader = cmd.ExecuteReader()) | ||
297 | { | ||
298 | while (reader.Read()) | ||
299 | { | ||
300 | AssetMetadata metadata = buildAssetMetadata(reader); | ||
301 | retList.Add(metadata); | ||
302 | } | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | |||
307 | return retList; | ||
308 | } | ||
259 | 309 | ||
260 | /*********************************************************************** | 310 | /*********************************************************************** |
261 | * | 311 | * |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs index 6e7519d..34b0565 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
42 | public class BrowseFrontendPlugin : IAssetInventoryServerPlugin | 42 | public class BrowseFrontendPlugin : IAssetInventoryServerPlugin |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | //private AssetInventoryServer m_server; | 45 | private AssetInventoryServer m_server; |
46 | 46 | ||
47 | public BrowseFrontendPlugin() | 47 | public BrowseFrontendPlugin() |
48 | { | 48 | { |
@@ -52,10 +52,10 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
52 | 52 | ||
53 | public void Initialise(AssetInventoryServer server) | 53 | public void Initialise(AssetInventoryServer server) |
54 | { | 54 | { |
55 | //m_server = server; | 55 | m_server = server; |
56 | 56 | ||
57 | // Request for / or /?... | 57 | // Request for / or /?... |
58 | //m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); | 58 | m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); |
59 | 59 | ||
60 | m_log.Info("[BROWSEFRONTEND]: Browser Frontend loaded."); | 60 | m_log.Info("[BROWSEFRONTEND]: Browser Frontend loaded."); |
61 | } | 61 | } |
@@ -86,102 +86,87 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
86 | 86 | ||
87 | #endregion IPlugin implementation | 87 | #endregion IPlugin implementation |
88 | 88 | ||
89 | //public class BrowseRequestHandler : IStreamedRequestHandler | 89 | public class BrowseRequestHandler : BaseStreamHandler |
90 | //{ | 90 | { |
91 | // AssetInventoryServer m_server; | 91 | AssetInventoryServer m_server; |
92 | // string m_contentType; | 92 | |
93 | // string m_httpMethod; | 93 | //public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "(^/$|(^/\?.*)") |
94 | // string m_path; | 94 | public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "/") |
95 | 95 | { | |
96 | // public BrowseRequestHandler(AssetInventoryServer server) | 96 | m_server = server; |
97 | // { | 97 | } |
98 | // m_server = server; | 98 | |
99 | // m_contentType = null; | 99 | public override string ContentType |
100 | // m_httpMethod = "GET"; | 100 | { |
101 | // m_path = @"(^/$)|(^/\?.*)"; | 101 | get { return "text/html"; } |
102 | // } | 102 | } |
103 | 103 | ||
104 | // #region IStreamedRequestHandler implementation | 104 | #region IStreamedRequestHandler implementation |
105 | 105 | ||
106 | // public string ContentType | 106 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
107 | // { | 107 | { |
108 | // get { return m_contentType; } | 108 | const int ASSETS_PER_PAGE = 25; |
109 | // } | 109 | const string HEADER = "<html><head><title>Asset Server</title></head><body>"; |
110 | 110 | const string TABLE_HEADER = | |
111 | // public string HttpMethod | 111 | "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; |
112 | // { | 112 | const string TABLE_FOOTER = "</table>"; |
113 | // get { return m_httpMethod; } | 113 | const string FOOTER = "</body></html>"; |
114 | // } | 114 | |
115 | 115 | UUID authToken = Utils.GetAuthToken(httpRequest); | |
116 | // public string Path | 116 | |
117 | // { | 117 | StringBuilder html = new StringBuilder(); |
118 | // get { return m_path; } | 118 | int start = 0; |
119 | // } | 119 | uint page = 0; |
120 | 120 | ||
121 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 121 | if (!String.IsNullOrEmpty(httpRequest.Url.Query)) |
122 | // { | 122 | { |
123 | // const int ASSETS_PER_PAGE = 25; | 123 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); |
124 | // const string HEADER = "<html><head><title>Asset Server</title></head><body>"; | 124 | if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) |
125 | // const string TABLE_HEADER = | 125 | start = (int)page * ASSETS_PER_PAGE; |
126 | // "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; | 126 | } |
127 | // const string TABLE_FOOTER = "</table>"; | 127 | |
128 | // const string FOOTER = "</body></html>"; | 128 | html.AppendLine(HEADER); |
129 | 129 | ||
130 | // UUID authToken = Utils.GetAuthToken(httpRequest); | 130 | html.AppendLine("<p>"); |
131 | 131 | if (page > 0) | |
132 | // StringBuilder html = new StringBuilder(); | 132 | html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); |
133 | // int start = 0; | 133 | html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); |
134 | // uint page = 0; | 134 | html.AppendLine("</p>"); |
135 | 135 | ||
136 | // if (!String.IsNullOrEmpty(httpRequest.Url.Query)) | 136 | html.AppendLine(TABLE_HEADER); |
137 | // { | 137 | |
138 | // NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | 138 | m_server.StorageProvider.ForEach( |
139 | // if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) | 139 | delegate(AssetMetadata data) |
140 | // start = (int)page * ASSETS_PER_PAGE; | 140 | { |
141 | // } | 141 | if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.FullID)) |
142 | 142 | { | |
143 | // html.AppendLine(HEADER); | 143 | html.AppendLine(String.Format( |
144 | 144 | "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", | |
145 | // html.AppendLine("<p>"); | 145 | data.Name, data.Description, data.ContentType, data.ID, data.Temporary, |
146 | // if (page > 0) | 146 | BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); |
147 | // html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); | 147 | } |
148 | // html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); | 148 | else |
149 | // html.AppendLine("</p>"); | 149 | { |
150 | 150 | html.AppendLine(String.Format( | |
151 | // html.AppendLine(TABLE_HEADER); | 151 | "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", |
152 | 152 | data.ID, data.Temporary)); | |
153 | // m_server.StorageProvider.ForEach( | 153 | } |
154 | // delegate(Metadata data) | 154 | }, start, ASSETS_PER_PAGE |
155 | // { | 155 | ); |
156 | // if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) | 156 | |
157 | // { | 157 | html.AppendLine(TABLE_FOOTER); |
158 | // html.AppendLine(String.Format( | 158 | |
159 | // "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", | 159 | html.AppendLine(FOOTER); |
160 | // data.Name, data.Description, data.ContentType, data.ID, data.Temporary, | 160 | |
161 | // BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); | 161 | byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); |
162 | // } | 162 | |
163 | // else | 163 | httpResponse.StatusCode = (int) HttpStatusCode.OK; |
164 | // { | 164 | //httpResponse.Body.Write(responseData, 0, responseData.Length); |
165 | // html.AppendLine(String.Format( | 165 | //httpResponse.Body.Flush(); |
166 | // "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", | 166 | return responseData; |
167 | // data.ID, data.Temporary)); | 167 | } |
168 | // } | 168 | |
169 | // }, start, ASSETS_PER_PAGE | 169 | #endregion IStreamedRequestHandler implementation |
170 | // ); | 170 | } |
171 | |||
172 | // html.AppendLine(TABLE_FOOTER); | ||
173 | |||
174 | // html.AppendLine(FOOTER); | ||
175 | |||
176 | // byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); | ||
177 | |||
178 | // httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
179 | // httpResponse.Body.Write(responseData, 0, responseData.Length); | ||
180 | // httpResponse.Body.Flush(); | ||
181 | // return responseData; | ||
182 | // } | ||
183 | |||
184 | // #endregion IStreamedRequestHandler implementation | ||
185 | //} | ||
186 | } | 171 | } |
187 | } | 172 | } |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs index dcacab2..4b0dd7f 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
33 | using OpenSim.Data; | 34 | using OpenSim.Data; |
@@ -117,42 +118,17 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
117 | { | 118 | { |
118 | int rowCount = 0; | 119 | int rowCount = 0; |
119 | 120 | ||
120 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect"))) | 121 | foreach (AssetMetadata metadata in m_assetProvider.FetchAssetMetadataSet(start, count)) |
121 | //{ | 122 | { |
122 | // MySqlDataReader reader; | 123 | // We set the ContentType here because Utils is only in |
123 | 124 | // AssetInventoryServer. This should be moved to the DB | |
124 | // try | 125 | // backends when the equivalent of SLAssetTypeToContentType is |
125 | // { | 126 | // in OpenSim.Framework or similar. |
126 | // dbConnection.Open(); | 127 | metadata.ContentType = Utils.SLAssetTypeToContentType(metadata.Type); |
127 | 128 | ||
128 | // MySqlCommand command = dbConnection.CreateCommand(); | 129 | action(metadata); |
129 | // command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}", | 130 | ++rowCount; |
130 | // start, count); | 131 | } |
131 | // reader = command.ExecuteReader(); | ||
132 | // } | ||
133 | // catch (MySqlException ex) | ||
134 | // { | ||
135 | // m_log.Error("[OPENSIMASSETSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
136 | // return 0; | ||
137 | // } | ||
138 | |||
139 | // while (reader.Read()) | ||
140 | // { | ||
141 | // Metadata metadata = new Metadata(); | ||
142 | // metadata.CreationDate = OpenMetaverse.Utils.Epoch; | ||
143 | // metadata.Description = reader.GetString(1); | ||
144 | // metadata.ID = UUID.Parse(reader.GetString(5)); | ||
145 | // metadata.Name = reader.GetString(0); | ||
146 | // metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4)); | ||
147 | // metadata.Temporary = reader.GetBoolean(3); | ||
148 | // metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); | ||
149 | |||
150 | // action(metadata); | ||
151 | // ++rowCount; | ||
152 | // } | ||
153 | |||
154 | // reader.Close(); | ||
155 | //} | ||
156 | 132 | ||
157 | return rowCount; | 133 | return rowCount; |
158 | } | 134 | } |
diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs index fc84eac..d6bce5b 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | using OpenSim.Data; | 31 | using OpenSim.Data; |
@@ -48,6 +49,7 @@ namespace OpenSim.Tests.Common.Mock | |||
48 | public void CreateAsset(AssetBase asset) {} | 49 | public void CreateAsset(AssetBase asset) {} |
49 | public void UpdateAsset(AssetBase asset) {} | 50 | public void UpdateAsset(AssetBase asset) {} |
50 | public bool ExistsAsset(UUID uuid) { return false; } | 51 | public bool ExistsAsset(UUID uuid) { return false; } |
52 | public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); } | ||
51 | public void Initialise(string connect) {} | 53 | public void Initialise(string connect) {} |
52 | } | 54 | } |
53 | } | 55 | } |