aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
diff options
context:
space:
mode:
authorMelanie2009-08-20 21:45:49 +0100
committerMelanie2009-08-20 21:45:49 +0100
commitb23160a871fe6a28105d39c9602c35cda75efe4a (patch)
tree43c8d839a3bf6016a1d621d814cfd9d670b068b2 /OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
parentRemove a load-order dependency in inventory transfer that was biting (diff)
downloadopensim-SC_OLD-b23160a871fe6a28105d39c9602c35cda75efe4a.zip
opensim-SC_OLD-b23160a871fe6a28105d39c9602c35cda75efe4a.tar.gz
opensim-SC_OLD-b23160a871fe6a28105d39c9602c35cda75efe4a.tar.bz2
opensim-SC_OLD-b23160a871fe6a28105d39c9602c35cda75efe4a.tar.xz
Remove the AssetInventory server from core. It has fallen behind both
upstream and the reference implementation to the point where it is no longer usable. It has no known users, and sinnce it doesn't work anymore, it is safe to assume that no one has used it in a long time.
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs173
1 files changed, 0 insertions, 173 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
deleted file mode 100644
index 90ea2e0..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
+++ /dev/null
@@ -1,173 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31using System.Collections.Specialized;
32using System.Net;
33using System.Text;
34using System.Web;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer;
39using log4net;
40
41namespace OpenSim.Grid.AssetInventoryServer.Plugins
42{
43 public class BrowseFrontendPlugin : IAssetInventoryServerPlugin
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private AssetInventoryServer m_server;
47
48 public BrowseFrontendPlugin()
49 {
50 }
51
52 #region IPlugin implementation
53
54 public void Initialise(AssetInventoryServer server)
55 {
56 m_server = server;
57
58 // Request for / or /?...
59 m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server));
60
61 m_log.Info("[BROWSEFRONTEND]: Browser Frontend loaded.");
62 }
63
64 /// <summary>
65 /// <para>Initialises asset interface</para>
66 /// </summary>
67 public void Initialise()
68 {
69 m_log.InfoFormat("[BROWSEFRONTEND]: {0} cannot be default-initialized!", Name);
70 throw new PluginNotInitialisedException(Name);
71 }
72
73 public void Dispose()
74 {
75 }
76
77 public string Version
78 {
79 // TODO: this should be something meaningful and not hardcoded?
80 get { return "0.1"; }
81 }
82
83 public string Name
84 {
85 get { return "BrowseFrontend"; }
86 }
87
88 #endregion IPlugin implementation
89
90 public class BrowseRequestHandler : BaseStreamHandler
91 {
92 AssetInventoryServer m_server;
93
94 //public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "(^/$|(^/\?.*)")
95 public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "/")
96 {
97 m_server = server;
98 }
99
100 public override string ContentType
101 {
102 get { return "text/html"; }
103 }
104
105 #region IStreamedRequestHandler implementation
106
107 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
108 {
109 const int ASSETS_PER_PAGE = 25;
110 const string HEADER = "<html><head><title>Asset Server</title></head><body>";
111 const string TABLE_HEADER =
112 "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>";
113 const string TABLE_FOOTER = "</table>";
114 const string FOOTER = "</body></html>";
115
116 UUID authToken = Utils.GetAuthToken(httpRequest);
117
118 StringBuilder html = new StringBuilder();
119 int start = 0;
120 uint page = 0;
121
122 if (!String.IsNullOrEmpty(httpRequest.Url.Query))
123 {
124 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
125 if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page))
126 start = (int)page * ASSETS_PER_PAGE;
127 }
128
129 html.AppendLine(HEADER);
130
131 html.AppendLine("<p>");
132 if (page > 0)
133 html.AppendFormat("<a href=\"{0}?page={1}\">&lt; Previous Page</a> | ", httpRequest.RawUrl, page - 1);
134 html.AppendFormat("<a href=\"{0}?page={1}\">Next Page &gt;</a>", httpRequest.RawUrl, page + 1);
135 html.AppendLine("</p>");
136
137 html.AppendLine(TABLE_HEADER);
138
139 m_server.StorageProvider.ForEach(
140 delegate(AssetMetadata data)
141 {
142 if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.FullID))
143 {
144 html.AppendLine(String.Format(
145 "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>",
146 data.Name, data.Description, data.ContentType, data.ID, data.Temporary,
147 BitConverter.ToString(data.SHA1).Replace("-", String.Empty)));
148 }
149 else
150 {
151 html.AppendLine(String.Format(
152 "<tr><td>[Protected Asset]</td><td>&nbsp;</td><td>&nbsp;</td><td>{0}</td><td>{1}</td><td>&nbsp;</td></tr>",
153 data.ID, data.Temporary));
154 }
155 }, start, ASSETS_PER_PAGE
156 );
157
158 html.AppendLine(TABLE_FOOTER);
159
160 html.AppendLine(FOOTER);
161
162 byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString());
163
164 httpResponse.StatusCode = (int) HttpStatusCode.OK;
165 //httpResponse.Body.Write(responseData, 0, responseData.Length);
166 //httpResponse.Body.Flush();
167 return responseData;
168 }
169
170 #endregion IStreamedRequestHandler implementation
171 }
172 }
173}