diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |
parent | Add a build script. (diff) | |
download | opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 9ad4a7a..953bc2a 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
55 | private static string ZeroID = UUID.Zero.ToString(); | 55 | private static string ZeroID = UUID.Zero.ToString(); |
56 | 56 | ||
57 | private string m_serverUrl = String.Empty; | 57 | private string m_serverUrl = String.Empty; |
58 | private IImprovedAssetCache m_cache; | 58 | private IAssetCache m_cache; |
59 | private bool m_Enabled = false; | 59 | private bool m_Enabled = false; |
60 | 60 | ||
61 | #region ISharedRegionModule | 61 | #region ISharedRegionModule |
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
65 | { | 65 | { |
66 | if (m_cache == null) | 66 | if (m_cache == null) |
67 | { | 67 | { |
68 | IImprovedAssetCache cache = scene.RequestModuleInterface<IImprovedAssetCache>(); | 68 | IAssetCache cache = scene.RequestModuleInterface<IAssetCache>(); |
69 | if (cache is ISharedRegionModule) | 69 | if (cache is ISharedRegionModule) |
70 | m_cache = cache; | 70 | m_cache = cache; |
71 | } | 71 | } |
@@ -77,7 +77,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
77 | public string Name { get { return "SimianAssetServiceConnector"; } } | 77 | public string Name { get { return "SimianAssetServiceConnector"; } } |
78 | public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAssetService>(this); } } | 78 | public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAssetService>(this); } } |
79 | public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAssetService>(this); } } | 79 | public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAssetService>(this); } } |
80 | 80 | ||
81 | #endregion ISharedRegionModule | 81 | #endregion ISharedRegionModule |
82 | 82 | ||
83 | public SimianAssetServiceConnector(IConfigSource source) | 83 | public SimianAssetServiceConnector(IConfigSource source) |
@@ -136,19 +136,22 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
136 | // Cache fetch | 136 | // Cache fetch |
137 | if (m_cache != null) | 137 | if (m_cache != null) |
138 | { | 138 | { |
139 | AssetBase asset = m_cache.Get(id); | 139 | AssetBase asset; |
140 | if (!m_cache.Get(id, out asset)) | ||
141 | return null; | ||
140 | if (asset != null) | 142 | if (asset != null) |
141 | return asset; | 143 | return asset; |
142 | } | 144 | } |
143 | 145 | ||
144 | return SimianGetOperation(id); | 146 | return SimianGetOperation(id); |
145 | } | 147 | } |
146 | 148 | ||
147 | 149 | ||
148 | public AssetBase GetCached(string id) | 150 | public AssetBase GetCached(string id) |
149 | { | 151 | { |
152 | AssetBase asset; | ||
150 | if (m_cache != null) | 153 | if (m_cache != null) |
151 | return m_cache.Get(id); | 154 | m_cache.Get(id, out asset); |
152 | 155 | ||
153 | return null; | 156 | return null; |
154 | } | 157 | } |
@@ -169,7 +172,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
169 | // Cache fetch | 172 | // Cache fetch |
170 | if (m_cache != null) | 173 | if (m_cache != null) |
171 | { | 174 | { |
172 | AssetBase asset = m_cache.Get(id); | 175 | AssetBase asset; |
176 | if (!m_cache.Get(id, out asset)) | ||
177 | return null; | ||
173 | if (asset != null) | 178 | if (asset != null) |
174 | return asset.Metadata; | 179 | return asset.Metadata; |
175 | } | 180 | } |
@@ -177,7 +182,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
177 | // return GetRemoteMetadata(id); | 182 | // return GetRemoteMetadata(id); |
178 | return SimianGetMetadataOperation(id); | 183 | return SimianGetMetadataOperation(id); |
179 | } | 184 | } |
180 | 185 | ||
181 | public byte[] GetData(string id) | 186 | public byte[] GetData(string id) |
182 | { | 187 | { |
183 | if (String.IsNullOrEmpty(m_serverUrl)) | 188 | if (String.IsNullOrEmpty(m_serverUrl)) |
@@ -212,7 +217,10 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
212 | // Cache fetch | 217 | // Cache fetch |
213 | if (m_cache != null) | 218 | if (m_cache != null) |
214 | { | 219 | { |
215 | AssetBase asset = m_cache.Get(id); | 220 | AssetBase asset; |
221 | if (!m_cache.Get(id, out asset)) | ||
222 | return false; | ||
223 | |||
216 | if (asset != null) | 224 | if (asset != null) |
217 | { | 225 | { |
218 | handler(id, sender, asset); | 226 | handler(id, sender, asset); |
@@ -296,7 +304,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
296 | 304 | ||
297 | return SimianStoreOperation(asset); | 305 | return SimianStoreOperation(asset); |
298 | } | 306 | } |
299 | 307 | ||
300 | /// <summary> | 308 | /// <summary> |
301 | /// Update an asset's content | 309 | /// Update an asset's content |
302 | /// </summary> | 310 | /// </summary> |
@@ -344,7 +352,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
344 | 352 | ||
345 | return SimianDeleteOperation(id); | 353 | return SimianDeleteOperation(id); |
346 | } | 354 | } |
347 | 355 | ||
348 | #endregion IAssetService | 356 | #endregion IAssetService |
349 | 357 | ||
350 | #region SimianOperations | 358 | #region SimianOperations |
@@ -369,9 +377,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
369 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString()); | 377 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString()); |
370 | return false; | 378 | return false; |
371 | } | 379 | } |
372 | 380 | ||
373 | return true; | 381 | return true; |
374 | 382 | ||
375 | } | 383 | } |
376 | catch (Exception ex) | 384 | catch (Exception ex) |
377 | { | 385 | { |
@@ -400,7 +408,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
400 | { "Temporary", asset.Temporary ? "1" : "0" }, | 408 | { "Temporary", asset.Temporary ? "1" : "0" }, |
401 | { "Name", asset.Name } | 409 | { "Name", asset.Name } |
402 | }; | 410 | }; |
403 | 411 | ||
404 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | 412 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
405 | if (! response["Success"].AsBoolean()) | 413 | if (! response["Success"].AsBoolean()) |
406 | { | 414 | { |
@@ -410,13 +418,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
410 | 418 | ||
411 | // asset.ID is always set before calling this function | 419 | // asset.ID is always set before calling this function |
412 | return asset.ID; | 420 | return asset.ID; |
413 | 421 | ||
414 | } | 422 | } |
415 | catch (Exception ex) | 423 | catch (Exception ex) |
416 | { | 424 | { |
417 | m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message); | 425 | m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message); |
418 | } | 426 | } |
419 | 427 | ||
420 | return null; | 428 | return null; |
421 | } | 429 | } |
422 | 430 | ||
@@ -427,12 +435,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
427 | /// <returns></returns> | 435 | /// <returns></returns> |
428 | private AssetBase SimianGetOperation(string id) | 436 | private AssetBase SimianGetOperation(string id) |
429 | { | 437 | { |
430 | try | 438 | try |
431 | { | 439 | { |
432 | NameValueCollection requestArgs = new NameValueCollection | 440 | NameValueCollection requestArgs = new NameValueCollection |
433 | { | 441 | { |
434 | { "RequestMethod", "xGetAsset" }, | 442 | { "RequestMethod", "xGetAsset" }, |
435 | { "ID", id } | 443 | { "ID", id } |
436 | }; | 444 | }; |
437 | 445 | ||
438 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | 446 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
@@ -441,7 +449,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
441 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString()); | 449 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString()); |
442 | return null; | 450 | return null; |
443 | } | 451 | } |
444 | 452 | ||
445 | AssetBase asset = new AssetBase(); | 453 | AssetBase asset = new AssetBase(); |
446 | 454 | ||
447 | asset.ID = id; | 455 | asset.ID = id; |
@@ -475,7 +483,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
475 | NameValueCollection requestArgs = new NameValueCollection | 483 | NameValueCollection requestArgs = new NameValueCollection |
476 | { | 484 | { |
477 | { "RequestMethod", "xGetAssetMetadata" }, | 485 | { "RequestMethod", "xGetAssetMetadata" }, |
478 | { "ID", id } | 486 | { "ID", id } |
479 | }; | 487 | }; |
480 | 488 | ||
481 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | 489 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
@@ -485,7 +493,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
485 | // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); | 493 | // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); |
486 | return null; | 494 | return null; |
487 | } | 495 | } |
488 | 496 | ||
489 | AssetMetadata metadata = new AssetMetadata(); | 497 | AssetMetadata metadata = new AssetMetadata(); |
490 | metadata.ID = id; | 498 | metadata.ID = id; |
491 | metadata.ContentType = response["ContentType"].AsString(); | 499 | metadata.ContentType = response["ContentType"].AsString(); |
@@ -620,7 +628,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
620 | // } | 628 | // } |
621 | 629 | ||
622 | // string errorMessage = null; | 630 | // string errorMessage = null; |
623 | 631 | ||
624 | // // Build the remote storage request | 632 | // // Build the remote storage request |
625 | // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | 633 | // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() |
626 | // { | 634 | // { |