diff options
author | John Hurliman | 2009-10-19 16:52:27 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-19 16:52:27 -0700 |
commit | fdce1be3db287bed901332b90ba57165e201d3fc (patch) | |
tree | 8f0792e4c4ac4c14a50559f8439573740a7b3326 /OpenSim/Data/NHibernate/NHibernateEstateData.cs | |
parent | Merge branch 'prioritization' of ssh://opensimulator.org/var/git/opensim into... (diff) | |
download | opensim-SC_OLD-fdce1be3db287bed901332b90ba57165e201d3fc.zip opensim-SC_OLD-fdce1be3db287bed901332b90ba57165e201d3fc.tar.gz opensim-SC_OLD-fdce1be3db287bed901332b90ba57165e201d3fc.tar.bz2 opensim-SC_OLD-fdce1be3db287bed901332b90ba57165e201d3fc.tar.xz |
* Removed OpenSim.Data.NHibernate
* Replaced calls to ThreadPool.QueueUserWorkItem() with ThreadPool.UnsafeQueueUserWorkItem() since OpenSim does not use Code Access Security sandboxing
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateEstateData.cs | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateEstateData.cs b/OpenSim/Data/NHibernate/NHibernateEstateData.cs deleted file mode 100644 index 5c5be9f..0000000 --- a/OpenSim/Data/NHibernate/NHibernateEstateData.cs +++ /dev/null | |||
@@ -1,168 +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 | using System.Reflection; | ||
29 | using log4net; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using NHibernate; | ||
34 | using NHibernate.Criterion; | ||
35 | using System.Collections; | ||
36 | using System; | ||
37 | |||
38 | namespace OpenSim.Data.NHibernate | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A User storage interface for the DB4o database system | ||
42 | /// </summary> | ||
43 | public class NHibernateEstateData : IEstateDataStore | ||
44 | { | ||
45 | |||
46 | #region Fields | ||
47 | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private NHibernateManager manager; | ||
51 | public NHibernateManager Manager | ||
52 | { | ||
53 | get | ||
54 | { | ||
55 | return manager; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "NHibernateEstateData"; } | ||
62 | } | ||
63 | |||
64 | public string Version | ||
65 | { | ||
66 | get { return "0.1"; } | ||
67 | } | ||
68 | |||
69 | #endregion | ||
70 | |||
71 | #region Startup and shutdown. | ||
72 | |||
73 | public void Initialise() | ||
74 | { | ||
75 | m_log.Info("[NHIBERNATE]: " + Name + " cannot be default-initialized!"); | ||
76 | throw new PluginNotInitialisedException(Name); | ||
77 | } | ||
78 | |||
79 | public void Initialise(string connect) | ||
80 | { | ||
81 | |||
82 | m_log.InfoFormat("[NHIBERNATE] Initializing " + Name + "."); | ||
83 | manager = new NHibernateManager(connect, "EstateStore"); | ||
84 | } | ||
85 | |||
86 | public void Dispose() { } | ||
87 | |||
88 | #endregion | ||
89 | |||
90 | #region IEstateDataStore Members | ||
91 | |||
92 | public EstateSettings LoadEstateSettings(UUID regionID) | ||
93 | { | ||
94 | EstateRegionLink link = LoadEstateRegionLink(regionID); | ||
95 | |||
96 | // Ensure that estate settings exist for the link | ||
97 | if (link != null) | ||
98 | { | ||
99 | if (manager.GetWithStatefullSession(typeof(EstateSettings), link.EstateID) == null) | ||
100 | { | ||
101 | // Delete broken link | ||
102 | manager.Delete(link); | ||
103 | link = null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | // If estate link does not exist create estate settings and link it to region. | ||
108 | if (link == null) | ||
109 | { | ||
110 | EstateSettings estateSettings = new EstateSettings(); | ||
111 | //estateSettings.EstateOwner = UUID.Random(); | ||
112 | //estateSettings.BlockDwell = false; | ||
113 | object identifier = manager.Insert(estateSettings); | ||
114 | |||
115 | if (identifier == null) | ||
116 | { | ||
117 | // Saving failed. Error is logged in the manager. | ||
118 | return null; | ||
119 | } | ||
120 | |||
121 | uint estateID = (uint)identifier; | ||
122 | link = new EstateRegionLink(); | ||
123 | link.EstateRegionLinkID = UUID.Random(); | ||
124 | link.RegionID = regionID; | ||
125 | link.EstateID = estateID; | ||
126 | manager.InsertWithStatefullSession(link); | ||
127 | } | ||
128 | |||
129 | // Load estate settings according to the existing or created link. | ||
130 | return (EstateSettings)manager.GetWithStatefullSession(typeof(EstateSettings), link.EstateID); | ||
131 | } | ||
132 | |||
133 | public void StoreEstateSettings(EstateSettings estateSettings) | ||
134 | { | ||
135 | // Estates are always updated when stored. | ||
136 | // Insert is always done via. load method as with the current API | ||
137 | // this is explicitly the only way to create region link. | ||
138 | manager.UpdateWithStatefullSession(estateSettings); | ||
139 | } | ||
140 | |||
141 | #endregion | ||
142 | |||
143 | #region Private Utility Methods | ||
144 | private EstateRegionLink LoadEstateRegionLink(UUID regionID) | ||
145 | { | ||
146 | ICriteria criteria = manager.GetSession().CreateCriteria(typeof(EstateRegionLink)); | ||
147 | criteria.Add(Expression.Eq("RegionID", regionID)); | ||
148 | IList links = criteria.List(); | ||
149 | |||
150 | // Fail fast if more than one estate links exist | ||
151 | if (links.Count > 1) | ||
152 | { | ||
153 | m_log.Error("[NHIBERNATE]: Region had more than one estate linked: " + regionID); | ||
154 | throw new Exception("[NHIBERNATE]: Region had more than one estate linked: " + regionID); | ||
155 | } | ||
156 | |||
157 | if (links.Count == 1) | ||
158 | { | ||
159 | return (EstateRegionLink)links[0]; | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | return null; | ||
164 | } | ||
165 | } | ||
166 | #endregion | ||
167 | } | ||
168 | } | ||