diff options
author | Melanie | 2012-01-06 00:08:18 +0000 |
---|---|---|
committer | Melanie | 2012-01-06 00:08:18 +0000 |
commit | fdfc4ab2a8e171139caf9751a23eb75afe881c2b (patch) | |
tree | bc0d8d3066ecf5fe87e0778e23190d14a58d3bc1 /OpenSim/Server | |
parent | That needs to be callable from elsewhere! (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.zip opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.gz opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.bz2 opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
Diffstat (limited to 'OpenSim/Server')
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 129 |
1 files changed, 128 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index df571fa..9b80245 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,129 @@ 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 asset", | ||
77 | "show asset <ID>", | ||
78 | "Show asset information", | ||
79 | HandleShowAsset); | ||
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 HandleShowAsset(string module, string[] args) | ||
157 | { | ||
158 | if (args.Length < 3) | ||
159 | { | ||
160 | MainConsole.Instance.Output("Syntax: show asset <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("Size: {0} bytes", asset.Data.Length); | ||
179 | MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no"); | ||
180 | MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); | ||
181 | |||
182 | for (i = 0 ; i < 5 ; i++) | ||
183 | { | ||
184 | int off = i * 16; | ||
185 | if (asset.Data.Length <= off) | ||
186 | break; | ||
187 | int len = 16; | ||
188 | if (asset.Data.Length < off + len) | ||
189 | len = asset.Data.Length - off; | ||
190 | |||
191 | byte[] line = new byte[len]; | ||
192 | Array.Copy(asset.Data, off, line, 0, len); | ||
193 | |||
194 | string text = BitConverter.ToString(line); | ||
195 | MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
196 | } | ||
70 | } | 197 | } |
71 | } | 198 | } |
72 | } | 199 | } \ No newline at end of file |