diff options
author | Justin Clarke Casey | 2009-01-20 18:38:51 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-01-20 18:38:51 +0000 |
commit | 37f7c5a0ea272761793e072f2439e5b8e5f30e13 (patch) | |
tree | 53199c878a8d509b1dc04274357c6e910f597f79 /OpenSim/Data/NHibernate | |
parent | * Apply http://opensimulator.org/mantis/view.php?id=3012 (diff) | |
download | opensim-SC-37f7c5a0ea272761793e072f2439e5b8e5f30e13.zip opensim-SC-37f7c5a0ea272761793e072f2439e5b8e5f30e13.tar.gz opensim-SC-37f7c5a0ea272761793e072f2439e5b8e5f30e13.tar.bz2 opensim-SC-37f7c5a0ea272761793e072f2439e5b8e5f30e13.tar.xz |
* Apply http://opensimulator.org/mantis/view.php?id=3020
* Adds a grid db implementation and unit tests to the NHibernate module
Diffstat (limited to 'OpenSim/Data/NHibernate')
9 files changed, 460 insertions, 42 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateGridData.cs b/OpenSim/Data/NHibernate/NHibernateGridData.cs new file mode 100644 index 0000000..912beca --- /dev/null +++ b/OpenSim/Data/NHibernate/NHibernateGridData.cs | |||
@@ -0,0 +1,241 @@ | |||
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 OpenSim 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 | |||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using System.Reflection; | ||
34 | using OpenSim.Framework; | ||
35 | using NHibernate; | ||
36 | using NHibernate.Criterion; | ||
37 | using System.Collections; | ||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Data.NHibernate | ||
41 | { | ||
42 | |||
43 | /// <summary> | ||
44 | /// A GridData Interface to the NHibernate database | ||
45 | /// </summary> | ||
46 | public class NHibernateGridData : GridDataBase | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | public NHibernateManager manager; | ||
50 | |||
51 | public override void Initialise() | ||
52 | { | ||
53 | m_log.Info("[NHibernateGridData]: " + Name + " cannot be default-initialized!"); | ||
54 | throw new PluginNotInitialisedException(Name); | ||
55 | } | ||
56 | |||
57 | public override void Initialise(string connect) | ||
58 | { | ||
59 | m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateGridData"); | ||
60 | manager = new NHibernateManager(connect, "GridStore"); | ||
61 | } | ||
62 | |||
63 | /*********************************************************************** | ||
64 | * | ||
65 | * Public Interface Functions | ||
66 | * | ||
67 | **********************************************************************/ | ||
68 | |||
69 | public override void Dispose() { } | ||
70 | |||
71 | /// <summary> | ||
72 | /// The plugin being loaded | ||
73 | /// </summary> | ||
74 | /// <returns>A string containing the plugin name</returns> | ||
75 | public override string Name | ||
76 | { | ||
77 | get { return "NHibernate Grid Data Interface"; } | ||
78 | } | ||
79 | |||
80 | /// <summary> | ||
81 | /// The plugins version | ||
82 | /// </summary> | ||
83 | /// <returns>A string containing the plugin version</returns> | ||
84 | public override string Version | ||
85 | { | ||
86 | get | ||
87 | { | ||
88 | Module module = GetType().Module; | ||
89 | Version dllVersion = module.Assembly.GetName().Version; | ||
90 | |||
91 | return string.Format("{0}.{1}.{2}.{3}", | ||
92 | dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public override bool AuthenticateSim(OpenMetaverse.UUID UUID, ulong regionHandle, string simrecvkey) | ||
97 | { | ||
98 | bool throwHissyFit = false; // Should be true by 1.0 | ||
99 | |||
100 | if (throwHissyFit) | ||
101 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
102 | |||
103 | RegionProfileData data = GetProfileByUUID(UUID); | ||
104 | |||
105 | return (regionHandle == data.regionHandle && simrecvkey == data.regionSecret); | ||
106 | } | ||
107 | |||
108 | public override ReservationData GetReservationAtPoint(uint x, uint y) | ||
109 | { | ||
110 | throw new NotImplementedException(); | ||
111 | } | ||
112 | |||
113 | public override DataResponse AddProfile(RegionProfileData profile) | ||
114 | { | ||
115 | if (manager.Load(typeof(RegionProfileData), profile.Uuid) == null) | ||
116 | { | ||
117 | manager.Save(profile); | ||
118 | return DataResponse.RESPONSE_OK; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | return DataResponse.RESPONSE_ERROR; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public override DataResponse UpdateProfile(RegionProfileData profile) | ||
127 | { | ||
128 | if (manager.Load(typeof(RegionProfileData), profile.Uuid) != null) | ||
129 | { | ||
130 | manager.Update(profile); | ||
131 | return DataResponse.RESPONSE_OK; | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | return DataResponse.RESPONSE_ERROR; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | public override DataResponse DeleteProfile(string uuid) | ||
140 | { | ||
141 | RegionProfileData regionProfileData = (RegionProfileData)manager.Load(typeof(RegionProfileData), new UUID(uuid)); | ||
142 | if (regionProfileData != null) | ||
143 | { | ||
144 | manager.Delete(regionProfileData); | ||
145 | return DataResponse.RESPONSE_OK; | ||
146 | } | ||
147 | return DataResponse.RESPONSE_ERROR; | ||
148 | } | ||
149 | |||
150 | public override RegionProfileData GetProfileByUUID(OpenMetaverse.UUID UUID) | ||
151 | { | ||
152 | return (RegionProfileData)manager.Load(typeof(RegionProfileData), UUID); | ||
153 | } | ||
154 | |||
155 | public override RegionProfileData GetProfileByHandle(ulong regionHandle) | ||
156 | { | ||
157 | using (ISession session = manager.GetSession()) | ||
158 | { | ||
159 | ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData)); | ||
160 | criteria.Add(Expression.Eq("RegionHandle", regionHandle)); | ||
161 | |||
162 | IList regions = criteria.List(); | ||
163 | |||
164 | if (regions.Count == 1) | ||
165 | { | ||
166 | return (RegionProfileData)regions[0]; | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | return null; | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | |||
175 | public override RegionProfileData GetProfileByString(string regionName) | ||
176 | { | ||
177 | |||
178 | using (ISession session = manager.GetSession()) | ||
179 | { | ||
180 | ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData)); | ||
181 | criteria.Add(Expression.Eq("RegionName", regionName)); | ||
182 | |||
183 | IList regions = criteria.List(); | ||
184 | |||
185 | if (regions.Count == 1) | ||
186 | { | ||
187 | return (RegionProfileData)regions[0]; | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | return null; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | } | ||
196 | |||
197 | public override RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax) | ||
198 | { | ||
199 | using (ISession session = manager.GetSession()) | ||
200 | { | ||
201 | ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData)); | ||
202 | criteria.Add(Expression.Ge("RegionLocX", Xmin)); | ||
203 | criteria.Add(Expression.Ge("RegionLocY", Ymin)); | ||
204 | criteria.Add(Expression.Le("RegionLocX", Xmax)); | ||
205 | criteria.Add(Expression.Le("RegionLocY", Ymax)); | ||
206 | |||
207 | IList regions = criteria.List(); | ||
208 | RegionProfileData[] regionArray = new RegionProfileData[regions.Count]; | ||
209 | |||
210 | for(int i=0;i<regionArray.Length;i++) | ||
211 | { | ||
212 | regionArray[i] = (RegionProfileData)regions[i]; | ||
213 | } | ||
214 | |||
215 | return regionArray; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | public override List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum) | ||
220 | { | ||
221 | using (ISession session = manager.GetSession()) | ||
222 | { | ||
223 | ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData)); | ||
224 | criteria.SetMaxResults((int)maxNum); | ||
225 | |||
226 | criteria.Add(Expression.Like("RegionName", namePrefix, MatchMode.Start)); | ||
227 | |||
228 | IList regions = criteria.List(); | ||
229 | List<RegionProfileData> regionList = new List<RegionProfileData>(); | ||
230 | |||
231 | foreach (RegionProfileData regionProfileData in regions) | ||
232 | { | ||
233 | regionList.Add(regionProfileData); | ||
234 | } | ||
235 | |||
236 | return regionList; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | } | ||
241 | } | ||
diff --git a/OpenSim/Data/NHibernate/NHibernateManager.cs b/OpenSim/Data/NHibernate/NHibernateManager.cs index 0ceaf9b..8fca6fe 100644 --- a/OpenSim/Data/NHibernate/NHibernateManager.cs +++ b/OpenSim/Data/NHibernate/NHibernateManager.cs | |||
@@ -140,9 +140,9 @@ namespace OpenSim.Data.NHibernate | |||
140 | { | 140 | { |
141 | obj = session.Get(type.FullName, uuid); | 141 | obj = session.Get(type.FullName, uuid); |
142 | } | 142 | } |
143 | catch (Exception) | 143 | catch (Exception e) |
144 | { | 144 | { |
145 | m_log.ErrorFormat("[NHIBERNATE] {0} not found with ID {1} ", type.Name, uuid); | 145 | m_log.ErrorFormat("[NHIBERNATE] {0} of id {1} loading threw exception: "+ e.ToString(), type.Name, uuid); |
146 | } | 146 | } |
147 | return obj; | 147 | return obj; |
148 | } | 148 | } |
diff --git a/OpenSim/Data/NHibernate/Resources/MsSql2005Dialect/001_GridStore.sql b/OpenSim/Data/NHibernate/Resources/MsSql2005Dialect/001_GridStore.sql index 0dfec7f..e4ad525 100644 --- a/OpenSim/Data/NHibernate/Resources/MsSql2005Dialect/001_GridStore.sql +++ b/OpenSim/Data/NHibernate/Resources/MsSql2005Dialect/001_GridStore.sql | |||
@@ -1,5 +1,5 @@ | |||
1 | create table Regions ( | 1 | create table Regions ( |
2 | Uuid NVARCHAR(255) not null, | 2 | Uuid NVARCHAR(36) not null, |
3 | RegionHandle BIGINT null, | 3 | RegionHandle BIGINT null, |
4 | RegionName NVARCHAR(32) null, | 4 | RegionName NVARCHAR(32) null, |
5 | RegionRecvKey NVARCHAR(128) null, | 5 | RegionRecvKey NVARCHAR(128) null, |
@@ -24,9 +24,9 @@ create table Regions ( | |||
24 | RegionUserSendKey NVARCHAR(128) null, | 24 | RegionUserSendKey NVARCHAR(128) null, |
25 | ServerHttpPort INT null, | 25 | ServerHttpPort INT null, |
26 | ServerRemotingPort INT null, | 26 | ServerRemotingPort INT null, |
27 | RegionMapTextureID NVARCHAR(255) null, | 27 | RegionMapTextureID NVARCHAR(36) null, |
28 | Owner_uuid NVARCHAR(255) null, | 28 | Owner_uuid NVARCHAR(36) null, |
29 | OriginUUID NVARCHAR(255) null, | 29 | OriginUUID NVARCHAR(36) null, |
30 | primary key (Uuid) | 30 | primary key (Uuid) |
31 | ) | 31 | ) |
32 | create index region_handle on Regions (RegionHandle) | 32 | create index region_handle on Regions (RegionHandle) |
diff --git a/OpenSim/Data/NHibernate/Resources/MySQLDialect/001_GridStore.sql b/OpenSim/Data/NHibernate/Resources/MySQLDialect/001_GridStore.sql index 5fb1c19..c6fe620 100644 --- a/OpenSim/Data/NHibernate/Resources/MySQLDialect/001_GridStore.sql +++ b/OpenSim/Data/NHibernate/Resources/MySQLDialect/001_GridStore.sql | |||
@@ -24,10 +24,10 @@ CREATE TABLE Regions ( | |||
24 | RegionUserURI VARCHAR(255) DEFAULT NULL, | 24 | RegionUserURI VARCHAR(255) DEFAULT NULL, |
25 | RegionUserRecvKey VARCHAR(128) DEFAULT NULL, | 25 | RegionUserRecvKey VARCHAR(128) DEFAULT NULL, |
26 | RegionUserSendKey VARCHAR(128) DEFAULT NULL, | 26 | RegionUserSendKey VARCHAR(128) DEFAULT NULL, |
27 | RegionMapTexture VARCHAR(36) DEFAULT NULL, | 27 | RegionMapTextureId VARCHAR(36) DEFAULT NULL, |
28 | ServerHttpPort INT DEFAULT NULL, | 28 | ServerHttpPort INT DEFAULT NULL, |
29 | ServerRemotingPort INT DEFAULT NULL, | 29 | ServerRemotingPort INT DEFAULT NULL, |
30 | PRIMARY KEY (uuid), | 30 | PRIMARY KEY (RegionID) |
31 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; | 31 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; |
32 | 32 | ||
33 | CREATE INDEX RegionNameIndex ON Regions (RegionName); | 33 | CREATE INDEX RegionNameIndex ON Regions (RegionName); |
diff --git a/OpenSim/Data/NHibernate/Resources/RegionProfileData.hbm.xml b/OpenSim/Data/NHibernate/Resources/RegionProfileData.hbm.xml new file mode 100644 index 0000000..5ff37d8 --- /dev/null +++ b/OpenSim/Data/NHibernate/Resources/RegionProfileData.hbm.xml | |||
@@ -0,0 +1,44 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | ||
2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> | ||
3 | <class name="OpenSim.Data.RegionProfileData, OpenSim.Data" table="Regions" lazy="false"> | ||
4 | <id name="Uuid" column="RegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"> | ||
5 | <generator class="assigned" /> | ||
6 | </id> | ||
7 | |||
8 | <property name="Owner_uuid" column="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> | ||
9 | <property name="OriginUUID" column="OriginID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> | ||
10 | |||
11 | <property name="RegionHandle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
12 | <property name="RegionName" type="String" length="32" /> | ||
13 | <property name="RegionRecvKey" type="String" length="128" /> | ||
14 | <property name="RegionSendKey" type="String" length="128" /> | ||
15 | <property name="RegionSecret" type="String" length="128" /> | ||
16 | <property name="RegionDataURI" type="String" length="255" /> | ||
17 | |||
18 | <property name="ServerIP" type="String" length="64" /> | ||
19 | <property name="ServerPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
20 | <property name="ServerURI" type="String" length="255" /> | ||
21 | |||
22 | <property name="RegionLocX" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
23 | <property name="RegionLocY" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
24 | <property name="RegionLocZ" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
25 | |||
26 | <property name="EastOverrideHandle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
27 | <property name="WestOverrideHandle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
28 | <property name="SouthOverrideHandle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
29 | <property name="NorthOverrideHandle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
30 | |||
31 | <property name="RegionAssetURI" type="String" length="255" /> | ||
32 | <property name="RegionAssetRecvKey" type="String" length="128" /> | ||
33 | <property name="RegionAssetSendKey" type="String" length="128" /> | ||
34 | |||
35 | <property name="RegionUserURI" type="String" length="255" /> | ||
36 | <property name="RegionUserRecvKey" type="String" length="128" /> | ||
37 | <property name="RegionUserSendKey" type="String" length="128" /> | ||
38 | <property name="RegionMapTextureID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> | ||
39 | |||
40 | <property name="ServerHttpPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
41 | <property name="ServerRemotingPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
42 | |||
43 | </class> | ||
44 | </hibernate-mapping> | ||
diff --git a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml index 3144b0b..189389f 100644 --- a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml | |||
@@ -141,36 +141,5 @@ | |||
141 | <property name="Flags" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | 141 | <property name="Flags" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> |
142 | <property name="InvType" type="System.Int32" /> | 142 | <property name="InvType" type="System.Int32" /> |
143 | </class> | 143 | </class> |
144 | <class name="OpenSim.Data.RegionProfileData, OpenSim.Data" table="Regions" lazy="false"> | 144 | |
145 | <id name="Uuid" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"> | ||
146 | <generator class="assigned" /> | ||
147 | </id> | ||
148 | <property name="RegionHandle" index="region_handle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
149 | <property name="RegionName" index="region_name" type="String" length="32"/> | ||
150 | <property name="RegionRecvKey" type="String" length="128"/> | ||
151 | <property name="RegionSendKey" type="String" length="128"/> | ||
152 | <property name="RegionSecret" type="String" length="128"/> | ||
153 | <property name="RegionDataURI" type="String" length="255"/> | ||
154 | <property name="ServerIP" type="String" length="64"/> | ||
155 | <property name="ServerPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
156 | <property name="ServerURI" type="String" length="255"/> | ||
157 | <property name="RegionLocX" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
158 | <property name="RegionLocY" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
159 | <property name="RegionLocZ" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
160 | <property name="EastOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
161 | <property name="WestOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
162 | <property name="SouthOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
163 | <property name="NorthOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> | ||
164 | <property name="RegionAssetURI" type="String" length="255"/> | ||
165 | <property name="RegionAssetRecvKey" type="String" length="128"/> | ||
166 | <property name="RegionAssetSendKey" type="String" length="128"/> | ||
167 | <property name="RegionUserURI" type="String" length="255"/> | ||
168 | <property name="RegionUserRecvKey" type="String" length="128"/> | ||
169 | <property name="RegionUserSendKey" type="String" length="128"/> | ||
170 | <property name="ServerHttpPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
171 | <property name="ServerRemotingPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> | ||
172 | <property name="RegionMapTextureID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/> | ||
173 | <property name="Owner_uuid" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/> | ||
174 | <property name="OriginUUID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/> | ||
175 | </class> | ||
176 | </hibernate-mapping> | 145 | </hibernate-mapping> |
diff --git a/OpenSim/Data/NHibernate/Resources/SQLiteDialect/001_GridStore.sql b/OpenSim/Data/NHibernate/Resources/SQLiteDialect/001_GridStore.sql index 336a277..4f09848 100644 --- a/OpenSim/Data/NHibernate/Resources/SQLiteDialect/001_GridStore.sql +++ b/OpenSim/Data/NHibernate/Resources/SQLiteDialect/001_GridStore.sql | |||
@@ -22,12 +22,12 @@ CREATE TABLE Regions ( | |||
22 | RegionUserURI VARCHAR(255) DEFAULT NULL, | 22 | RegionUserURI VARCHAR(255) DEFAULT NULL, |
23 | RegionUserRecvKey VARCHAR(128) DEFAULT NULL, | 23 | RegionUserRecvKey VARCHAR(128) DEFAULT NULL, |
24 | RegionUserSendKey VARCHAR(128) DEFAULT NULL, | 24 | RegionUserSendKey VARCHAR(128) DEFAULT NULL, |
25 | regionMapTexture VARCHAR(36) DEFAULT NULL, | 25 | RegionMapTextureId VARCHAR(36) DEFAULT NULL, |
26 | ServerHttpPort INT DEFAULT NULL, | 26 | ServerHttpPort INT DEFAULT NULL, |
27 | ServerRemotingPort INT DEFAULT NULL, | 27 | ServerRemotingPort INT DEFAULT NULL, |
28 | OwnerID VARCHAR(36) DEFAULT NULL, | 28 | OwnerID VARCHAR(36) DEFAULT NULL, |
29 | OriginID VARCHAR(36) DEFAULT NULL, | 29 | OriginID VARCHAR(36) DEFAULT NULL, |
30 | PRIMARY KEY (uuid), | 30 | PRIMARY KEY (RegionId) |
31 | ); | 31 | ); |
32 | 32 | ||
33 | CREATE INDEX RegionNameIndex ON Regions (RegionName); | 33 | CREATE INDEX RegionNameIndex ON Regions (RegionName); |
diff --git a/OpenSim/Data/NHibernate/Tests/NHibernateMySQLGridTest.cs b/OpenSim/Data/NHibernate/Tests/NHibernateMySQLGridTest.cs new file mode 100644 index 0000000..0abb8ee --- /dev/null +++ b/OpenSim/Data/NHibernate/Tests/NHibernateMySQLGridTest.cs | |||
@@ -0,0 +1,82 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Collections.Generic; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data.Tests; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Data.NHibernate; | ||
38 | |||
39 | namespace OpenSim.Data.NHibernate.Tests | ||
40 | { | ||
41 | [TestFixture] | ||
42 | public class NHibernateMySQLGridTest : BasicGridTest | ||
43 | { | ||
44 | public string file; | ||
45 | public NHibernateManager database; | ||
46 | public string connect = "MySQL5Dialect;MySqlDataDriver;Server=localhost;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit"; | ||
47 | |||
48 | [TestFixtureSetUp] | ||
49 | public void Init() | ||
50 | { | ||
51 | SuperInit(); | ||
52 | // If we manage to connect to the database with the user | ||
53 | // and password above it is our test database, and run | ||
54 | // these tests. If anything goes wrong, ignore these | ||
55 | // tests. | ||
56 | try | ||
57 | { | ||
58 | db = new NHibernateGridData(); | ||
59 | db.Initialise(connect); | ||
60 | database = ((NHibernateGridData)db).manager; | ||
61 | } | ||
62 | catch (Exception e) | ||
63 | { | ||
64 | System.Console.WriteLine("Exception {0}", e); | ||
65 | Assert.Ignore(); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | [TestFixtureTearDown] | ||
70 | public void Cleanup() | ||
71 | { | ||
72 | if (db != null) | ||
73 | { | ||
74 | db.Dispose(); | ||
75 | } | ||
76 | if (database != null) | ||
77 | { | ||
78 | database.DropSchema(); | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/NHibernate/Tests/NHibernateSQLiteGridTest.cs b/OpenSim/Data/NHibernate/Tests/NHibernateSQLiteGridTest.cs new file mode 100644 index 0000000..a7a0c93 --- /dev/null +++ b/OpenSim/Data/NHibernate/Tests/NHibernateSQLiteGridTest.cs | |||
@@ -0,0 +1,82 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Collections.Generic; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data.Tests; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Data.NHibernate; | ||
38 | |||
39 | namespace OpenSim.Data.NHibernate.Tests | ||
40 | { | ||
41 | [TestFixture] | ||
42 | public class NHibernateSQLiteGridTest : BasicGridTest | ||
43 | { | ||
44 | public string file; | ||
45 | public NHibernateManager database; | ||
46 | public string connect = "SQLiteDialect;SQLite20Driver;Data Source=" + Path.GetTempFileName() + ".db;Version=3"; | ||
47 | |||
48 | [TestFixtureSetUp] | ||
49 | public void Init() | ||
50 | { | ||
51 | SuperInit(); | ||
52 | // If we manage to connect to the database with the user | ||
53 | // and password above it is our test database, and run | ||
54 | // these tests. If anything goes wrong, ignore these | ||
55 | // tests. | ||
56 | try | ||
57 | { | ||
58 | db = new NHibernateGridData(); | ||
59 | db.Initialise(connect); | ||
60 | database = ((NHibernateGridData)db).manager; | ||
61 | } | ||
62 | catch (Exception e) | ||
63 | { | ||
64 | System.Console.WriteLine("Exception {0}", e); | ||
65 | Assert.Ignore(); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | [TestFixtureTearDown] | ||
70 | public void Cleanup() | ||
71 | { | ||
72 | if (db != null) | ||
73 | { | ||
74 | db.Dispose(); | ||
75 | } | ||
76 | if (database != null) | ||
77 | { | ||
78 | database.DropSchema(); | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | } \ No newline at end of file | ||