From 5a0fa4f34c41034e67a4d047425b8565a7393636 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 1 Dec 2008 17:49:52 +0000 Subject: * minor: fix log message printed when unrecognized elements are found in inventory rest input xml --- .../Rest/Inventory/RestAssetServices.cs | 2 - .../Rest/Inventory/RestInventoryServices.cs | 252 ++++++++++----------- 2 files changed, 119 insertions(+), 135 deletions(-) (limited to 'OpenSim/ApplicationPlugins') diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index 35c6de9..ba9e5b1 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs @@ -247,10 +247,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// The only parameter we recognize is a UUID. The enclosed asset data (base-64 encoded) /// is decoded and stored in the database, identified by the supplied UUID. /// - private void DoPut(AssetRequestData rdata) { - bool modified = false; bool created = false; diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index 9054569..dd4095d 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -121,7 +121,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// This property is declared locally because it is used a lot and /// brevity is nice. /// - internal string MsgId { get { return Rest.MsgId; } @@ -139,7 +138,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// Outbound HTTP request information /// REST service domain prefix /// A RequestData instance suitable for this service - private RequestData Allocate(OSHttpRequest request, OSHttpResponse response, string prefix) { return (RequestData) new InventoryRequestData(request, response, prefix); @@ -152,7 +150,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// It handles all aspects of inventory REST processing, i.e. /admin/inventory /// /// A consolidated HTTP request work area - private void DoInventory(RequestData hdata) { InventoryRequestData rdata = (InventoryRequestData) hdata; @@ -295,7 +292,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}", MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); - lock (rdata) { if (!rdata.HaveInventory) @@ -373,7 +369,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// corresponding subtree based upon node name. /// /// HTTP service request work area - private void DoGet(InventoryRequestData rdata) { rdata.initXmlWriter(); @@ -439,7 +434,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// context identified by the URI. /// /// HTTP service request work area - private void DoExtend(InventoryRequestData rdata) { bool created = false; @@ -480,7 +474,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // [3] A (possibly empty) set of assets. // If all of these are empty, then the POST is a harmless no-operation. - XmlInventoryCollection entity = ReconstituteEntity(rdata); + XmlInventoryCollection entity = ReconstituteEntity(rdata); // Inlined assets can be included in entity. These must be incorporated into // the asset database before we attempt to update the inventory. If anything @@ -667,7 +661,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// during the reconstitution process. /// /// HTTP service request work area - private void DoUpdate(InventoryRequestData rdata) { int count = 0; @@ -1303,7 +1296,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// HTTP service request work area /// The item to be formatted /// Pretty print indentation - private void formatItem(InventoryRequestData rdata, InventoryItemBase i, string indent) { Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}", @@ -1349,7 +1341,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// that required it cannot be completed, and it fails accordingly. /// /// HTTP service request work area - private InventoryFolderBase GetTrashCan(InventoryRequestData rdata) { InventoryFolderBase TrashCan = null; @@ -1394,7 +1385,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// /// Folder obtained from enclosed entity /// Folder obtained from the user's inventory - private bool FolderHasChanged(InventoryFolderBase newf, InventoryFolderBase oldf) { return (newf.Name != oldf.Name @@ -1411,7 +1401,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// /// Item obtained from enclosed entity /// Item obtained from the user's inventory - private bool ItemHasChanged(InventoryItemBase newf, InventoryItemBase oldf) { return (newf.Name != oldf.Name @@ -1449,7 +1438,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// missing parent IDs are resolved). /// /// HTTP service request work area - internal XmlInventoryCollection ReconstituteEntity(InventoryRequestData rdata) { Rest.Log.DebugFormat("{0} Reconstituting entity", MsgId); @@ -1468,78 +1456,80 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { switch (ic.xml.NodeType) { - case XmlNodeType.Element : - Rest.Log.DebugFormat("{0} StartElement: <{1}>", - MsgId, ic.xml.Name); - switch (ic.xml.Name) - { - case "Folder" : - Rest.Log.DebugFormat("{0} Processing {1} element", + case XmlNodeType.Element : + Rest.Log.DebugFormat("{0} StartElement: <{1}>", MsgId, ic.xml.Name); - CollectFolder(ic); + switch (ic.xml.Name) + { + case "Folder" : + Rest.Log.DebugFormat("{0} Processing {1} element", + MsgId, ic.xml.Name); + CollectFolder(ic); + break; + case "Item" : + Rest.Log.DebugFormat("{0} Processing {1} element", + MsgId, ic.xml.Name); + CollectItem(ic); + break; + case "Asset" : + Rest.Log.DebugFormat("{0} Processing {1} element", + MsgId, ic.xml.Name); + CollectAsset(ic); + break; + case "Permissions" : + Rest.Log.DebugFormat("{0} Processing {1} element", + MsgId, ic.xml.Name); + CollectPermissions(ic); + break; + default : + Rest.Log.DebugFormat("{0} Ignoring {1} element", + MsgId, ic.xml.Name); + break; + } + // This stinks, but the ReadElement call above not only reads + // the imbedded data, but also consumes the end tag for Asset + // and moves the element pointer on to the containing Item's + // element-end, however, if there was a permissions element + // following, it would get us to the start of that.. + if (ic.xml.NodeType == XmlNodeType.EndElement && + ic.xml.Name == "Item") + { + Validate(ic); + } break; - case "Item" : - Rest.Log.DebugFormat("{0} Processing {1} element", - MsgId, ic.xml.Name); - CollectItem(ic); - break; - case "Asset" : - Rest.Log.DebugFormat("{0} Processing {1} element", - MsgId, ic.xml.Name); - CollectAsset(ic); - break; - case "Permissions" : - Rest.Log.DebugFormat("{0} Processing {1} element", - MsgId, ic.xml.Name); - CollectPermissions(ic); + + case XmlNodeType.EndElement : + switch (ic.xml.Name) + { + case "Folder" : + Rest.Log.DebugFormat("{0} Completing {1} element", + MsgId, ic.xml.Name); + ic.Pop(); + break; + case "Item" : + Rest.Log.DebugFormat("{0} Completing {1} element", + MsgId, ic.xml.Name); + Validate(ic); + break; + case "Asset" : + Rest.Log.DebugFormat("{0} Completing {1} element", + MsgId, ic.xml.Name); + break; + case "Permissions" : + Rest.Log.DebugFormat("{0} Completing {1} element", + MsgId, ic.xml.Name); + break; + default : + Rest.Log.DebugFormat("{0} Ignoring {1} element", + MsgId, ic.xml.Name); + break; + } break; + default : - Rest.Log.DebugFormat("{0} Ignoring {1} element", - MsgId, ic.xml.Name); + Rest.Log.DebugFormat("{0} Ignoring: <{1}>:<{2}>", + MsgId, ic.xml.NodeType, ic.xml.Value); break; - } - // This stinks, but the ReadElement call above not only reads - // the imbedded data, but also consumes the end tag for Asset - // and moves the element pointer on to the containing Item's - // element-end, however, if there was a permissions element - // following, it would get us to the start of that.. - if (ic.xml.NodeType == XmlNodeType.EndElement && - ic.xml.Name == "Item") - { - Validate(ic); - } - break; - case XmlNodeType.EndElement : - switch (ic.xml.Name) - { - case "Folder" : - Rest.Log.DebugFormat("{0} Completing {1} element", - MsgId, ic.xml.Name); - ic.Pop(); - break; - case "Item" : - Rest.Log.DebugFormat("{0} Completing {1} element", - MsgId, ic.xml.Name); - Validate(ic); - break; - case "Asset" : - Rest.Log.DebugFormat("{0} Completing {1} element", - MsgId, ic.xml.Name); - break; - case "Permissions" : - Rest.Log.DebugFormat("{0} Completing {1} element", - MsgId, ic.xml.Name); - break; - default : - Rest.Log.DebugFormat("{0} Ignoring {1} element", - MsgId, ic.xml.Name); - break; - } - break; - default : - Rest.Log.DebugFormat("{0} [0] Ignoring: <{1}>:<2>", - MsgId, ic.xml.NodeType, ic.xml.Value); - break; } } } @@ -1688,7 +1678,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// All context is reset whenever the effective folder changes /// or an item is successfully validated. /// - private void CollectItem(XmlInventoryCollection ic) { Rest.Log.DebugFormat("{0} Interpret item element", MsgId); @@ -1715,55 +1704,55 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory switch (ic.xml.Name) { - case "name" : - result.Name = ic.xml.Value; - break; - case "desc" : - result.Description = ic.xml.Value; - break; - case "uuid" : - result.ID = new UUID(ic.xml.Value); - break; - case "folder" : - result.Folder = new UUID(ic.xml.Value); - break; - case "owner" : - result.Owner = new UUID(ic.xml.Value); - break; - case "invtype" : - result.InvType = Int32.Parse(ic.xml.Value); - break; - case "creator" : - result.Creator = new UUID(ic.xml.Value); - break; - case "assettype" : - result.AssetType = Int32.Parse(ic.xml.Value); - break; - case "groupowned" : - result.GroupOwned = Boolean.Parse(ic.xml.Value); - break; - case "groupid" : - result.GroupID = new UUID(ic.xml.Value); - break; - case "flags" : - result.Flags = UInt32.Parse(ic.xml.Value); - break; - case "creationdate" : - result.CreationDate = Int32.Parse(ic.xml.Value); - break; - case "saletype" : - result.SaleType = Byte.Parse(ic.xml.Value); - break; - case "saleprice" : - result.SalePrice = Int32.Parse(ic.xml.Value); - break; + case "name" : + result.Name = ic.xml.Value; + break; + case "desc" : + result.Description = ic.xml.Value; + break; + case "uuid" : + result.ID = new UUID(ic.xml.Value); + break; + case "folder" : + result.Folder = new UUID(ic.xml.Value); + break; + case "owner" : + result.Owner = new UUID(ic.xml.Value); + break; + case "invtype" : + result.InvType = Int32.Parse(ic.xml.Value); + break; + case "creator" : + result.Creator = new UUID(ic.xml.Value); + break; + case "assettype" : + result.AssetType = Int32.Parse(ic.xml.Value); + break; + case "groupowned" : + result.GroupOwned = Boolean.Parse(ic.xml.Value); + break; + case "groupid" : + result.GroupID = new UUID(ic.xml.Value); + break; + case "flags" : + result.Flags = UInt32.Parse(ic.xml.Value); + break; + case "creationdate" : + result.CreationDate = Int32.Parse(ic.xml.Value); + break; + case "saletype" : + result.SaleType = Byte.Parse(ic.xml.Value); + break; + case "saleprice" : + result.SalePrice = Int32.Parse(ic.xml.Value); + break; - default : - Rest.Log.DebugFormat("{0} Item: Unrecognized attribute: {1}:{2}", - MsgId, ic.xml.Name, ic.xml.Value); - ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute", - ic.xml.Name)); - break; + default : + Rest.Log.DebugFormat("{0} Item: Unrecognized attribute: {1}:{2}", + MsgId, ic.xml.Name, ic.xml.Value); + ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute", + ic.xml.Name)); + break; } } } @@ -1793,7 +1782,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// An asset, if created is stored in the /// XmlInventoryCollection /// - private void CollectAsset(XmlInventoryCollection ic) { Rest.Log.DebugFormat("{0} Interpret asset element", MsgId); @@ -1885,7 +1873,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { string b64string = null; - // Generate a UUID of none were given, and generally none should + // Generate a UUID if none were given, and generally none should // be. Ever. if (uuid == UUID.Zero) @@ -1927,7 +1915,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory } ic.Push(asset); - } /// @@ -1935,7 +1922,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// This overrides the default permissions set when the /// XmlInventoryCollection object was created. /// - private void CollectPermissions(XmlInventoryCollection ic) { if (ic.xml.HasAttributes) -- cgit v1.1