diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 448962ae13..de52623459 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -457,8 +457,6 @@ namespace OpenSim.Data.MySQL if (prim.ParentUUID == UUID.Zero) { objects[prim.UUID] = new SceneObjectGroup(prim); - if (prim.KeyframeMotion != null) - prim.KeyframeMotion.UpdateSceneObject(objects[prim.UUID]); } } diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 70b76c9186..c35bba2965 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -732,11 +732,12 @@ namespace OpenSim.Data.SQLite } SceneObjectGroup group = new SceneObjectGroup(prim); - if (prim.KeyframeMotion != null) - prim.KeyframeMotion.UpdateSceneObject(group); + createdObjects.Add(group.UUID, group); retvals.Add(group); LoadItems(prim); + + } } catch (Exception e) diff --git a/OpenSim/Framework/Animation.cs b/OpenSim/Framework/Animation.cs index 8bdf8f4373..34255058ca 100644 --- a/OpenSim/Framework/Animation.cs +++ b/OpenSim/Framework/Animation.cs @@ -125,11 +125,10 @@ namespace OpenSim.Framework Animation other = obj as Animation; if (other != null) { - return (other.AnimID == this.AnimID + return (other.AnimID.Equals(this.AnimID) && other.SequenceNum == this.SequenceNum - && other.ObjectID == this.ObjectID); + && other.ObjectID.Equals(this.ObjectID) ); } - return base.Equals(obj); } diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index cfd34bb5b4..d189580677 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -121,12 +121,14 @@ namespace OpenSim.Framework.Servers + " level >= 2 then long warnings are logged when receiving bad input data.\n" + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" + " level >= 4 then the time taken to fulfill the request is logged.\n" - + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" - + " level >= 6 then the entire incoming data is logged.\n" + + " level >= 5 then a sample from the beginning of the data is logged.\n" + + " level >= 6 then the entire data is logged.\n" + " no level is specified then the current level is returned.\n\n" + "If out or all and\n" + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" - + " level >= 4 then the time taken to fulfill the request is logged.\n", + + " level >= 4 then the time taken to fulfill the request is logged.\n" + + " level >= 5 then a sample from the beginning of the data is logged.\n" + + " level >= 6 then the entire data is logged.\n", HandleDebugHttpCommand); } diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 701fbb0280..4599f62001 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -151,6 +151,39 @@ namespace OpenSim.Framework } } + public static void LogOutgoingDetail(Stream outputStream) + { + using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8)) + { + string output; + + if (DebugLevel == 5) + { + const int sampleLength = 80; + char[] sampleChars = new char[sampleLength]; + reader.Read(sampleChars, 0, sampleLength); + output = new string(sampleChars); + } + else + { + output = reader.ReadToEnd(); + } + + LogOutgoingDetail(output); + } + } + + public static void LogOutgoingDetail(string output) + { + if (DebugLevel == 5) + { + output = output.Substring(0, 80); + output = output + "..."; + } + + m_log.DebugFormat("[WEB UTIL]: {0}", output.Replace("\n", @"\n")); + } + private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) { int reqnum = RequestNumber++; @@ -178,7 +211,11 @@ namespace OpenSim.Framework // If there is some input, write it into the request if (data != null) { - strBuffer = OSDParser.SerializeJsonString(data); + strBuffer = OSDParser.SerializeJsonString(data); + + if (DebugLevel >= 5) + LogOutgoingDetail(strBuffer); + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); if (compressed) @@ -357,6 +394,10 @@ namespace OpenSim.Framework if (data != null) { queryString = BuildQueryString(data); + + if (DebugLevel >= 5) + LogOutgoingDetail(queryString); + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); request.ContentLength = buffer.Length; @@ -767,6 +808,9 @@ namespace OpenSim.Framework int length = (int)buffer.Length; request.ContentLength = length; + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(buffer); + request.BeginGetRequestStream(delegate(IAsyncResult res) { Stream requestStream = request.EndGetRequestStream(res); @@ -954,6 +998,9 @@ namespace OpenSim.Framework length = (int)obj.Length; request.ContentLength = length; + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(buffer); + Stream requestStream = null; try { @@ -1096,6 +1143,9 @@ namespace OpenSim.Framework int length = (int)buffer.Length; request.ContentLength = length; + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(buffer); + Stream requestStream = null; try { @@ -1198,4 +1248,4 @@ namespace OpenSim.Framework return deserial; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs index 7073433129..4f75191cf2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs @@ -42,7 +42,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests { [TestFixture] - public class AssetConnectorsTests : OpenSimTestCase + public class AssetConnectorTests : OpenSimTestCase { [Test] public void TestAddAsset() @@ -77,7 +77,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests // TODO: Add cache and check that this does receive a copy of the asset } - [Test] public void TestAddTemporaryAsset() { TestHelpers.InMethod(); @@ -93,34 +92,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); lasc.Initialise(config); - // If it is local, it should not be stored - AssetBase a1 = AssetHelpers.CreateNotecardAsset(); - a1.Local = true; - a1.Temporary = true; - - lasc.Store(a1); - - Assert.That(lasc.Get(a1.ID), Is.Null); - Assert.That(lasc.GetData(a1.ID), Is.Null); - Assert.That(lasc.GetMetadata(a1.ID), Is.Null); - // If it is remote, it should be stored - // AssetBase a2 = AssetHelpers.CreateNotecardAsset(); - // a2.Local = false; - // a2.Temporary = true; + AssetBase a2 = AssetHelpers.CreateNotecardAsset(); + a2.Local = false; + a2.Temporary = true; - // lasc.Store(a2); + lasc.Store(a2); - // AssetBase retreivedA2 = lasc.Get(a2.ID); - // Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID)); - // Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID)); - // Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length)); + AssetBase retreivedA2 = lasc.Get(a2.ID); + Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID)); + Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID)); + Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length)); - // AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID); - // Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID)); + AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID); + Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID)); - // byte[] retrievedA2Data = lasc.GetData(a2.ID); - // Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length)); + byte[] retrievedA2Data = lasc.GetData(a2.ID); + Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length)); // TODO: Add cache and check that this does receive a copy of the asset } @@ -152,5 +140,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests // TODO: Add cache and check that this does receive a copy of the asset } + + [Test] + public void TestAddTemporaryLocalAsset() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); + config.AddConfig("AssetService"); + config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); + config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); + + LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); + lasc.Initialise(config); + + // If it is local, it should not be stored + AssetBase a1 = AssetHelpers.CreateNotecardAsset(); + a1.Local = true; + a1.Temporary = true; + + lasc.Store(a1); + + Assert.That(lasc.Get(a1.ID), Is.Null); + Assert.That(lasc.GetData(a1.ID), Is.Null); + Assert.That(lasc.GetMetadata(a1.ID), Is.Null); + + // TODO: Add cache and check that this does receive a copy of the asset + } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 5dee64d0b5..b7400ea8ca 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -312,18 +312,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation buff.Append("dflt="); buff.Append(DefaultAnimation.ToString()); buff.Append(",iDflt="); - if (DefaultAnimation == ImplicitDefaultAnimation) + if (DefaultAnimation.Equals(ImplicitDefaultAnimation)) buff.Append("same"); else buff.Append(ImplicitDefaultAnimation.ToString()); if (m_animations.Count > 0) { buff.Append(",anims="); + bool firstTime = true; foreach (OpenSim.Framework.Animation anim in m_animations) { + if (!firstTime) + buff.Append(","); buff.Append("<"); buff.Append(anim.ToString()); - buff.Append(">,"); + buff.Append(">"); + firstTime = false; } } return buff.ToString(); diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index a701a79081..3b5a5bd6f2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -94,6 +94,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) { SendAnimPack(); + m_scenePresence.TriggerScenePresenceUpdated(); } } @@ -135,6 +136,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_animations.Remove(animID, allowNoDefault)) { SendAnimPack(); + m_scenePresence.TriggerScenePresenceUpdated(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index da80e4f627..7b5fdcb559 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -763,6 +763,11 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; + if (part.KeyframeMotion != null) + { + part.KeyframeMotion.UpdateSceneObject(this); + } + if (Object.ReferenceEquals(part, m_rootPart)) continue; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bab14dd3de..774546c693 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: Destructor called on {0}", Name); // } - private void TriggerScenePresenceUpdated() + public void TriggerScenePresenceUpdated() { if (m_scene != null) m_scene.EventManager.TriggerScenePresenceUpdated(this); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 202a4ce0ee..006a9c17f2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -168,10 +168,10 @@ public abstract class BSShape if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched) { prim.PrimAssetState = BSPhysObject.PrimAssetCondition.FailedMeshing; - physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}", - LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); - physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,setFailed,objNam={1},tex={2}", - prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture); + physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. prim={1}, texture={2}", + LogHeader, UsefulPrimInfo(physicsScene, prim), prim.BaseShape.SculptTexture); + physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,setFailed,prim={1},tex={2}", + prim.LocalID, UsefulPrimInfo(physicsScene, prim), prim.BaseShape.SculptTexture); } else { @@ -238,17 +238,17 @@ public abstract class BSShape { if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.FailedAssetFetch) { - physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}", - LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); - physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,wasFailed,objNam={1},tex={2}", - prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture); + physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. prim={1}, texture={2}", + LogHeader, UsefulPrimInfo(physicsScene, prim), prim.BaseShape.SculptTexture); + physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,wasFailed,prim={1},tex={2}", + prim.LocalID, UsefulPrimInfo(physicsScene, prim), prim.BaseShape.SculptTexture); } if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.FailedMeshing) { - physicsScene.Logger.WarnFormat("{0} Mesh asset would not mesh. obj={1}, texture={2}", - LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); - physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,wasFailedMeshing,objNam={1},tex={2}", - prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture); + physicsScene.Logger.WarnFormat("{0} Mesh asset would not mesh. prim={1}, texture={2}", + LogHeader, UsefulPrimInfo(physicsScene, prim), prim.BaseShape.SculptTexture); + physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,wasFailedMeshing,prim={1},tex={2}", + prim.LocalID, UsefulPrimInfo(physicsScene, prim), prim.BaseShape.SculptTexture); } } } @@ -260,6 +260,19 @@ public abstract class BSShape return fillShape.physShapeInfo; } + public static String UsefulPrimInfo(BSScene pScene, BSPhysObject prim) + { + StringBuilder buff = new StringBuilder(prim.PhysObjectName); + buff.Append("/pos="); + buff.Append(prim.RawPosition.ToString()); + if (pScene != null) + { + buff.Append("/rgn="); + buff.Append(pScene.Name); + } + return buff.ToString(); + } + #endregion // Common shape routines } @@ -528,8 +541,7 @@ public class BSShapeMesh : BSShape { // Force the asset condition to 'failed' so we won't try to keep fetching and processing this mesh. prim.PrimAssetState = BSPhysObject.PrimAssetCondition.FailedMeshing; - physicsScene.Logger.DebugFormat("{0} All mesh triangles degenerate. Prim {1} at {2} in {3}", - LogHeader, prim.PhysObjectName, prim.RawPosition, physicsScene.Name); + physicsScene.Logger.DebugFormat("{0} All mesh triangles degenerate. Prim={1}", LogHeader, UsefulPrimInfo(physicsScene, prim) ); physicsScene.DetailLog("{0},BSShapeMesh.CreatePhysicalMesh,allDegenerate,key={1}", prim.LocalID, newMeshKey); } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 1e015263da..4357ef15f6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -1,5 +1,9 @@ CURRENT PROBLEMS TO FIX AND/OR LOOK AT ================================================= +Vehicle buoyancy. Computed correctly? Possibly creating very large effective mass. + Interaction of llSetBuoyancy and vehicle buoyancy. Should be additive? + Negative buoyancy computed correctly +Computation of mesh mass. How done? How should it be done? Script changing rotation of child prim while vehicle moving (eg turning wheel) causes the wheel to appear to jump back. Looks like sending position from previous update. Enable vehicle border crossings (at least as poorly as ODE) diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 64127c20af..9d28dc3c6d 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -155,7 +155,7 @@ namespace OpenSim.Server.Handlers.Asset } catch (Exception e) { - m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace); + m_log.ErrorFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace); } return FailureResult(); diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 44f5e0180c..36d4ae25f0 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs @@ -84,6 +84,30 @@ namespace OpenSim.Services.Connectors m_ServerURI = serviceURI; } + private bool CheckReturn(Dictionary ret) + { + if (ret == null) + return false; + + if (ret.Count == 0) + return false; + + if (ret.ContainsKey("RESULT")) + { + if (ret["RESULT"] is string) + { + bool result; + + if (bool.TryParse((string)ret["RESULT"], out result)) + return result; + + return false; + } + } + + return true; + } + public bool CreateUserInventory(UUID principalID) { Dictionary ret = MakeRequest("CREATEUSERINVENTORY", @@ -91,12 +115,7 @@ namespace OpenSim.Services.Connectors { "PRINCIPAL", principalID.ToString() } }); - if (ret == null) - return false; - if (ret.Count == 0) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public List GetInventorySkeleton(UUID principalID) @@ -106,9 +125,7 @@ namespace OpenSim.Services.Connectors { "PRINCIPAL", principalID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; Dictionary folders = (Dictionary)ret["FOLDERS"]; @@ -135,9 +152,7 @@ namespace OpenSim.Services.Connectors { "PRINCIPAL", principalID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; return BuildFolder((Dictionary)ret["folder"]); @@ -151,9 +166,7 @@ namespace OpenSim.Services.Connectors { "TYPE", ((int)type).ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; return BuildFolder((Dictionary)ret["folder"]); @@ -174,9 +187,7 @@ namespace OpenSim.Services.Connectors { "FOLDER", folderID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; Dictionary folders = @@ -205,9 +216,7 @@ namespace OpenSim.Services.Connectors { "FOLDER", folderID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; Dictionary items = (Dictionary)ret["ITEMS"]; @@ -230,10 +239,7 @@ namespace OpenSim.Services.Connectors { "ID", folder.ID.ToString() } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool UpdateFolder(InventoryFolderBase folder) @@ -248,10 +254,7 @@ namespace OpenSim.Services.Connectors { "ID", folder.ID.ToString() } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool MoveFolder(InventoryFolderBase folder) @@ -263,10 +266,7 @@ namespace OpenSim.Services.Connectors { "PRINCIPAL", folder.Owner.ToString() } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool DeleteFolders(UUID principalID, List folderIDs) @@ -282,10 +282,7 @@ namespace OpenSim.Services.Connectors { "FOLDERS", slist } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool PurgeFolder(InventoryFolderBase folder) @@ -295,10 +292,7 @@ namespace OpenSim.Services.Connectors { "ID", folder.ID.ToString() } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool AddItem(InventoryItemBase item) @@ -330,10 +324,7 @@ namespace OpenSim.Services.Connectors { "CreationDate", item.CreationDate.ToString() } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool UpdateItem(InventoryItemBase item) @@ -365,10 +356,7 @@ namespace OpenSim.Services.Connectors { "CreationDate", item.CreationDate.ToString() } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool MoveItems(UUID principalID, List items) @@ -389,10 +377,7 @@ namespace OpenSim.Services.Connectors { "DESTLIST", destlist } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public bool DeleteItems(UUID principalID, List itemIDs) @@ -408,10 +393,7 @@ namespace OpenSim.Services.Connectors { "ITEMS", slist } }); - if (ret == null) - return false; - - return bool.Parse(ret["RESULT"].ToString()); + return CheckReturn(ret); } public InventoryItemBase GetItem(InventoryItemBase item) @@ -423,9 +405,7 @@ namespace OpenSim.Services.Connectors { "ID", item.ID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; return BuildItem((Dictionary)ret["item"]); @@ -447,9 +427,7 @@ namespace OpenSim.Services.Connectors { "ID", folder.ID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; return BuildFolder((Dictionary)ret["folder"]); @@ -469,7 +447,7 @@ namespace OpenSim.Services.Connectors { "PRINCIPAL", principalID.ToString() } }); - if (ret == null) + if (!CheckReturn(ret)) return null; List items = new List(); @@ -488,10 +466,22 @@ namespace OpenSim.Services.Connectors { "ASSET", assetID.ToString() } }); + // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int if (ret == null) return 0; - return int.Parse(ret["RESULT"].ToString()); + if (ret.ContainsKey("RESULT")) + { + if (ret["RESULT"] is string) + { + int intResult; + + if (int.TryParse ((string)ret["RESULT"], out intResult)) + return intResult; + } + } + + return 0; } public InventoryCollection GetUserInventory(UUID principalID) @@ -508,9 +498,7 @@ namespace OpenSim.Services.Connectors { "PRINCIPAL", principalID.ToString() } }); - if (ret == null) - return null; - if (ret.Count == 0) + if (!CheckReturn(ret)) return null; Dictionary folders = diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index eecf7579e5..410916f5c5 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -115,6 +115,12 @@ namespace OpenSim.Services.HypergridService { XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); + if (suitcase == null) + { + m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for inventory skeleton", principalID); + return null; + } + List tree = GetFolderTree(principalID, suitcase.folderID); if (tree == null || (tree != null && tree.Count == 0)) return null; @@ -134,6 +140,7 @@ namespace OpenSim.Services.HypergridService public override InventoryCollection GetUserInventory(UUID userID) { m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); + InventoryCollection userInventory = new InventoryCollection(); userInventory.UserID = userID; userInventory.Folders = new List(); @@ -141,6 +148,12 @@ namespace OpenSim.Services.HypergridService XInventoryFolder suitcase = GetSuitcaseXFolder(userID); + if (suitcase == null) + { + m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for user inventory", userID); + return null; + } + List tree = GetFolderTree(userID, suitcase.folderID); if (tree == null || (tree != null && tree.Count == 0)) { @@ -182,7 +195,8 @@ namespace OpenSim.Services.HypergridService m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); // Let's find out the local root folder - XInventoryFolder root = GetRootXFolder(principalID); ; + XInventoryFolder root = GetRootXFolder(principalID); + if (root == null) { m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); @@ -255,6 +269,13 @@ namespace OpenSim.Services.HypergridService { //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); + + if (suitcase == null) + { + m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for child type folder {1}", principalID, type); + return null; + } + XInventoryFolder[] folders = m_Database.GetFolders( new string[] { "agentID", "type", "parentFolderID" }, new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); @@ -546,6 +567,7 @@ namespace OpenSim.Services.HypergridService private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) { XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); + if (suitcase == null) { m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);