aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs185
1 files changed, 85 insertions, 100 deletions
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}\">&lt; Previous Page</a> | ", httpRequest.RawUrl, page - 1);
133 // int start = 0; 133 html.AppendFormat("<a href=\"{0}?page={1}\">Next Page &gt;</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}\">&lt; Previous Page</a> | ", httpRequest.RawUrl, page - 1); 147 }
148 // html.AppendFormat("<a href=\"{0}?page={1}\">Next Page &gt;</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>&nbsp;</td><td>&nbsp;</td><td>{0}</td><td>{1}</td><td>&nbsp;</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>&nbsp;</td><td>&nbsp;</td><td>{0}</td><td>{1}</td><td>&nbsp;</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}