diff options
author | Mike Mazur | 2009-02-16 02:28:34 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-16 02:28:34 +0000 |
commit | ab5e3328323a66028bfd47562d9d515dbec433be (patch) | |
tree | d81184cd1f8788c20b4600649195be66e03f48c3 /OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs | |
parent | We need to return a zero-length byte array from the Handle() routine. (diff) | |
download | opensim-SC_OLD-ab5e3328323a66028bfd47562d9d515dbec433be.zip opensim-SC_OLD-ab5e3328323a66028bfd47562d9d515dbec433be.tar.gz opensim-SC_OLD-ab5e3328323a66028bfd47562d9d515dbec433be.tar.bz2 opensim-SC_OLD-ab5e3328323a66028bfd47562d9d515dbec433be.tar.xz |
- removed OpenSim.Grid.AssetInventoryServer.Metadata class in favor of
OpenSim.Framework.AssetMetadata and related updates in AssetInventory
server
- removed dependency on MySql.Data.MySqlClient
- commented out the bulk of OpenSimInventoryStorage due to missing
MySql.Data dependency
- refactor asset creation in OpenSimAssetFrontend
- commented out ForEach implementation, which also depended on
MySql.Data, until it's supported by OpenSim backends
- commented out some handlers in BrowseFrontend and ReferenceFrontend as
they relied on either ForEach or the removed Metadata class
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs')
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs | 197 |
1 files changed, 98 insertions, 99 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs index 6afda79..3b6e99e 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs | |||
@@ -57,8 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
57 | m_server = server; | 57 | m_server = server; |
58 | 58 | ||
59 | // Request for / or /?... | 59 | // Request for / or /?... |
60 | //server.HttpServer.AddHandler("get", null, @"(^/$)|(^/\?.*)", BrowseRequestHandler); | 60 | //m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); |
61 | m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); | ||
62 | 61 | ||
63 | m_log.Info("[ASSET] Browser Frontend loaded."); | 62 | m_log.Info("[ASSET] Browser Frontend loaded."); |
64 | } | 63 | } |
@@ -89,102 +88,102 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
89 | 88 | ||
90 | #endregion IPlugin implementation | 89 | #endregion IPlugin implementation |
91 | 90 | ||
92 | public class BrowseRequestHandler : IStreamedRequestHandler | 91 | //public class BrowseRequestHandler : IStreamedRequestHandler |
93 | { | 92 | //{ |
94 | AssetInventoryServer m_server; | 93 | // AssetInventoryServer m_server; |
95 | string m_contentType; | 94 | // string m_contentType; |
96 | string m_httpMethod; | 95 | // string m_httpMethod; |
97 | string m_path; | 96 | // string m_path; |
98 | 97 | ||
99 | public BrowseRequestHandler(AssetInventoryServer server) | 98 | // public BrowseRequestHandler(AssetInventoryServer server) |
100 | { | 99 | // { |
101 | m_server = server; | 100 | // m_server = server; |
102 | m_contentType = null; | 101 | // m_contentType = null; |
103 | m_httpMethod = "GET"; | 102 | // m_httpMethod = "GET"; |
104 | m_path = @"(^/$)|(^/\?.*)"; | 103 | // m_path = @"(^/$)|(^/\?.*)"; |
105 | } | 104 | // } |
106 | 105 | ||
107 | #region IStreamedRequestHandler implementation | 106 | // #region IStreamedRequestHandler implementation |
108 | 107 | ||
109 | public string ContentType | 108 | // public string ContentType |
110 | { | 109 | // { |
111 | get { return m_contentType; } | 110 | // get { return m_contentType; } |
112 | } | 111 | // } |
113 | 112 | ||
114 | public string HttpMethod | 113 | // public string HttpMethod |
115 | { | 114 | // { |
116 | get { return m_httpMethod; } | 115 | // get { return m_httpMethod; } |
117 | } | 116 | // } |
118 | 117 | ||
119 | public string Path | 118 | // public string Path |
120 | { | 119 | // { |
121 | get { return m_path; } | 120 | // get { return m_path; } |
122 | } | 121 | // } |
123 | 122 | ||
124 | public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 123 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
125 | { | 124 | // { |
126 | const int ASSETS_PER_PAGE = 25; | 125 | // const int ASSETS_PER_PAGE = 25; |
127 | const string HEADER = "<html><head><title>Asset Server</title></head><body>"; | 126 | // const string HEADER = "<html><head><title>Asset Server</title></head><body>"; |
128 | const string TABLE_HEADER = | 127 | // const string TABLE_HEADER = |
129 | "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; | 128 | // "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; |
130 | const string TABLE_FOOTER = "</table>"; | 129 | // const string TABLE_FOOTER = "</table>"; |
131 | const string FOOTER = "</body></html>"; | 130 | // const string FOOTER = "</body></html>"; |
132 | 131 | ||
133 | UUID authToken = Utils.GetAuthToken(httpRequest); | 132 | // UUID authToken = Utils.GetAuthToken(httpRequest); |
134 | 133 | ||
135 | StringBuilder html = new StringBuilder(); | 134 | // StringBuilder html = new StringBuilder(); |
136 | int start = 0; | 135 | // int start = 0; |
137 | uint page = 0; | 136 | // uint page = 0; |
138 | 137 | ||
139 | if (!String.IsNullOrEmpty(httpRequest.Url.Query)) | 138 | // if (!String.IsNullOrEmpty(httpRequest.Url.Query)) |
140 | { | 139 | // { |
141 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | 140 | // NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); |
142 | if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) | 141 | // if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) |
143 | start = (int)page * ASSETS_PER_PAGE; | 142 | // start = (int)page * ASSETS_PER_PAGE; |
144 | } | 143 | // } |
145 | 144 | ||
146 | html.AppendLine(HEADER); | 145 | // html.AppendLine(HEADER); |
147 | 146 | ||
148 | html.AppendLine("<p>"); | 147 | // html.AppendLine("<p>"); |
149 | if (page > 0) | 148 | // if (page > 0) |
150 | html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); | 149 | // html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); |
151 | html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); | 150 | // html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); |
152 | html.AppendLine("</p>"); | 151 | // html.AppendLine("</p>"); |
153 | 152 | ||
154 | html.AppendLine(TABLE_HEADER); | 153 | // html.AppendLine(TABLE_HEADER); |
155 | 154 | ||
156 | m_server.StorageProvider.ForEach( | 155 | // m_server.StorageProvider.ForEach( |
157 | delegate(Metadata data) | 156 | // delegate(Metadata data) |
158 | { | 157 | // { |
159 | if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) | 158 | // if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) |
160 | { | 159 | // { |
161 | html.AppendLine(String.Format( | 160 | // html.AppendLine(String.Format( |
162 | "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", | 161 | // "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", |
163 | data.Name, data.Description, data.ContentType, data.ID, data.Temporary, | 162 | // data.Name, data.Description, data.ContentType, data.ID, data.Temporary, |
164 | BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); | 163 | // BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); |
165 | } | 164 | // } |
166 | else | 165 | // else |
167 | { | 166 | // { |
168 | html.AppendLine(String.Format( | 167 | // html.AppendLine(String.Format( |
169 | "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", | 168 | // "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", |
170 | data.ID, data.Temporary)); | 169 | // data.ID, data.Temporary)); |
171 | } | 170 | // } |
172 | }, start, ASSETS_PER_PAGE | 171 | // }, start, ASSETS_PER_PAGE |
173 | ); | 172 | // ); |
174 | 173 | ||
175 | html.AppendLine(TABLE_FOOTER); | 174 | // html.AppendLine(TABLE_FOOTER); |
176 | 175 | ||
177 | html.AppendLine(FOOTER); | 176 | // html.AppendLine(FOOTER); |
178 | 177 | ||
179 | byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); | 178 | // byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); |
180 | 179 | ||
181 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | 180 | // httpResponse.StatusCode = (int) HttpStatusCode.OK; |
182 | httpResponse.Body.Write(responseData, 0, responseData.Length); | 181 | // httpResponse.Body.Write(responseData, 0, responseData.Length); |
183 | httpResponse.Body.Flush(); | 182 | // httpResponse.Body.Flush(); |
184 | return responseData; | 183 | // return responseData; |
185 | } | 184 | // } |
186 | 185 | ||
187 | #endregion IStreamedRequestHandler implementation | 186 | // #endregion IStreamedRequestHandler implementation |
188 | } | 187 | //} |
189 | } | 188 | } |
190 | } | 189 | } |