aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
diff options
context:
space:
mode:
authorDiva Canto2009-08-10 10:58:43 -0700
committerDiva Canto2009-08-10 10:58:43 -0700
commit43b7e6728898a060faa2bc6dd053dadeb63c6e7f (patch)
treecd3474bab20e8f84f1f3a19e8274f4fbb04d2811 /OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
parentFirst pass at cleaning up old OGS1 and Local Inventory: removed everything-in... (diff)
downloadopensim-SC_OLD-43b7e6728898a060faa2bc6dd053dadeb63c6e7f.zip
opensim-SC_OLD-43b7e6728898a060faa2bc6dd053dadeb63c6e7f.tar.gz
opensim-SC_OLD-43b7e6728898a060faa2bc6dd053dadeb63c6e7f.tar.bz2
opensim-SC_OLD-43b7e6728898a060faa2bc6dd053dadeb63c6e7f.tar.xz
Et voila! - Old inventory code removed.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs343
1 files changed, 0 insertions, 343 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
deleted file mode 100644
index 364799a..0000000
--- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
+++ /dev/null
@@ -1,343 +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 OGS1InventoryService : IInventoryServices
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 OGS1InventoryService(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, InventoryReceiptCallback callback)
71 {
72 if (!m_RequestingInventory.ContainsKey(userID))
73 {
74 m_RequestingInventory.Add(userID, callback);
75
76 try
77 {
78 m_log.InfoFormat(
79 "[OGS1 INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1}",
80 _inventoryServerUrl, userID);
81
82 RestObjectPosterResponse<InventoryCollection> requester
83 = new RestObjectPosterResponse<InventoryCollection>();
84 requester.ResponseCallback = InventoryResponse;
85
86 requester.BeginPostObject<Guid>(_inventoryServerUrl + "/GetInventory/", userID.Guid);
87 }
88 catch (WebException e)
89 {
90 if (StatsManager.SimExtraStats != null)
91 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
92
93 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Request inventory operation failed, {0} {1}",
94 e.Source, e.Message);
95 }
96 }
97 else
98 {
99 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: RequestInventoryForUser() - could you not find user profile for {0}", userID);
100 }
101 }
102
103 /// <summary>
104 /// Callback used by the inventory server GetInventory request
105 /// </summary>
106 /// <param name="userID"></param>
107 private void InventoryResponse(InventoryCollection response)
108 {
109 UUID userID = response.UserID;
110 if (m_RequestingInventory.ContainsKey(userID))
111 {
112 m_log.InfoFormat("[OGS1 INVENTORY SERVICE]: " +
113 "Received inventory response for user {0} containing {1} folders and {2} items",
114 userID, response.Folders.Count, response.Items.Count);
115
116 InventoryFolderImpl rootFolder = null;
117 InventoryReceiptCallback callback = m_RequestingInventory[userID];
118
119 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
120 ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
121
122 foreach (InventoryFolderBase folder in response.Folders)
123 {
124 if (folder.ParentID == UUID.Zero)
125 {
126 rootFolder = new InventoryFolderImpl(folder);
127 folders.Add(rootFolder);
128
129 break;
130 }
131 }
132
133 if (rootFolder != null)
134 {
135 foreach (InventoryFolderBase folder in response.Folders)
136 {
137 if (folder.ID != rootFolder.ID)
138 {
139 folders.Add(new InventoryFolderImpl(folder));
140 }
141 }
142
143 foreach (InventoryItemBase item in response.Items)
144 {
145 items.Add(item);
146 }
147 }
148 else
149 {
150 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID);
151 }
152
153 callback(folders, items);
154
155 m_RequestingInventory.Remove(userID);
156 }
157 else
158 {
159 m_log.WarnFormat(
160 "[OGS1 INVENTORY SERVICE]: " +
161 "Received inventory response for {0} for which we do not have a record of requesting!",
162 userID);
163 }
164 }
165
166 /// <summary>
167 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
168 /// </summary>
169 public bool AddFolder(InventoryFolderBase folder)
170 {
171 try
172 {
173 return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
174 "POST", _inventoryServerUrl + "/NewFolder/", folder);
175 }
176 catch (WebException e)
177 {
178 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory folder operation failed, {0} {1}",
179 e.Source, e.Message);
180 }
181
182 return false;
183 }
184
185 /// <summary>
186 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
187 /// </summary>
188 /// <param name="folder"></param>
189 public bool UpdateFolder(InventoryFolderBase folder)
190 {
191 try
192 {
193 return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
194 "POST", _inventoryServerUrl + "/UpdateFolder/", folder);
195 }
196 catch (WebException e)
197 {
198 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Update inventory folder operation failed, {0} {1}",
199 e.Source, e.Message);
200 }
201
202 return false;
203 }
204
205 /// <summary>
206 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
207 /// </summary>
208 /// <param name="folder"></param>
209 public bool MoveFolder(InventoryFolderBase folder)
210 {
211 try
212 {
213 return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
214 "POST", _inventoryServerUrl + "/MoveFolder/", folder);
215 }
216 catch (WebException e)
217 {
218 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
219 e.Source, e.Message);
220 }
221
222 return false;
223 }
224
225 /// <summary>
226 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
227 /// </summary>
228 public bool PurgeFolder(InventoryFolderBase folder)
229 {
230 try
231 {
232 return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
233 "POST", _inventoryServerUrl + "/PurgeFolder/", folder);
234 }
235 catch (WebException e)
236 {
237 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
238 e.Source, e.Message);
239 }
240
241 return false;
242 }
243
244 /// <summary>
245 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
246 /// </summary>
247 public bool AddItem(InventoryItemBase item)
248 {
249 try
250 {
251 return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
252 "POST", _inventoryServerUrl + "/NewItem/", item);
253 }
254 catch (WebException e)
255 {
256 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory item operation failed, {0} {1}",
257 e.Source, e.Message);
258 }
259
260 return false;
261 }
262
263 // TODO: this is a temporary workaround, the UpdateInventoryItem method need to be implemented
264 public bool UpdateItem(InventoryItemBase item)
265 {
266 try
267 {
268 return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
269 "POST", _inventoryServerUrl + "/NewItem/", item);
270 }
271 catch (WebException e)
272 {
273 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Update new inventory item operation failed, {0} {1}",
274 e.Source, e.Message);
275 }
276
277 return false;
278 }
279
280 /// <summary>
281 /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
282 /// </summary>
283 public bool DeleteItem(InventoryItemBase item)
284 {
285 try
286 {
287 return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
288 "POST", _inventoryServerUrl + "/DeleteItem/", item);
289 }
290 catch (WebException e)
291 {
292 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Delete inventory item operation failed, {0} {1}",
293 e.Source, e.Message);
294 }
295
296 return false;
297 }
298
299 public InventoryItemBase QueryItem(InventoryItemBase item)
300 {
301 try
302 {
303 return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, InventoryItemBase>(
304 "POST", _inventoryServerUrl + "/QueryItem/", item);
305 }
306 catch (WebException e)
307 {
308 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
309 e.Source, e.Message);
310 }
311
312 return null;
313 }
314
315 public InventoryFolderBase QueryFolder(InventoryFolderBase item)
316 {
317 try
318 {
319 return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, InventoryFolderBase>(
320 "POST", _inventoryServerUrl + "/QueryFolder/", item);
321 }
322 catch (WebException e)
323 {
324 m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
325 e.Source, e.Message);
326 }
327
328 return null;
329 }
330
331 public bool HasInventoryForUser(UUID userID)
332 {
333 return false;
334 }
335
336 public InventoryFolderBase RequestRootFolder(UUID userID)
337 {
338 return null;
339 }
340
341 #endregion
342 }
343}