diff options
Merge branch 'master' of /home/opensim/src/OpenSim/Core
Diffstat (limited to 'OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs | 335 |
1 files changed, 0 insertions, 335 deletions
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs deleted file mode 100644 index 9878855..0000000 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ /dev/null | |||
@@ -1,335 +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 OpenMetaverse; | ||
36 | |||
37 | namespace OpenSim.Services.Connectors.Inventory | ||
38 | { | ||
39 | public class HGInventoryServiceConnector : ISessionAuthInventoryService | ||
40 | { | ||
41 | private static readonly ILog m_log = | ||
42 | LogManager.GetLogger( | ||
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | private Dictionary<string, InventoryServicesConnector> m_connectors = new Dictionary<string, InventoryServicesConnector>(); | ||
46 | |||
47 | public HGInventoryServiceConnector(IConfigSource source) | ||
48 | { | ||
49 | IConfig moduleConfig = source.Configs["Modules"]; | ||
50 | if (moduleConfig != null) | ||
51 | { | ||
52 | |||
53 | IConfig inventoryConfig = source.Configs["InventoryService"]; | ||
54 | if (inventoryConfig == null) | ||
55 | { | ||
56 | m_log.Error("[HG INVENTORY SERVICE]: InventoryService missing from OpenSim.ini"); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | m_log.Info("[HG INVENTORY SERVICE]: HG inventory service enabled"); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | private bool StringToUrlAndUserID(string id, out string url, out string userID) | ||
65 | { | ||
66 | url = String.Empty; | ||
67 | userID = String.Empty; | ||
68 | |||
69 | Uri assetUri; | ||
70 | |||
71 | if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) && | ||
72 | assetUri.Scheme == Uri.UriSchemeHttp) | ||
73 | { | ||
74 | url = "http://" + assetUri.Authority; | ||
75 | userID = assetUri.LocalPath.Trim(new char[] { '/' }); | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | return false; | ||
80 | } | ||
81 | private ISessionAuthInventoryService GetConnector(string url) | ||
82 | { | ||
83 | InventoryServicesConnector connector = null; | ||
84 | lock (m_connectors) | ||
85 | { | ||
86 | if (m_connectors.ContainsKey(url)) | ||
87 | { | ||
88 | connector = m_connectors[url]; | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | // We're instantiating this class explicitly, but this won't | ||
93 | // work in general, because the remote grid may be running | ||
94 | // an inventory server that has a different protocol. | ||
95 | // Eventually we will want a piece of protocol asking | ||
96 | // the remote server about its kind. Definitely cool thing to do! | ||
97 | connector = new InventoryServicesConnector(url); | ||
98 | m_connectors.Add(url, connector); | ||
99 | } | ||
100 | } | ||
101 | return connector; | ||
102 | } | ||
103 | |||
104 | public string Host | ||
105 | { | ||
106 | get { return string.Empty; } | ||
107 | } | ||
108 | |||
109 | public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback) | ||
110 | { | ||
111 | m_log.Debug("[HGInventory]: GetUserInventory " + id); | ||
112 | string url = string.Empty; | ||
113 | string userID = string.Empty; | ||
114 | |||
115 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
116 | { | ||
117 | ISessionAuthInventoryService connector = GetConnector(url); | ||
118 | connector.GetUserInventory(userID, sessionID, callback); | ||
119 | } | ||
120 | |||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// Gets the user folder for the given folder-type | ||
125 | /// </summary> | ||
126 | /// <param name="userID"></param> | ||
127 | /// <param name="type"></param> | ||
128 | /// <returns></returns> | ||
129 | public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string id, UUID sessionID) | ||
130 | { | ||
131 | m_log.Debug("[HGInventory]: GetSystemFolders " + id); | ||
132 | string url = string.Empty; | ||
133 | string userID = string.Empty; | ||
134 | |||
135 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
136 | { | ||
137 | ISessionAuthInventoryService connector = GetConnector(url); | ||
138 | return connector.GetSystemFolders(userID, sessionID); | ||
139 | } | ||
140 | |||
141 | return new Dictionary<AssetType, InventoryFolderBase>(); | ||
142 | } | ||
143 | |||
144 | /// <summary> | ||
145 | /// Gets everything (folders and items) inside a folder | ||
146 | /// </summary> | ||
147 | /// <param name="userId"></param> | ||
148 | /// <param name="folderID"></param> | ||
149 | /// <returns></returns> | ||
150 | public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID) | ||
151 | { | ||
152 | m_log.Debug("[HGInventory]: GetFolderContent " + id); | ||
153 | string url = string.Empty; | ||
154 | string userID = string.Empty; | ||
155 | |||
156 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
157 | { | ||
158 | ISessionAuthInventoryService connector = GetConnector(url); | ||
159 | return connector.GetFolderContent(userID, folderID, sessionID); | ||
160 | } | ||
161 | |||
162 | return null; | ||
163 | } | ||
164 | |||
165 | public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
166 | { | ||
167 | string url = string.Empty; | ||
168 | string userID = string.Empty; | ||
169 | |||
170 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
171 | { | ||
172 | ISessionAuthInventoryService connector = GetConnector(url); | ||
173 | return connector.AddFolder(userID, folder, sessionID); | ||
174 | } | ||
175 | return false; | ||
176 | } | ||
177 | |||
178 | public bool UpdateFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
179 | { | ||
180 | string url = string.Empty; | ||
181 | string userID = string.Empty; | ||
182 | |||
183 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
184 | { | ||
185 | ISessionAuthInventoryService connector = GetConnector(url); | ||
186 | return connector.UpdateFolder(userID, folder, sessionID); | ||
187 | } | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | public bool MoveFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
192 | { | ||
193 | string url = string.Empty; | ||
194 | string userID = string.Empty; | ||
195 | |||
196 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
197 | { | ||
198 | ISessionAuthInventoryService connector = GetConnector(url); | ||
199 | return connector.MoveFolder(userID, folder, sessionID); | ||
200 | } | ||
201 | return false; | ||
202 | } | ||
203 | |||
204 | public bool DeleteFolders(string id, List<UUID> folders, UUID sessionID) | ||
205 | { | ||
206 | string url = string.Empty; | ||
207 | string userID = string.Empty; | ||
208 | |||
209 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
210 | { | ||
211 | ISessionAuthInventoryService connector = GetConnector(url); | ||
212 | return connector.DeleteFolders(userID, folders, sessionID); | ||
213 | } | ||
214 | return false; | ||
215 | } | ||
216 | |||
217 | public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
218 | { | ||
219 | string url = string.Empty; | ||
220 | string userID = string.Empty; | ||
221 | |||
222 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
223 | { | ||
224 | ISessionAuthInventoryService connector = GetConnector(url); | ||
225 | return connector.PurgeFolder(userID, folder, sessionID); | ||
226 | } | ||
227 | return false; | ||
228 | } | ||
229 | |||
230 | public List<InventoryItemBase> GetFolderItems(string id, UUID folderID, UUID sessionID) | ||
231 | { | ||
232 | string url = string.Empty; | ||
233 | string userID = string.Empty; | ||
234 | |||
235 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
236 | { | ||
237 | ISessionAuthInventoryService connector = GetConnector(url); | ||
238 | return connector.GetFolderItems(userID, folderID, sessionID); | ||
239 | } | ||
240 | return new List<InventoryItemBase>(); | ||
241 | } | ||
242 | |||
243 | public bool AddItem(string id, InventoryItemBase item, UUID sessionID) | ||
244 | { | ||
245 | string url = string.Empty; | ||
246 | string userID = string.Empty; | ||
247 | |||
248 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
249 | { | ||
250 | ISessionAuthInventoryService connector = GetConnector(url); | ||
251 | return connector.AddItem(userID, item, sessionID); | ||
252 | } | ||
253 | return false; | ||
254 | } | ||
255 | |||
256 | public bool UpdateItem(string id, InventoryItemBase item, UUID sessionID) | ||
257 | { | ||
258 | string url = string.Empty; | ||
259 | string userID = string.Empty; | ||
260 | |||
261 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
262 | { | ||
263 | ISessionAuthInventoryService connector = GetConnector(url); | ||
264 | return connector.UpdateItem(userID, item, sessionID); | ||
265 | } | ||
266 | return false; | ||
267 | } | ||
268 | |||
269 | public bool MoveItems(string id, List<InventoryItemBase> items, UUID sessionID) | ||
270 | { | ||
271 | string url = string.Empty; | ||
272 | string userID = string.Empty; | ||
273 | |||
274 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
275 | { | ||
276 | ISessionAuthInventoryService connector = GetConnector(url); | ||
277 | return connector.MoveItems(userID, items, sessionID); | ||
278 | } | ||
279 | return false; | ||
280 | } | ||
281 | |||
282 | public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID) | ||
283 | { | ||
284 | string url = string.Empty; | ||
285 | string userID = string.Empty; | ||
286 | |||
287 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
288 | { | ||
289 | ISessionAuthInventoryService connector = GetConnector(url); | ||
290 | return connector.DeleteItems(userID, itemIDs, sessionID); | ||
291 | } | ||
292 | return false; | ||
293 | } | ||
294 | |||
295 | public InventoryItemBase QueryItem(string id, InventoryItemBase item, UUID sessionID) | ||
296 | { | ||
297 | string url = string.Empty; | ||
298 | string userID = string.Empty; | ||
299 | |||
300 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
301 | { | ||
302 | //m_log.DebugFormat("[HGInventory CONNECTOR]: calling {0}", url); | ||
303 | ISessionAuthInventoryService connector = GetConnector(url); | ||
304 | return connector.QueryItem(userID, item, sessionID); | ||
305 | } | ||
306 | return null; | ||
307 | } | ||
308 | |||
309 | public InventoryFolderBase QueryFolder(string id, InventoryFolderBase folder, UUID sessionID) | ||
310 | { | ||
311 | string url = string.Empty; | ||
312 | string userID = string.Empty; | ||
313 | |||
314 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
315 | { | ||
316 | ISessionAuthInventoryService connector = GetConnector(url); | ||
317 | return connector.QueryFolder(userID, folder, sessionID); | ||
318 | } | ||
319 | return null; | ||
320 | } | ||
321 | |||
322 | public int GetAssetPermissions(string id, UUID assetID, UUID sessionID) | ||
323 | { | ||
324 | string url = string.Empty; | ||
325 | string userID = string.Empty; | ||
326 | |||
327 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
328 | { | ||
329 | ISessionAuthInventoryService connector = GetConnector(url); | ||
330 | return connector.GetAssetPermissions(userID, assetID, sessionID); | ||
331 | } | ||
332 | return 0; | ||
333 | } | ||
334 | } | ||
335 | } | ||