diff options
author | Sean Dague | 2008-05-01 20:33:43 +0000 |
---|---|---|
committer | Sean Dague | 2008-05-01 20:33:43 +0000 |
commit | cc5351ec1b39fa1bcc75379bf74000e5690c137d (patch) | |
tree | f422571ccb3928565403cbbd63f9af85c5c024fb /OpenSim/Framework | |
parent | remove DB4o, we're pretty sure no one uses this, and (diff) | |
download | opensim-SC_OLD-cc5351ec1b39fa1bcc75379bf74000e5690c137d.zip opensim-SC_OLD-cc5351ec1b39fa1bcc75379bf74000e5690c137d.tar.gz opensim-SC_OLD-cc5351ec1b39fa1bcc75379bf74000e5690c137d.tar.bz2 opensim-SC_OLD-cc5351ec1b39fa1bcc75379bf74000e5690c137d.tar.xz |
remove the db4o asset server
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServer.cs | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs deleted file mode 100644 index 891fa6d..0000000 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ /dev/null | |||
@@ -1,145 +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 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 | using System.IO; | ||
28 | using System.Reflection; | ||
29 | using Db4objects.Db4o; | ||
30 | using Db4objects.Db4o.Query; | ||
31 | using libsecondlife; | ||
32 | using log4net; | ||
33 | |||
34 | namespace OpenSim.Framework.Communications.Cache | ||
35 | { | ||
36 | public class LocalAssetServer : AssetServerBase | ||
37 | { | ||
38 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | |||
40 | private IObjectContainer db; | ||
41 | |||
42 | public LocalAssetServer() | ||
43 | { | ||
44 | bool yapfile; | ||
45 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); | ||
46 | |||
47 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); | ||
48 | m_log.Info("[ASSETS]: Db4 Asset database creation"); | ||
49 | |||
50 | if (!yapfile) | ||
51 | { | ||
52 | SetUpAssetDatabase(); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | public void CreateAndCommitAsset(AssetBase asset) | ||
57 | { | ||
58 | AssetStorage store = new AssetStorage(); | ||
59 | store.Data = asset.Data; | ||
60 | store.Name = asset.Name; | ||
61 | store.UUID = asset.FullID; | ||
62 | db.Set(store); | ||
63 | db.Commit(); | ||
64 | } | ||
65 | |||
66 | public override void Close() | ||
67 | { | ||
68 | base.Close(); | ||
69 | |||
70 | if (db != null) | ||
71 | { | ||
72 | m_log.Info("[ASSETSERVER]: Closing local asset server database"); | ||
73 | db.Close(); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | protected override AssetBase GetAsset(AssetRequest req) | ||
78 | { | ||
79 | byte[] idata = null; | ||
80 | bool found = false; | ||
81 | AssetStorage foundAsset = null; | ||
82 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); | ||
83 | if (result.Count > 0) | ||
84 | { | ||
85 | foundAsset = (AssetStorage) result.Next(); | ||
86 | found = true; | ||
87 | } | ||
88 | |||
89 | AssetBase asset = new AssetBase(); | ||
90 | if (found) | ||
91 | { | ||
92 | asset.FullID = foundAsset.UUID; | ||
93 | asset.Type = foundAsset.Type; | ||
94 | asset.InvType = foundAsset.Type; | ||
95 | asset.Name = foundAsset.Name; | ||
96 | idata = foundAsset.Data; | ||
97 | asset.Data = idata; | ||
98 | |||
99 | return asset; | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | protected override void StoreAsset(AssetBase asset) | ||
108 | { | ||
109 | AssetStorage store = new AssetStorage(); | ||
110 | store.Data = asset.Data; | ||
111 | store.Name = asset.Name; | ||
112 | store.UUID = asset.FullID; | ||
113 | db.Set(store); | ||
114 | |||
115 | CommitAssets(); | ||
116 | } | ||
117 | |||
118 | protected override void CommitAssets() | ||
119 | { | ||
120 | db.Commit(); | ||
121 | } | ||
122 | |||
123 | protected virtual void SetUpAssetDatabase() | ||
124 | { | ||
125 | m_log.Info("[LOCAL ASSET SERVER]: Setting up asset database"); | ||
126 | |||
127 | base.LoadDefaultAssets(); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | public class AssetUUIDQuery : Predicate | ||
132 | { | ||
133 | private LLUUID _findID; | ||
134 | |||
135 | public AssetUUIDQuery(LLUUID find) | ||
136 | { | ||
137 | _findID = find; | ||
138 | } | ||
139 | |||
140 | public bool Match(AssetStorage asset) | ||
141 | { | ||
142 | return (asset.UUID == _findID); | ||
143 | } | ||
144 | } | ||
145 | } | ||