diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 127 | ||||
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 124 |
2 files changed, 129 insertions, 122 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index df571fa..9960228 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -26,7 +26,11 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Console; | ||
30 | using OpenSim.Server.Base; | 34 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.Servers.HttpServer; | 36 | using OpenSim.Framework.Servers.HttpServer; |
@@ -67,6 +71,127 @@ namespace OpenSim.Server.Handlers.Asset | |||
67 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 71 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); |
68 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); | 72 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); |
69 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); | 73 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); |
74 | |||
75 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
76 | "show digest", | ||
77 | "show digest <ID>", | ||
78 | "Show asset digest", | ||
79 | HandleShowDigest); | ||
80 | |||
81 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
82 | "delete asset", | ||
83 | "delete asset <ID>", | ||
84 | "Delete asset from database", | ||
85 | HandleDeleteAsset); | ||
86 | |||
87 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
88 | "dump asset", | ||
89 | "dump asset <ID>", | ||
90 | "Dump asset to a file", | ||
91 | "The filename is the same as the ID given.", | ||
92 | HandleDumpAsset); | ||
93 | } | ||
94 | |||
95 | void HandleDeleteAsset(string module, string[] args) | ||
96 | { | ||
97 | if (args.Length < 3) | ||
98 | { | ||
99 | MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
100 | return; | ||
101 | } | ||
102 | |||
103 | AssetBase asset = m_AssetService.Get(args[2]); | ||
104 | |||
105 | if (asset == null || asset.Data.Length == 0) | ||
106 | { | ||
107 | MainConsole.Instance.Output("Asset not found"); | ||
108 | return; | ||
109 | } | ||
110 | |||
111 | m_AssetService.Delete(args[2]); | ||
112 | |||
113 | //MainConsole.Instance.Output("Asset deleted"); | ||
114 | // TODO: Implement this | ||
115 | |||
116 | MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
117 | } | ||
118 | |||
119 | void HandleDumpAsset(string module, string[] args) | ||
120 | { | ||
121 | if (args.Length < 3) | ||
122 | { | ||
123 | MainConsole.Instance.Output("Usage is dump asset <ID>"); | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | UUID assetId; | ||
128 | string rawAssetId = args[2]; | ||
129 | |||
130 | if (!UUID.TryParse(rawAssetId, out assetId)) | ||
131 | { | ||
132 | MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | AssetBase asset = m_AssetService.Get(assetId.ToString()); | ||
137 | if (asset == null) | ||
138 | { | ||
139 | MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | string fileName = rawAssetId; | ||
144 | |||
145 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | ||
146 | { | ||
147 | using (BinaryWriter bw = new BinaryWriter(fs)) | ||
148 | { | ||
149 | bw.Write(asset.Data); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); | ||
154 | } | ||
155 | |||
156 | void HandleShowDigest(string module, string[] args) | ||
157 | { | ||
158 | if (args.Length < 3) | ||
159 | { | ||
160 | MainConsole.Instance.Output("Syntax: show digest <ID>"); | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | AssetBase asset = m_AssetService.Get(args[2]); | ||
165 | |||
166 | if (asset == null || asset.Data.Length == 0) | ||
167 | { | ||
168 | MainConsole.Instance.Output("Asset not found"); | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | int i; | ||
173 | |||
174 | MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); | ||
175 | MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); | ||
176 | MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); | ||
177 | MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); | ||
178 | MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); | ||
179 | |||
180 | for (i = 0 ; i < 5 ; i++) | ||
181 | { | ||
182 | int off = i * 16; | ||
183 | if (asset.Data.Length <= off) | ||
184 | break; | ||
185 | int len = 16; | ||
186 | if (asset.Data.Length < off + len) | ||
187 | len = asset.Data.Length - off; | ||
188 | |||
189 | byte[] line = new byte[len]; | ||
190 | Array.Copy(asset.Data, off, line, 0, len); | ||
191 | |||
192 | string text = BitConverter.ToString(line); | ||
193 | MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
194 | } | ||
70 | } | 195 | } |
71 | } | 196 | } |
72 | } | 197 | } \ No newline at end of file |
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index b3af8e3..4f4cbf6 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs | |||
@@ -32,7 +32,6 @@ using System.Reflection; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Data; | 35 | using OpenSim.Data; |
37 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
38 | using OpenMetaverse; | 37 | using OpenMetaverse; |
@@ -53,23 +52,6 @@ namespace OpenSim.Services.AssetService | |||
53 | { | 52 | { |
54 | m_RootInstance = this; | 53 | m_RootInstance = this; |
55 | 54 | ||
56 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
57 | "show digest", | ||
58 | "show digest <ID>", | ||
59 | "Show asset digest", HandleShowDigest); | ||
60 | |||
61 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
62 | "delete asset", | ||
63 | "delete asset <ID>", | ||
64 | "Delete asset from database", HandleDeleteAsset); | ||
65 | |||
66 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
67 | "dump asset", | ||
68 | "dump asset <ID>", | ||
69 | "Dump asset to a file", | ||
70 | "The filename is the same as the ID given.", | ||
71 | HandleDumpAsset); | ||
72 | |||
73 | if (m_AssetLoader != null) | 55 | if (m_AssetLoader != null) |
74 | { | 56 | { |
75 | IConfig assetConfig = config.Configs["AssetService"]; | 57 | IConfig assetConfig = config.Configs["AssetService"]; |
@@ -218,111 +200,11 @@ namespace OpenSim.Services.AssetService | |||
218 | return m_Database.Delete(id); | 200 | return m_Database.Delete(id); |
219 | } | 201 | } |
220 | else | 202 | else |
221 | m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); | ||
222 | |||
223 | return false; | ||
224 | } | ||
225 | |||
226 | void HandleDumpAsset(string module, string[] args) | ||
227 | { | ||
228 | if (args.Length < 3) | ||
229 | { | ||
230 | MainConsole.Instance.Output("Usage is dump asset <ID>"); | ||
231 | return; | ||
232 | } | ||
233 | |||
234 | string rawAssetId = args[2]; | ||
235 | UUID assetId; | ||
236 | |||
237 | if (!UUID.TryParse(rawAssetId, out assetId)) | ||
238 | { | ||
239 | MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | AssetBase asset = m_Database.GetAsset(assetId); | ||
244 | if (asset == null) | ||
245 | { | ||
246 | MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); | ||
247 | return; | ||
248 | } | ||
249 | |||
250 | string fileName = rawAssetId; | ||
251 | |||
252 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | ||
253 | { | ||
254 | using (BinaryWriter bw = new BinaryWriter(fs)) | ||
255 | { | ||
256 | bw.Write(asset.Data); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); | ||
261 | } | ||
262 | |||
263 | void HandleShowDigest(string module, string[] args) | ||
264 | { | ||
265 | if (args.Length < 3) | ||
266 | { | ||
267 | MainConsole.Instance.Output("Syntax: show digest <ID>"); | ||
268 | return; | ||
269 | } | ||
270 | |||
271 | AssetBase asset = Get(args[2]); | ||
272 | |||
273 | if (asset == null || asset.Data.Length == 0) | ||
274 | { | ||
275 | MainConsole.Instance.Output("Asset not found"); | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | int i; | ||
280 | |||
281 | MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); | ||
282 | MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); | ||
283 | MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); | ||
284 | MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); | ||
285 | MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); | ||
286 | |||
287 | for (i = 0 ; i < 5 ; i++) | ||
288 | { | 203 | { |
289 | int off = i * 16; | 204 | m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); |
290 | if (asset.Data.Length <= off) | ||
291 | break; | ||
292 | int len = 16; | ||
293 | if (asset.Data.Length < off + len) | ||
294 | len = asset.Data.Length - off; | ||
295 | |||
296 | byte[] line = new byte[len]; | ||
297 | Array.Copy(asset.Data, off, line, 0, len); | ||
298 | |||
299 | string text = BitConverter.ToString(line); | ||
300 | MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
301 | } | ||
302 | } | ||
303 | |||
304 | void HandleDeleteAsset(string module, string[] args) | ||
305 | { | ||
306 | if (args.Length < 3) | ||
307 | { | ||
308 | MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
309 | return; | ||
310 | } | ||
311 | |||
312 | AssetBase asset = Get(args[2]); | ||
313 | |||
314 | if (asset == null || asset.Data.Length == 0) | ||
315 | { | ||
316 | MainConsole.Instance.Output("Asset not found"); | ||
317 | return; | ||
318 | } | 205 | } |
319 | 206 | ||
320 | Delete(args[2]); | 207 | return false; |
321 | |||
322 | //MainConsole.Instance.Output("Asset deleted"); | ||
323 | // TODO: Implement this | ||
324 | |||
325 | MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
326 | } | 208 | } |
327 | } | 209 | } |
328 | } | 210 | } \ No newline at end of file |