diff options
author | Dr Scofield | 2008-10-20 18:07:06 +0000 |
---|---|---|
committer | Dr Scofield | 2008-10-20 18:07:06 +0000 |
commit | 12042cdc2b53e581ace6a017d9b17bd763a544b2 (patch) | |
tree | 0d99aa0e5dc5349d420c820c2c78c59f3228957f /OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs | |
parent | actually enabling SaveOAR XmlRpc ;-) (diff) | |
download | opensim-SC-12042cdc2b53e581ace6a017d9b17bd763a544b2.zip opensim-SC-12042cdc2b53e581ace6a017d9b17bd763a544b2.tar.gz opensim-SC-12042cdc2b53e581ace6a017d9b17bd763a544b2.tar.bz2 opensim-SC-12042cdc2b53e581ace6a017d9b17bd763a544b2.tar.xz |
From: Alan Webb <alan_webb@us.ibm.com>
cleanups and assorted fixes to REST inventory, asset, and appearance
services.
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs | 87 |
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; | |||
31 | using System.Threading; | 31 | using System.Threading; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | using System.Drawing; | 33 | using System.Drawing; |
34 | using System.Timers; | ||
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Framework.Communications; | 37 | using 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 | } |