diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Null/NullXGroupData.cs (renamed from OpenSim/Services/InventoryService/InventoryServiceBase.cs) | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/OpenSim/Services/InventoryService/InventoryServiceBase.cs b/OpenSim/Data/Null/NullXGroupData.cs index 456e455..7a86b9f 100644 --- a/OpenSim/Services/InventoryService/InventoryServiceBase.cs +++ b/OpenSim/Data/Null/NullXGroupData.cs | |||
@@ -26,57 +26,65 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | ||
30 | using System.Reflection; | 32 | using System.Reflection; |
31 | using Nini.Config; | 33 | using System.Threading; |
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
33 | using OpenSim.Data; | 37 | using OpenSim.Data; |
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Base; | ||
36 | 38 | ||
37 | namespace OpenSim.Services.InventoryService | 39 | namespace OpenSim.Data.Null |
38 | { | 40 | { |
39 | public class InventoryServiceBase : ServiceBase | 41 | public class NullXGroupData : NullGenericDataHandler, IXGroupData |
40 | { | 42 | { |
41 | protected IInventoryDataPlugin m_Database = null; | 43 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 44 | ||
43 | public InventoryServiceBase(IConfigSource config) : base(config) | 45 | private Dictionary<UUID, XGroup> m_groups = new Dictionary<UUID, XGroup>(); |
44 | { | 46 | |
45 | string dllName = String.Empty; | 47 | public NullXGroupData(string connectionString, string realm) {} |
46 | string connString = String.Empty; | ||
47 | 48 | ||
48 | // | 49 | public bool StoreGroup(XGroup group) |
49 | // Try reading the [DatabaseService] section first, if it exists | 50 | { |
50 | // | 51 | lock (m_groups) |
51 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
52 | if (dbConfig != null) | ||
53 | { | 52 | { |
54 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | 53 | m_groups[group.groupID] = group.Clone(); |
55 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
56 | } | 54 | } |
57 | 55 | ||
58 | // | 56 | return true; |
59 | // Try reading the more specific [InventoryService] section, if it exists | 57 | } |
60 | // | 58 | |
61 | IConfig inventoryConfig = config.Configs["InventoryService"]; | 59 | public XGroup[] GetGroups(string field, string val) |
62 | if (inventoryConfig != null) | 60 | { |
61 | return GetGroups(new string[] { field }, new string[] { val }); | ||
62 | } | ||
63 | |||
64 | public XGroup[] GetGroups(string[] fields, string[] vals) | ||
65 | { | ||
66 | lock (m_groups) | ||
63 | { | 67 | { |
64 | dllName = inventoryConfig.GetString("StorageProvider", dllName); | 68 | List<XGroup> origGroups = Get<XGroup>(fields, vals, m_groups.Values.ToList()); |
65 | connString = inventoryConfig.GetString("ConnectionString", connString); | 69 | |
70 | return origGroups.Select(g => g.Clone()).ToArray(); | ||
66 | } | 71 | } |
72 | } | ||
67 | 73 | ||
68 | // | 74 | public bool DeleteGroups(string field, string val) |
69 | // We tried, but this doesn't exist. We can't proceed. | 75 | { |
70 | // | 76 | return DeleteGroups(new string[] { field }, new string[] { val }); |
71 | if (dllName.Equals(String.Empty)) | 77 | } |
72 | throw new Exception("No InventoryService configuration"); | ||
73 | 78 | ||
74 | m_Database = LoadPlugin<IInventoryDataPlugin>(dllName); | 79 | public bool DeleteGroups(string[] fields, string[] vals) |
75 | if (m_Database == null) | 80 | { |
76 | throw new Exception("Could not find a storage interface in the given module"); | 81 | lock (m_groups) |
82 | { | ||
83 | XGroup[] groupsToDelete = GetGroups(fields, vals); | ||
84 | Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID)); | ||
85 | } | ||
77 | 86 | ||
78 | m_Database.Initialise(connString); | 87 | return true; |
79 | } | 88 | } |
80 | |||
81 | } | 89 | } |
82 | } | 90 | } \ No newline at end of file |