aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Null
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Null/NullGenericDataHandler.cs67
-rw-r--r--OpenSim/Data/Null/NullXGroupData.cs (renamed from OpenSim/Services/InventoryService/InventoryServiceBase.cs)78
-rw-r--r--OpenSim/Data/Null/Properties/AssemblyInfo.cs2
3 files changed, 111 insertions, 36 deletions
diff --git a/OpenSim/Data/Null/NullGenericDataHandler.cs b/OpenSim/Data/Null/NullGenericDataHandler.cs
new file mode 100644
index 0000000..dd9d190
--- /dev/null
+++ b/OpenSim/Data/Null/NullGenericDataHandler.cs
@@ -0,0 +1,67 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Data;
36
37namespace OpenSim.Data.Null
38{
39 /// <summary>
40 /// Not a proper generic data handler yet - probably needs to actually store the data as well instead of relying
41 /// on descendent classes
42 /// </summary>
43 public class NullGenericDataHandler
44 {
45 protected List<T> Get<T>(string[] fields, string[] vals, List<T> inputEntities)
46 {
47 List<T> entities = inputEntities;
48
49 for (int i = 0; i < fields.Length; i++)
50 {
51 entities
52 = entities.Where(
53 e =>
54 {
55 FieldInfo fi = typeof(T).GetField(fields[i]);
56 if (fi == null)
57 throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i]));
58
59 return fi.GetValue(e).ToString() == vals[i];
60 }
61 ).ToList();
62 }
63
64 return entities;
65 }
66 }
67} \ No newline at end of file
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
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq;
30using System.Reflection; 32using System.Reflection;
31using Nini.Config; 33using System.Threading;
34using log4net;
35using OpenMetaverse;
32using OpenSim.Framework; 36using OpenSim.Framework;
33using OpenSim.Data; 37using OpenSim.Data;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Base;
36 38
37namespace OpenSim.Services.InventoryService 39namespace 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
diff --git a/OpenSim/Data/Null/Properties/AssemblyInfo.cs b/OpenSim/Data/Null/Properties/AssemblyInfo.cs
index 4b64436..43b0bb3 100644
--- a/OpenSim/Data/Null/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/Null/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.6.5.*")] 64[assembly : AssemblyVersion("0.7.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")] 65[assembly : AssemblyFileVersion("0.6.5.0")]