aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateGridData.cs
diff options
context:
space:
mode:
authorMelanie2009-10-22 07:12:10 +0100
committerMelanie2009-10-22 07:12:10 +0100
commitc4969d47d9bbc22b37054451cd31451ca8d8c78a (patch)
tree788e3b034254bcf068ca950ee97a78b6aa07b386 /OpenSim/Data/NHibernate/NHibernateGridData.cs
parentMerge branch 'master' into vehicles (diff)
parentRemove the "mel_t" from version string (diff)
downloadopensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.zip
opensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.tar.gz
opensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.tar.bz2
opensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateGridData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateGridData.cs236
1 files changed, 0 insertions, 236 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateGridData.cs b/OpenSim/Data/NHibernate/NHibernateGridData.cs
deleted file mode 100644
index 018af62..0000000
--- a/OpenSim/Data/NHibernate/NHibernateGridData.cs
+++ /dev/null
@@ -1,236 +0,0 @@
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
28
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Reflection;
33using log4net;
34using NHibernate;
35using NHibernate.Criterion;
36using OpenMetaverse;
37using OpenSim.Framework;
38
39namespace OpenSim.Data.NHibernate
40{
41
42 /// <summary>
43 /// A GridData Interface to the NHibernate database
44 /// </summary>
45 public class NHibernateGridData : GridDataBase
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private NHibernateManager manager;
50 public NHibernateManager Manager
51 {
52 get
53 {
54 return manager;
55 }
56 }
57
58 public override void Initialise()
59 {
60 m_log.Info("[NHibernateGridData]: " + Name + " cannot be default-initialized!");
61 throw new PluginNotInitialisedException(Name);
62 }
63
64 public override void Initialise(string connect)
65 {
66 m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateGridData");
67 manager = new NHibernateManager(connect, "GridStore");
68 }
69
70 /***********************************************************************
71 *
72 * Public Interface Functions
73 *
74 **********************************************************************/
75
76 public override void Dispose() { }
77
78 /// <summary>
79 /// The plugin being loaded
80 /// </summary>
81 /// <returns>A string containing the plugin name</returns>
82 public override string Name
83 {
84 get { return "NHibernate Grid Data Interface"; }
85 }
86
87 /// <summary>
88 /// The plugins version
89 /// </summary>
90 /// <returns>A string containing the plugin version</returns>
91 public override string Version
92 {
93 get
94 {
95 Module module = GetType().Module;
96 Version dllVersion = module.Assembly.GetName().Version;
97
98 return string.Format("{0}.{1}.{2}.{3}",
99 dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
100 }
101 }
102
103 public override bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey)
104 {
105 bool throwHissyFit = false; // Should be true by 1.0
106
107 if (throwHissyFit)
108 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
109
110 RegionProfileData data = GetProfileByUUID(UUID);
111
112 return (regionHandle == data.regionHandle && simrecvkey == data.regionSecret);
113 }
114
115 public override ReservationData GetReservationAtPoint(uint x, uint y)
116 {
117 throw new NotImplementedException();
118 }
119
120 public override DataResponse StoreProfile(RegionProfileData profile)
121 {
122 if (manager.Get(typeof(RegionProfileData), profile.Uuid) == null)
123 {
124 manager.Insert(profile);
125 return DataResponse.RESPONSE_OK;
126 }
127 else
128 {
129 manager.Update(profile);
130 return DataResponse.RESPONSE_OK;
131 }
132 }
133
134 public override DataResponse DeleteProfile(string uuid)
135 {
136 RegionProfileData regionProfileData = (RegionProfileData)manager.Get(typeof(RegionProfileData), new UUID(uuid));
137 if (regionProfileData != null)
138 {
139 manager.Delete(regionProfileData);
140 return DataResponse.RESPONSE_OK;
141 }
142 return DataResponse.RESPONSE_ERROR;
143 }
144
145 public override RegionProfileData GetProfileByUUID(UUID UUID)
146 {
147 return (RegionProfileData)manager.Get(typeof(RegionProfileData), UUID);
148 }
149
150 public override RegionProfileData GetProfileByHandle(ulong regionHandle)
151 {
152 using (ISession session = manager.GetSession())
153 {
154 ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData));
155 criteria.Add(Expression.Eq("RegionHandle", regionHandle));
156
157 IList regions = criteria.List();
158
159 if (regions.Count == 1)
160 {
161 return (RegionProfileData)regions[0];
162 }
163 else
164 {
165 return null;
166 }
167 }
168 }
169
170 public override RegionProfileData GetProfileByString(string regionName)
171 {
172
173 using (ISession session = manager.GetSession())
174 {
175 ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData));
176 criteria.Add(Expression.Eq("RegionName", regionName));
177
178 IList regions = criteria.List();
179
180 if (regions.Count == 1)
181 {
182 return (RegionProfileData)regions[0];
183 }
184 else
185 {
186 return null;
187 }
188 }
189
190 }
191
192 public override RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax)
193 {
194 using (ISession session = manager.GetSession())
195 {
196 ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData));
197 criteria.Add(Expression.Ge("RegionLocX", Xmin));
198 criteria.Add(Expression.Ge("RegionLocY", Ymin));
199 criteria.Add(Expression.Le("RegionLocX", Xmax));
200 criteria.Add(Expression.Le("RegionLocY", Ymax));
201
202 IList regions = criteria.List();
203 RegionProfileData[] regionArray = new RegionProfileData[regions.Count];
204
205 for (int i=0;i<regionArray.Length;i++)
206 {
207 regionArray[i] = (RegionProfileData)regions[i];
208 }
209
210 return regionArray;
211 }
212 }
213
214 public override List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum)
215 {
216 using (ISession session = manager.GetSession())
217 {
218 ICriteria criteria = session.CreateCriteria(typeof(RegionProfileData));
219 criteria.SetMaxResults((int)maxNum);
220
221 criteria.Add(Expression.Like("RegionName", namePrefix, MatchMode.Start));
222
223 IList regions = criteria.List();
224 List<RegionProfileData> regionList = new List<RegionProfileData>();
225
226 foreach (RegionProfileData regionProfileData in regions)
227 {
228 regionList.Add(regionProfileData);
229 }
230
231 return regionList;
232 }
233 }
234
235 }
236}