aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs87
1 files changed, 76 insertions, 11 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index 9cbbf0c..003c6ee 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -31,6 +31,7 @@ using System.IO;
31using System.Threading; 31using System.Threading;
32using System.Xml; 32using System.Xml;
33using System.Drawing; 33using System.Drawing;
34using System.Timers;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
36using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
@@ -61,6 +62,20 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
61 Rest.Log.InfoFormat("{0} Inventory services initializing", MsgId); 62 Rest.Log.InfoFormat("{0} Inventory services initializing", MsgId);
62 Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version); 63 Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version);
63 64
65 // This is better than a null reference.
66
67 if (Rest.InventoryServices == null)
68 throw new Exception(String.Format("{0} OpenSim inventory services are not available",
69 MsgId));
70
71 if (Rest.UserServices == null)
72 throw new Exception(String.Format("{0} OpenSim user services are not available",
73 MsgId));
74
75 if (Rest.AssetServices == null)
76 throw new Exception(String.Format("{0} OpenSim asset services are not available",
77 MsgId));
78
64 // If a relative path was specified for the handler's domain, 79 // If a relative path was specified for the handler's domain,
65 // add the standard prefix to make it absolute, e.g. /admin 80 // add the standard prefix to make it absolute, e.g. /admin
66 81
@@ -167,9 +182,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
167 182
168 try 183 try
169 { 184 {
170 // digest scheme seems borked: disable it for the time
171 // being
172 rdata.scheme = Rest.AS_BASIC;
173 if (!rdata.IsAuthenticated) 185 if (!rdata.IsAuthenticated)
174 { 186 {
175 rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName)); 187 rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
@@ -283,12 +295,22 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
283 Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}", 295 Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}",
284 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 296 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
285 297
286 lock (rdata) 298
299 lock (rdata)
300 {
301 if (!rdata.HaveInventory)
302 {
303 rdata.startWD(1000);
304 rdata.timeout = false;
305 Monitor.Wait(rdata);
306 }
307 }
308
309 if (rdata.timeout)
287 { 310 {
288 if (!rdata.HaveInventory) 311 Rest.Log.WarnFormat("{0} Inventory not available for {1} {2}. No response from service.",
289 { 312 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
290 Monitor.Wait(rdata); 313 rdata.Fail(Rest.HttpStatusCodeServerError, "inventory server not responding");
291 }
292 } 314 }
293 315
294 if (rdata.root == null) 316 if (rdata.root == null)
@@ -2145,12 +2167,50 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
2145 internal ICollection<InventoryItemBase> items = null; 2167 internal ICollection<InventoryItemBase> items = null;
2146 internal UserProfileData userProfile = null; 2168 internal UserProfileData userProfile = null;
2147 internal InventoryFolderBase root = null; 2169 internal InventoryFolderBase root = null;
2170 internal bool timeout = false;
2171 internal System.Timers.Timer watchDog = new System.Timers.Timer();
2148 2172
2149 internal InventoryRequestData(OSHttpRequest request, OSHttpResponse response, string prefix) 2173 internal InventoryRequestData(OSHttpRequest request, OSHttpResponse response, string prefix)
2150 : base(request, response, prefix) 2174 : base(request, response, prefix)
2151 { 2175 {
2152 } 2176 }
2153 2177
2178 internal void startWD(double interval)
2179 {
2180 Rest.Log.DebugFormat("{0} Setting watchdog", MsgId);
2181 watchDog.Elapsed += new ElapsedEventHandler(OnTimeOut);
2182 watchDog.Interval = interval;
2183 watchDog.AutoReset = false;
2184 watchDog.Enabled = true;
2185 watchDog.Start();
2186 }
2187
2188 internal void stopWD()
2189 {
2190 Rest.Log.DebugFormat("{0} Reset watchdog", MsgId);
2191 watchDog.Stop();
2192 }
2193
2194 /// <summary>
2195 /// This is the callback method required by the inventory watchdog. The
2196 /// requestor issues an inventory request and then blocks until the
2197 /// request completes, or this method signals the monitor.
2198 /// </summary>
2199
2200 private void OnTimeOut(object sender, ElapsedEventArgs args)
2201 {
2202 Rest.Log.DebugFormat("{0} Asynchronous inventory update timed-out", MsgId);
2203 // InventoryRequestData rdata = (InventoryRequestData) sender;
2204 lock (this)
2205 {
2206 this.folders = null;
2207 this.items = null;
2208 this.HaveInventory = false;
2209 this.timeout = true;
2210 Monitor.Pulse(this);
2211 }
2212 }
2213
2154 /// <summary> 2214 /// <summary>
2155 /// This is the callback method required by inventory services. The 2215 /// This is the callback method required by inventory services. The
2156 /// requestor issues an inventory request and then blocks until this 2216 /// requestor issues an inventory request and then blocks until this
@@ -2160,11 +2220,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
2160 internal void GetUserInventory(ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items) 2220 internal void GetUserInventory(ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items)
2161 { 2221 {
2162 Rest.Log.DebugFormat("{0} Asynchronously updating inventory data", MsgId); 2222 Rest.Log.DebugFormat("{0} Asynchronously updating inventory data", MsgId);
2163 this.folders = folders;
2164 this.items = items;
2165 this.HaveInventory = true;
2166 lock (this) 2223 lock (this)
2167 { 2224 {
2225 if (watchDog.Enabled)
2226 {
2227 this.stopWD();
2228 }
2229 this.folders = folders;
2230 this.items = items;
2231 this.HaveInventory = true;
2232 this.timeout = false;
2168 Monitor.Pulse(this); 2233 Monitor.Pulse(this);
2169 } 2234 }
2170 } 2235 }