diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml | 13 | ||||
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs (renamed from OpenSim/Grid/AssetInventoryServer/Extensions/SimpleStorage.cs) | 70 | ||||
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs | 73 |
3 files changed, 134 insertions, 22 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml new file mode 100644 index 0000000..53534c4 --- /dev/null +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml | |||
@@ -0,0 +1,13 @@ | |||
1 | <Addin id="OpenSim.Grid.AssetInventoryServer.Plugins.Simple" version="0.1"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" /> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path="/OpenSim/AssetInventoryServer/StorageProvider"> | ||
11 | <Plugin id="SimpleAssetStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.SimpleAssetStoragePlugin" /> | ||
12 | </Extension> | ||
13 | </Addin> | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleStorage.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs index 9456ef5..fd198d9 100644 --- a/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleStorage.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs | |||
@@ -34,12 +34,13 @@ using System.IO; | |||
34 | using ExtensionLoader; | 34 | using ExtensionLoader; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | using OpenSim.Framework; | ||
37 | 38 | ||
38 | namespace OpenSim.Grid.AssetInventoryServer.Extensions | 39 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple |
39 | { | 40 | { |
40 | public class SimpleStorage : IExtension<AssetInventoryServer>, IStorageProvider | 41 | public class SimpleAssetStoragePlugin : IAssetStorageProvider |
41 | { | 42 | { |
42 | const string EXTENSION_NAME = ""; // Used in metrics reporting | 43 | const string EXTENSION_NAME = "SimpleAssetStorage"; // Used in metrics reporting |
43 | const string DEFAULT_DATA_DIR = "SimpleAssets"; | 44 | const string DEFAULT_DATA_DIR = "SimpleAssets"; |
44 | const string TEMP_DATA_DIR = "SimpleAssetsTemp"; | 45 | const string TEMP_DATA_DIR = "SimpleAssetsTemp"; |
45 | 46 | ||
@@ -47,30 +48,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Extensions | |||
47 | Dictionary<UUID, Metadata> metadataStorage; | 48 | Dictionary<UUID, Metadata> metadataStorage; |
48 | Dictionary<UUID, string> filenames; | 49 | Dictionary<UUID, string> filenames; |
49 | 50 | ||
50 | public SimpleStorage() | 51 | public SimpleAssetStoragePlugin() |
51 | { | 52 | { |
52 | } | 53 | } |
53 | 54 | ||
54 | #region Required Interfaces | 55 | #region Required Interfaces |
55 | 56 | ||
56 | public void Start(AssetInventoryServer server) | ||
57 | { | ||
58 | this.server = server; | ||
59 | metadataStorage = new Dictionary<UUID, Metadata>(); | ||
60 | filenames = new Dictionary<UUID, string>(); | ||
61 | |||
62 | LoadFiles(DEFAULT_DATA_DIR, false); | ||
63 | LoadFiles(TEMP_DATA_DIR, true); | ||
64 | |||
65 | Logger.Log.InfoFormat("Initialized the store index with metadata for {0} assets", | ||
66 | metadataStorage.Count); | ||
67 | } | ||
68 | |||
69 | public void Stop() | ||
70 | { | ||
71 | WipeTemporary(); | ||
72 | } | ||
73 | |||
74 | public BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata) | 57 | public BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata) |
75 | { | 58 | { |
76 | metadata = null; | 59 | metadata = null; |
@@ -203,6 +186,49 @@ namespace OpenSim.Grid.AssetInventoryServer.Extensions | |||
203 | 186 | ||
204 | #endregion Required Interfaces | 187 | #endregion Required Interfaces |
205 | 188 | ||
189 | #region IPlugin implementation | ||
190 | |||
191 | public void Initialise(AssetInventoryServer server) | ||
192 | { | ||
193 | this.server = server; | ||
194 | |||
195 | metadataStorage = new Dictionary<UUID, Metadata>(); | ||
196 | filenames = new Dictionary<UUID, string>(); | ||
197 | |||
198 | LoadFiles(DEFAULT_DATA_DIR, false); | ||
199 | LoadFiles(TEMP_DATA_DIR, true); | ||
200 | |||
201 | Logger.Log.InfoFormat("Initialized the store index with metadata for {0} assets", | ||
202 | metadataStorage.Count); | ||
203 | } | ||
204 | |||
205 | /// <summary> | ||
206 | /// <para>Initialises asset interface</para> | ||
207 | /// </summary> | ||
208 | public void Initialise() | ||
209 | { | ||
210 | Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); | ||
211 | throw new PluginNotInitialisedException(Name); | ||
212 | } | ||
213 | |||
214 | public void Dispose() | ||
215 | { | ||
216 | WipeTemporary(); | ||
217 | } | ||
218 | |||
219 | public string Version | ||
220 | { | ||
221 | // TODO: this should be something meaningful and not hardcoded? | ||
222 | get { return "0.1"; } | ||
223 | } | ||
224 | |||
225 | public string Name | ||
226 | { | ||
227 | get { return "AssetInventoryServer Simple asset storage provider"; } | ||
228 | } | ||
229 | |||
230 | #endregion IPlugin implementation | ||
231 | |||
206 | public void WipeTemporary() | 232 | public void WipeTemporary() |
207 | { | 233 | { |
208 | if (Directory.Exists(TEMP_DATA_DIR)) | 234 | if (Directory.Exists(TEMP_DATA_DIR)) |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs new file mode 100644 index 0000000..6a32718 --- /dev/null +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008 Intel Corporation | ||
3 | * All rights reserved. | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * -- Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * -- Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * -- Neither the name of the Intel Corporation nor the names of its | ||
14 | * contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
20 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS | ||
21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.IO; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | ||
35 | { | ||
36 | public static class SimpleUtils | ||
37 | { | ||
38 | public static string ParseNameFromFilename(string filename) | ||
39 | { | ||
40 | filename = Path.GetFileName(filename); | ||
41 | |||
42 | int dot = filename.LastIndexOf('.'); | ||
43 | int firstDash = filename.IndexOf('-'); | ||
44 | |||
45 | if (dot - 37 > 0 && firstDash > 0) | ||
46 | return filename.Substring(0, firstDash); | ||
47 | else | ||
48 | return String.Empty; | ||
49 | } | ||
50 | |||
51 | public static UUID ParseUUIDFromFilename(string filename) | ||
52 | { | ||
53 | int dot = filename.LastIndexOf('.'); | ||
54 | |||
55 | if (dot > 35) | ||
56 | { | ||
57 | // Grab the last 36 characters of the filename | ||
58 | string uuidString = filename.Substring(dot - 36, 36); | ||
59 | UUID uuid; | ||
60 | UUID.TryParse(uuidString, out uuid); | ||
61 | return uuid; | ||
62 | } | ||
63 | else | ||
64 | { | ||
65 | UUID uuid; | ||
66 | if (UUID.TryParse(Path.GetFileName(filename), out uuid)) | ||
67 | return uuid; | ||
68 | else | ||
69 | return UUID.Zero; | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||