diff options
Diffstat (limited to 'OpenSim/Services/InventoryService')
-rw-r--r-- | OpenSim/Services/InventoryService/HGInventoryService.cs | 242 |
1 files changed, 0 insertions, 242 deletions
diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/InventoryService/HGInventoryService.cs deleted file mode 100644 index 0db80d0..0000000 --- a/OpenSim/Services/InventoryService/HGInventoryService.cs +++ /dev/null | |||
@@ -1,242 +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 log4net; | ||
29 | using Nini.Config; | ||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace OpenSim.Services.InventoryService | ||
39 | { | ||
40 | public class HGInventoryService : ISessionAuthInventoryService | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private Dictionary<string, InventoryServicesConnector> m_connectors = new Dictionary<string, InventoryServicesConnector>(); | ||
47 | |||
48 | public HGInventoryService(IConfigSource source) | ||
49 | { | ||
50 | IConfig moduleConfig = source.Configs["Modules"]; | ||
51 | if (moduleConfig != null) | ||
52 | { | ||
53 | |||
54 | IConfig assetConfig = source.Configs["InventoryService"]; | ||
55 | if (assetConfig == null) | ||
56 | { | ||
57 | m_log.Error("[HG INVENTORY SERVICE]: InventoryService missing from OpenSim.ini"); | ||
58 | return; | ||
59 | } | ||
60 | |||
61 | m_log.Info("[HG INVENTORY SERVICE]: HG inventory service enabled"); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | private bool StringToUrlAndUserID(string id, out string url, out string userID) | ||
66 | { | ||
67 | url = String.Empty; | ||
68 | userID = String.Empty; | ||
69 | |||
70 | Uri assetUri; | ||
71 | |||
72 | if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) && | ||
73 | assetUri.Scheme == Uri.UriSchemeHttp) | ||
74 | { | ||
75 | url = "http://" + assetUri.Authority; | ||
76 | userID = assetUri.LocalPath.Trim(new char[] { '/' }); | ||
77 | return true; | ||
78 | } | ||
79 | |||
80 | return false; | ||
81 | } | ||
82 | private ISessionAuthInventoryService GetConnector(string url) | ||
83 | { | ||
84 | InventoryServicesConnector connector = null; | ||
85 | lock (m_connectors) | ||
86 | { | ||
87 | if (m_connectors.ContainsKey(url)) | ||
88 | { | ||
89 | connector = m_connectors[url]; | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | // We're instantiating this class explicitly, but this won't | ||
94 | // work in general, because the remote grid may be running | ||
95 | // an inventory server that has a different protocol. | ||
96 | // Eventually we will want a piece of protocol asking | ||
97 | // the remote server about its kind. Definitely cool thing to do! | ||
98 | connector = new InventoryServicesConnector(url); | ||
99 | m_connectors.Add(url, connector); | ||
100 | } | ||
101 | } | ||
102 | return connector; | ||
103 | } | ||
104 | |||
105 | public string Host | ||
106 | { | ||
107 | get { return string.Empty; } | ||
108 | } | ||
109 | |||
110 | public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback) | ||
111 | { | ||
112 | m_log.Debug("[HGInventory]: GetUserInventory " + id); | ||
113 | string url = string.Empty; | ||
114 | string userID = string.Empty; | ||
115 | |||
116 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
117 | { | ||
118 | ISessionAuthInventoryService connector = GetConnector(url); | ||
119 | connector.GetUserInventory(userID, sessionID, callback); | ||
120 | } | ||
121 | |||
122 | } | ||
123 | |||
124 | public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
125 | { | ||
126 | string url = string.Empty; | ||
127 | string userID = string.Empty; | ||
128 | |||
129 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
130 | { | ||
131 | ISessionAuthInventoryService connector = GetConnector(url); | ||
132 | return connector.AddFolder(userID, folder, sessionID); | ||
133 | } | ||
134 | return false; | ||
135 | } | ||
136 | |||
137 | public bool UpdateFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
138 | { | ||
139 | string url = string.Empty; | ||
140 | string userID = string.Empty; | ||
141 | |||
142 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
143 | { | ||
144 | ISessionAuthInventoryService connector = GetConnector(url); | ||
145 | return connector.UpdateFolder(userID, folder, sessionID); | ||
146 | } | ||
147 | return false; | ||
148 | } | ||
149 | |||
150 | public bool MoveFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
151 | { | ||
152 | string url = string.Empty; | ||
153 | string userID = string.Empty; | ||
154 | |||
155 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
156 | { | ||
157 | ISessionAuthInventoryService connector = GetConnector(url); | ||
158 | return connector.MoveFolder(userID, folder, sessionID); | ||
159 | } | ||
160 | return false; | ||
161 | } | ||
162 | |||
163 | public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
164 | { | ||
165 | string url = string.Empty; | ||
166 | string userID = string.Empty; | ||
167 | |||
168 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
169 | { | ||
170 | ISessionAuthInventoryService connector = GetConnector(url); | ||
171 | return connector.PurgeFolder(userID, folder, sessionID); | ||
172 | } | ||
173 | return false; | ||
174 | } | ||
175 | |||
176 | public bool AddItem(string id, InventoryItemBase item, UUID sessionID) | ||
177 | { | ||
178 | string url = string.Empty; | ||
179 | string userID = string.Empty; | ||
180 | |||
181 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
182 | { | ||
183 | ISessionAuthInventoryService connector = GetConnector(url); | ||
184 | return connector.AddItem(userID, item, sessionID); | ||
185 | } | ||
186 | return false; | ||
187 | } | ||
188 | |||
189 | public bool UpdateItem(string id, InventoryItemBase item, UUID sessionID) | ||
190 | { | ||
191 | string url = string.Empty; | ||
192 | string userID = string.Empty; | ||
193 | |||
194 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
195 | { | ||
196 | ISessionAuthInventoryService connector = GetConnector(url); | ||
197 | return connector.UpdateItem(userID, item, sessionID); | ||
198 | } | ||
199 | return false; | ||
200 | } | ||
201 | |||
202 | public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) | ||
203 | { | ||
204 | string url = string.Empty; | ||
205 | string userID = string.Empty; | ||
206 | |||
207 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
208 | { | ||
209 | ISessionAuthInventoryService connector = GetConnector(url); | ||
210 | return connector.UpdateItem(userID, item, sessionID); | ||
211 | } | ||
212 | return false; | ||
213 | } | ||
214 | |||
215 | public InventoryItemBase QueryItem(string id, InventoryItemBase item, UUID sessionID) | ||
216 | { | ||
217 | string url = string.Empty; | ||
218 | string userID = string.Empty; | ||
219 | |||
220 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
221 | { | ||
222 | ISessionAuthInventoryService connector = GetConnector(url); | ||
223 | return connector.QueryItem(userID, item, sessionID); | ||
224 | } | ||
225 | return null; | ||
226 | } | ||
227 | |||
228 | public InventoryFolderBase QueryFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
229 | { | ||
230 | string url = string.Empty; | ||
231 | string userID = string.Empty; | ||
232 | |||
233 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
234 | { | ||
235 | ISessionAuthInventoryService connector = GetConnector(url); | ||
236 | return connector.QueryFolder(userID, folder, sessionID); | ||
237 | } | ||
238 | return null; | ||
239 | } | ||
240 | |||
241 | } | ||
242 | } | ||