aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/OGS1/OGS1SecureInventoryService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1SecureInventoryService.cs')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1SecureInventoryService.cs351
1 files changed, 0 insertions, 351 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1SecureInventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1SecureInventoryService.cs
deleted file mode 100644
index 1290a01..0000000
--- a/OpenSim/Region/Communications/OGS1/OGS1SecureInventoryService.cs
+++ /dev/null
@@ -1,351 +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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Framework.Statistics;
39
40namespace OpenSim.Region.Communications.OGS1
41{
42 public class OGS1SecureInventoryService : ISecureInventoryService
43 {
44 private static readonly ILog m_log
45 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 private string _inventoryServerUrl;
48 private Uri m_Uri;
49 private Dictionary<UUID, InventoryReceiptCallback> m_RequestingInventory
50 = new Dictionary<UUID, InventoryReceiptCallback>();
51
52 public OGS1SecureInventoryService(string inventoryServerUrl)
53 {
54 _inventoryServerUrl = inventoryServerUrl;
55 m_Uri = new Uri(_inventoryServerUrl);
56 }
57
58 #region IInventoryServices Members
59
60 public string Host
61 {
62 get { return m_Uri.Host; }
63 }
64
65 /// <summary>
66 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
67 /// </summary>
68 /// <param name="userID"></param>
69 /// <param name="callback"></param>
70 public void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback)
71 {
72 lock (m_RequestingInventory)
73 {
74 if (!m_RequestingInventory.ContainsKey(userID))
75 m_RequestingInventory.Add(userID, callback);
76 else
77 {
78 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: RequestInventoryForUser() - could you not find user profile for {0}", userID);
79 return;
80 }
81 }
82
83 try
84 {
85 m_log.InfoFormat(
86 "[OGS1 INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1}",
87 _inventoryServerUrl, userID);
88
89 RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
90 = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
91 requester.ResponseCallback = InventoryResponse;
92
93 requester.BeginPostObject(_inventoryServerUrl + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString());
94 }
95 catch (WebException e)
96 {
97 if (StatsManager.SimExtraStats != null)
98 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
99
100 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Request inventory operation failed, {0} {1}",
101 e.Source, e.Message);
102 }
103 }
104
105 /// <summary>
106 /// Callback used by the inventory server GetInventory request
107 /// </summary>
108 /// <param name="userID"></param>
109 private void InventoryResponse(InventoryCollection response)
110 {
111 UUID userID = response.UserID;
112 InventoryReceiptCallback callback = null;
113 lock (m_RequestingInventory)
114 {
115 if (m_RequestingInventory.ContainsKey(userID))
116 {
117 callback = m_RequestingInventory[userID];
118 m_RequestingInventory.Remove(userID);
119 }
120 else
121 {
122 m_log.WarnFormat(
123 "[OGS1 INVENTORY SERVICE]: " +
124 "Received inventory response for {0} for which we do not have a record of requesting!",
125 userID);
126 return;
127 }
128 }
129
130 m_log.InfoFormat("[OGS1 INVENTORY SERVICE]: " +
131 "Received inventory response for user {0} containing {1} folders and {2} items",
132 userID, response.Folders.Count, response.Items.Count);
133
134 InventoryFolderImpl rootFolder = null;
135
136 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
137 ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
138
139 foreach (InventoryFolderBase folder in response.Folders)
140 {
141 if (folder.ParentID == UUID.Zero)
142 {
143 rootFolder = new InventoryFolderImpl(folder);
144 folders.Add(rootFolder);
145
146 break;
147 }
148 }
149
150 if (rootFolder != null)
151 {
152 foreach (InventoryFolderBase folder in response.Folders)
153 {
154 if (folder.ID != rootFolder.ID)
155 {
156 folders.Add(new InventoryFolderImpl(folder));
157 }
158 }
159
160 foreach (InventoryItemBase item in response.Items)
161 {
162 items.Add(item);
163 }
164 }
165 else
166 {
167 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID);
168 }
169
170 callback(folders, items);
171
172 }
173
174 /// <summary>
175 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
176 /// </summary>
177 public bool AddFolder(InventoryFolderBase folder, UUID session_id)
178 {
179 try
180 {
181 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
182 "POST", _inventoryServerUrl + "/NewFolder/", folder, session_id.ToString(), folder.Owner.ToString());
183 }
184 catch (WebException e)
185 {
186 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory folder operation failed, {0} {1}",
187 e.Source, e.Message);
188 }
189
190 return false;
191 }
192
193 /// <summary>
194 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
195 /// </summary>
196 /// <param name="folder"></param>
197 public bool UpdateFolder(InventoryFolderBase folder, UUID session_id)
198 {
199 try
200 {
201 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
202 "POST", _inventoryServerUrl + "/UpdateFolder/", folder, session_id.ToString(), folder.Owner.ToString());
203 }
204 catch (WebException e)
205 {
206 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Update inventory folder operation failed, {0} {1}",
207 e.Source, e.Message);
208 }
209
210 return false;
211 }
212
213 /// <summary>
214 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
215 /// </summary>
216 /// <param name="folder"></param>
217 public bool MoveFolder(InventoryFolderBase folder, UUID session_id)
218 {
219 try
220 {
221 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
222 "POST", _inventoryServerUrl + "/MoveFolder/", folder, session_id.ToString(), folder.Owner.ToString());
223 }
224 catch (WebException e)
225 {
226 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
227 e.Source, e.Message);
228 }
229
230 return false;
231 }
232
233 /// <summary>
234 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
235 /// </summary>
236 public bool PurgeFolder(InventoryFolderBase folder, UUID session_id)
237 {
238 try
239 {
240 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
241 "POST", _inventoryServerUrl + "/PurgeFolder/", folder, session_id.ToString(), folder.Owner.ToString());
242 }
243 catch (WebException e)
244 {
245 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
246 e.Source, e.Message);
247 }
248
249 return false;
250 }
251
252 /// <summary>
253 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
254 /// </summary>
255 public bool AddItem(InventoryItemBase item, UUID session_id)
256 {
257 try
258 {
259 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
260 "POST", _inventoryServerUrl + "/NewItem/", item, session_id.ToString(), item.Owner.ToString());
261 }
262 catch (WebException e)
263 {
264 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory item operation failed, {0} {1}",
265 e.Source, e.Message);
266 }
267
268 return false;
269 }
270
271 // TODO: this is a temporary workaround, the UpdateInventoryItem method need to be implemented
272 public bool UpdateItem(InventoryItemBase item, UUID session_id)
273 {
274 try
275 {
276 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
277 "POST", _inventoryServerUrl + "/NewItem/", item, session_id.ToString(), item.Owner.ToString());
278 }
279 catch (WebException e)
280 {
281 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Update new inventory item operation failed, {0} {1}",
282 e.Source, e.Message);
283 }
284
285 return false;
286 }
287
288 /// <summary>
289 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
290 /// </summary>
291 public bool DeleteItem(InventoryItemBase item, UUID session_id)
292 {
293 try
294 {
295 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
296 "POST", _inventoryServerUrl + "/DeleteItem/", item, session_id.ToString(), item.Owner.ToString());
297 }
298 catch (WebException e)
299 {
300 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Delete inventory item operation failed, {0} {1}",
301 e.Source, e.Message);
302 }
303
304 return false;
305 }
306
307 public InventoryItemBase QueryItem(InventoryItemBase item, UUID session_id)
308 {
309 try
310 {
311 return SynchronousRestSessionObjectPoster<InventoryItemBase, InventoryItemBase>.BeginPostObject(
312 "POST", _inventoryServerUrl + "/QueryItem/", item, session_id.ToString(), item.Owner.ToString());
313 }
314 catch (WebException e)
315 {
316 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
317 e.Source, e.Message);
318 }
319
320 return null;
321 }
322
323 public InventoryFolderBase QueryFolder(InventoryFolderBase item, UUID session_id)
324 {
325 try
326 {
327 return SynchronousRestSessionObjectPoster<InventoryFolderBase, InventoryFolderBase>.BeginPostObject(
328 "POST", _inventoryServerUrl + "/QueryFolder/", item, session_id.ToString(), item.Owner.ToString());
329 }
330 catch (WebException e)
331 {
332 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
333 e.Source, e.Message);
334 }
335
336 return null;
337 }
338
339 public bool HasInventoryForUser(UUID userID)
340 {
341 return false;
342 }
343
344 public InventoryFolderBase RequestRootFolder(UUID userID)
345 {
346 return null;
347 }
348
349 #endregion
350 }
351}