aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs (renamed from OpenSim/Grid/AssetInventoryServer/Extensions/SimpleStorage.cs)70
1 files changed, 48 insertions, 22 deletions
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;
34using ExtensionLoader; 34using ExtensionLoader;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework;
37 38
38namespace OpenSim.Grid.AssetInventoryServer.Extensions 39namespace 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))