From 07b8d51da8186e537da35c1d56d176b4843d8eaa Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:27:17 +0000 Subject: AssetInventoryServer now compiles while using the standard OpenSim console and HttpServer. It doesn't work though. --- .../Plugins/BrowseFrontendPlugin.cs | 137 +++++++++++++-------- 1 file changed, 87 insertions(+), 50 deletions(-) (limited to 'OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs') diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs index f445b97..bb38d5d 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs @@ -28,20 +28,21 @@ */ using System; +using System.IO; using System.Collections.Generic; using System.Collections.Specialized; using System.Net; using System.Text; using System.Web; using OpenMetaverse; -using HttpServer; using OpenSim.Framework; +using OpenSim.Framework.Servers; namespace OpenSim.Grid.AssetInventoryServer.Plugins { public class BrowseFrontendPlugin : IAssetInventoryServerPlugin { - AssetInventoryServer server; + AssetInventoryServer m_server; public BrowseFrontendPlugin() { @@ -51,10 +52,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins public void Initialise(AssetInventoryServer server) { - this.server = server; + m_server = server; // Request for / or /?... - server.HttpServer.AddHandler("get", null, @"(^/$)|(^/\?.*)", BrowseRequestHandler); + //server.HttpServer.AddHandler("get", null, @"(^/$)|(^/\?.*)", BrowseRequestHandler); + m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); Logger.Log.Info("[ASSET] Browser Frontend loaded."); } @@ -85,67 +87,102 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins #endregion IPlugin implementation - bool BrowseRequestHandler(IHttpClientContext client, IHttpRequest request, IHttpResponse response) + public class BrowseRequestHandler : IStreamedRequestHandler { - const int ASSETS_PER_PAGE = 25; - const string HEADER = "
Name | Description | Type | ID | Temporary | SHA-1 |
---|
Name | Description | Type | ID | Temporary | SHA-1 |
---|
"); - if (page > 0) - html.AppendFormat("< Previous Page | ", request.Uri.AbsolutePath, page - 1); - html.AppendFormat("Next Page >", request.Uri.AbsolutePath, page + 1); - html.AppendLine("
"); + UUID authToken = Utils.GetAuthToken(httpRequest); - html.AppendLine(TABLE_HEADER); + StringBuilder html = new StringBuilder(); + int start = 0; + uint page = 0; - server.StorageProvider.ForEach( - delegate(Metadata data) + if (!String.IsNullOrEmpty(httpRequest.Url.Query)) { - if (server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) - { - html.AppendLine(String.Format( - ""); + if (page > 0) + html.AppendFormat("< Previous Page | ", httpRequest.RawUrl, page - 1); + html.AppendFormat("Next Page >", httpRequest.RawUrl, page + 1); + html.AppendLine("
"); - byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); + html.AppendLine(TABLE_HEADER); + + m_server.StorageProvider.ForEach( + delegate(Metadata data) + { + if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) + { + html.AppendLine(String.Format( + "