diff options
Diffstat (limited to 'OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs')
-rw-r--r-- | OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs | 271 |
1 files changed, 0 insertions, 271 deletions
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs deleted file mode 100644 index 46fecd0..0000000 --- a/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs +++ /dev/null | |||
@@ -1,271 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using Db4objects.Db4o; | ||
31 | using Db4objects.Db4o.Query; | ||
32 | |||
33 | using libsecondlife; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using OpenSim.Framework.Terrain; | ||
37 | using OpenSim.Framework.Console; | ||
38 | |||
39 | |||
40 | namespace OpenSim.Storage.LocalStorageDb4o | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// | ||
44 | /// </summary> | ||
45 | public class Db4LocalStorage : ILocalStorage | ||
46 | { | ||
47 | private IObjectContainer db; | ||
48 | private string datastore; | ||
49 | |||
50 | public Db4LocalStorage() | ||
51 | { | ||
52 | |||
53 | } | ||
54 | |||
55 | public void Initialise(string dfile) | ||
56 | { | ||
57 | OpenSim.Framework.Console.MainConsole.Instance.Warn("Db4LocalStorage Opening " + dfile); | ||
58 | datastore = dfile; | ||
59 | try | ||
60 | { | ||
61 | db = Db4oFactory.OpenFile(datastore); | ||
62 | OpenSim.Framework.Console.MainConsole.Instance.Verbose("Db4LocalStorage creation"); | ||
63 | } | ||
64 | catch (Exception e) | ||
65 | { | ||
66 | db.Close(); | ||
67 | OpenSim.Framework.Console.MainConsole.Instance.Warn("Db4LocalStorage :Constructor - Exception occured"); | ||
68 | OpenSim.Framework.Console.MainConsole.Instance.Warn(e.ToString()); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void StorePrim(PrimData prim) | ||
73 | { | ||
74 | IObjectSet result = db.Query(new UUIDPrimQuery(prim.FullID)); | ||
75 | if(result.Count>0) | ||
76 | { | ||
77 | //prim already in storage | ||
78 | //so update it | ||
79 | PrimData found = (PrimData) result.Next(); | ||
80 | found.PathBegin = prim.PathBegin; | ||
81 | found.PathCurve= prim.PathCurve; | ||
82 | found.PathEnd = prim.PathEnd; | ||
83 | found.PathRadiusOffset = prim.PathRadiusOffset; | ||
84 | found.PathRevolutions = prim.PathRevolutions; | ||
85 | found.PathScaleX= prim.PathScaleX; | ||
86 | found.PathScaleY = prim.PathScaleY; | ||
87 | found.PathShearX = prim.PathShearX; | ||
88 | found.PathShearY = prim.PathShearY; | ||
89 | found.PathSkew = prim.PathSkew; | ||
90 | found.PathTaperX = prim.PathTaperX; | ||
91 | found.PathTaperY = prim.PathTaperY; | ||
92 | found.PathTwist = prim.PathTwist; | ||
93 | found.PathTwistBegin = prim.PathTwistBegin; | ||
94 | found.PCode = prim.PCode; | ||
95 | found.ProfileBegin = prim.ProfileBegin; | ||
96 | found.ProfileCurve = prim.ProfileCurve; | ||
97 | found.ProfileEnd = prim.ProfileEnd; | ||
98 | found.ProfileHollow = prim.ProfileHollow; | ||
99 | found.Position = prim.Position; | ||
100 | found.Rotation = prim.Rotation; | ||
101 | found.Texture = prim.Texture; | ||
102 | db.Set(found); | ||
103 | db.Commit(); | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | //not in storage | ||
108 | db.Set(prim); | ||
109 | db.Commit(); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public void RemovePrim(LLUUID primID) | ||
114 | { | ||
115 | IObjectSet result = db.Query(new UUIDPrimQuery(primID)); | ||
116 | if(result.Count>0) | ||
117 | { | ||
118 | PrimData found = (PrimData) result.Next(); | ||
119 | db.Delete(found); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | |||
124 | public void LoadPrimitives(ILocalStorageReceiver receiver) | ||
125 | { | ||
126 | IObjectSet result = db.Get(typeof(PrimData)); | ||
127 | OpenSim.Framework.Console.MainConsole.Instance.Verbose("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count); | ||
128 | foreach (PrimData prim in result) { | ||
129 | receiver.PrimFromStorage(prim); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | public float[] LoadWorld() | ||
134 | { | ||
135 | OpenSim.Framework.Console.MainConsole.Instance.Verbose("LoadWorld() - Loading world...."); | ||
136 | float[] heightmap = null; | ||
137 | OpenSim.Framework.Console.MainConsole.Instance.Verbose("LoadWorld() - Looking for a heightmap in local DB"); | ||
138 | IObjectSet world_result = db.Get(typeof(MapStorage)); | ||
139 | if (world_result.Count > 0) | ||
140 | { | ||
141 | OpenSim.Framework.Console.MainConsole.Instance.Verbose("LoadWorld() - Found a heightmap in local database, loading"); | ||
142 | MapStorage map = (MapStorage)world_result.Next(); | ||
143 | //blank.LandMap = map.Map; | ||
144 | heightmap = map.Map; | ||
145 | } | ||
146 | return heightmap; | ||
147 | } | ||
148 | |||
149 | public void SaveMap(float[] heightmap) | ||
150 | { | ||
151 | IObjectSet world_result = db.Get(typeof(MapStorage)); | ||
152 | if (world_result.Count > 0) | ||
153 | { | ||
154 | OpenSim.Framework.Console.MainConsole.Instance.Verbose("SaveWorld() - updating saved copy of heightmap in local database"); | ||
155 | MapStorage map = (MapStorage)world_result.Next(); | ||
156 | db.Delete(map); | ||
157 | } | ||
158 | MapStorage map1 = new MapStorage(); | ||
159 | map1.Map = heightmap; //OpenSim_Main.local_world.LandMap; | ||
160 | db.Set(map1); | ||
161 | db.Commit(); | ||
162 | } | ||
163 | |||
164 | public void SaveParcel(ParcelData parcel) | ||
165 | { | ||
166 | IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID)); | ||
167 | if (result.Count > 0) | ||
168 | { | ||
169 | //Old Parcel | ||
170 | ParcelData updateParcel = (ParcelData)result.Next(); | ||
171 | updateParcel.AABBMax = parcel.AABBMax; | ||
172 | updateParcel.AABBMin = parcel.AABBMin; | ||
173 | updateParcel.area = parcel.area; | ||
174 | updateParcel.auctionID = parcel.auctionID; | ||
175 | updateParcel.authBuyerID = parcel.authBuyerID; | ||
176 | updateParcel.category = parcel.category; | ||
177 | updateParcel.claimDate = parcel.claimDate; | ||
178 | updateParcel.claimPrice = parcel.claimPrice; | ||
179 | updateParcel.groupID = parcel.groupID; | ||
180 | updateParcel.groupPrims = parcel.groupPrims; | ||
181 | updateParcel.isGroupOwned = parcel.isGroupOwned; | ||
182 | updateParcel.landingType = parcel.landingType; | ||
183 | updateParcel.mediaAutoScale = parcel.mediaAutoScale; | ||
184 | updateParcel.mediaID = parcel.mediaID; | ||
185 | updateParcel.mediaURL = parcel.mediaURL; | ||
186 | updateParcel.musicURL = parcel.musicURL; | ||
187 | updateParcel.localID = parcel.localID; | ||
188 | updateParcel.ownerID = parcel.ownerID; | ||
189 | updateParcel.passHours = parcel.passHours; | ||
190 | updateParcel.passPrice = parcel.passPrice; | ||
191 | updateParcel.parcelBitmapByteArray = (byte[])parcel.parcelBitmapByteArray.Clone(); | ||
192 | updateParcel.parcelDesc = parcel.parcelDesc; | ||
193 | updateParcel.parcelFlags = parcel.parcelFlags; | ||
194 | updateParcel.parcelName = parcel.parcelName; | ||
195 | updateParcel.parcelStatus = parcel.parcelStatus; | ||
196 | updateParcel.salePrice = parcel.salePrice; | ||
197 | updateParcel.snapshotID = parcel.snapshotID; | ||
198 | updateParcel.userLocation = parcel.userLocation; | ||
199 | updateParcel.userLookAt = parcel.userLookAt; | ||
200 | |||
201 | db.Set(updateParcel); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | db.Set(parcel); | ||
206 | } | ||
207 | db.Commit(); | ||
208 | } | ||
209 | |||
210 | public void SaveParcels(ParcelData[] parcel_data) | ||
211 | { | ||
212 | MainConsole.Instance.Notice("Parcel Backup: Saving Parcels..."); | ||
213 | int i; | ||
214 | for (i = 0; i < parcel_data.GetLength(0); i++) | ||
215 | { | ||
216 | |||
217 | SaveParcel(parcel_data[i]); | ||
218 | |||
219 | } | ||
220 | MainConsole.Instance.Notice("Parcel Backup: Parcel Save Complete"); | ||
221 | } | ||
222 | |||
223 | public void RemoveParcel(ParcelData parcel) | ||
224 | { | ||
225 | IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID)); | ||
226 | if (result.Count > 0) | ||
227 | { | ||
228 | db.Delete(result[0]); | ||
229 | } | ||
230 | db.Commit(); | ||
231 | } | ||
232 | public void RemoveAllParcels() | ||
233 | { | ||
234 | MainConsole.Instance.Notice("Parcel Backup: Removing all parcels..."); | ||
235 | IObjectSet result = db.Get(typeof(ParcelData)); | ||
236 | if (result.Count > 0) | ||
237 | { | ||
238 | foreach (ParcelData parcelData in result) | ||
239 | { | ||
240 | RemoveParcel(parcelData); | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | |||
245 | public void LoadParcels(ILocalStorageParcelReceiver recv) | ||
246 | { | ||
247 | MainConsole.Instance.Notice("Parcel Backup: Loading Parcels..."); | ||
248 | IObjectSet result = db.Get(typeof(ParcelData)); | ||
249 | if (result.Count > 0) | ||
250 | { | ||
251 | MainConsole.Instance.Notice("Parcel Backup: Parcels exist in database."); | ||
252 | foreach (ParcelData parcelData in result) | ||
253 | { | ||
254 | |||
255 | recv.ParcelFromStorage(parcelData); | ||
256 | } | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | MainConsole.Instance.Notice("Parcel Backup: No parcels exist. Creating basic parcel."); | ||
261 | recv.NoParcelDataFromStorage(); | ||
262 | } | ||
263 | MainConsole.Instance.Notice("Parcel Backup: Parcels Restored"); | ||
264 | } | ||
265 | public void ShutDown() | ||
266 | { | ||
267 | db.Commit(); | ||
268 | db.Close(); | ||
269 | } | ||
270 | } | ||
271 | } \ No newline at end of file | ||