aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-12-01 18:09:04 +0000
committerJustin Clarke Casey2008-12-01 18:09:04 +0000
commit4699cd7957a8c26856ec1ac2de3003007bc26173 (patch)
treeca53d8d1dd67e39382e3fbf05d35cbc137136ca6 /OpenSim/ApplicationPlugins/Rest
parent* minor: fix log message printed when unrecognized elements are found in inve... (diff)
downloadopensim-SC-4699cd7957a8c26856ec1ac2de3003007bc26173.zip
opensim-SC-4699cd7957a8c26856ec1ac2de3003007bc26173.tar.gz
opensim-SC-4699cd7957a8c26856ec1ac2de3003007bc26173.tar.bz2
opensim-SC-4699cd7957a8c26856ec1ac2de3003007bc26173.tar.xz
* stop inventory item creation via REST falling over on any included assets that are not inline (UUID only)
* make rest inventory item xml output use 'invtype' for inventory type rather than just 'type'. This makes it symmetrical with input xml
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs186
1 files changed, 93 insertions, 93 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index dd4095d..11ae75f 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -1293,9 +1293,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1293 /// <summary> 1293 /// <summary>
1294 /// This method generates XML that describes an instance of InventoryItemBase. 1294 /// This method generates XML that describes an instance of InventoryItemBase.
1295 /// </summary> 1295 /// </summary>
1296 /// <param name=rdata>HTTP service request work area</param> 1296 /// <param name="rdata">HTTP service request work area</param>
1297 /// <param name=i>The item to be formatted</param> 1297 /// <param name="i">The item to be formatted</param>
1298 /// <param name=indent>Pretty print indentation</param> 1298 /// <param name="indent">Pretty print indentation</param>
1299 private void formatItem(InventoryRequestData rdata, InventoryItemBase i, string indent) 1299 private void formatItem(InventoryRequestData rdata, InventoryItemBase i, string indent)
1300 { 1300 {
1301 Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}", 1301 Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}",
@@ -1310,7 +1310,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1310 rdata.writer.WriteAttributeString("owner", String.Empty, i.Owner.ToString()); 1310 rdata.writer.WriteAttributeString("owner", String.Empty, i.Owner.ToString());
1311 rdata.writer.WriteAttributeString("creator", String.Empty, i.Creator.ToString()); 1311 rdata.writer.WriteAttributeString("creator", String.Empty, i.Creator.ToString());
1312 rdata.writer.WriteAttributeString("creationdate", String.Empty, i.CreationDate.ToString()); 1312 rdata.writer.WriteAttributeString("creationdate", String.Empty, i.CreationDate.ToString());
1313 rdata.writer.WriteAttributeString("type", String.Empty, i.InvType.ToString()); 1313 rdata.writer.WriteAttributeString("invtype", String.Empty, i.InvType.ToString());
1314 rdata.writer.WriteAttributeString("assettype", String.Empty, i.AssetType.ToString()); 1314 rdata.writer.WriteAttributeString("assettype", String.Empty, i.AssetType.ToString());
1315 rdata.writer.WriteAttributeString("groupowned", String.Empty, i.GroupOwned.ToString()); 1315 rdata.writer.WriteAttributeString("groupowned", String.Empty, i.GroupOwned.ToString());
1316 rdata.writer.WriteAttributeString("groupid", String.Empty, i.GroupID.ToString()); 1316 rdata.writer.WriteAttributeString("groupid", String.Empty, i.GroupID.ToString());
@@ -1456,36 +1456,38 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1456 { 1456 {
1457 switch (ic.xml.NodeType) 1457 switch (ic.xml.NodeType)
1458 { 1458 {
1459 case XmlNodeType.Element : 1459 case XmlNodeType.Element:
1460 Rest.Log.DebugFormat("{0} StartElement: <{1}>", 1460 Rest.Log.DebugFormat("{0} StartElement: <{1}>",
1461 MsgId, ic.xml.Name); 1461 MsgId, ic.xml.Name);
1462
1462 switch (ic.xml.Name) 1463 switch (ic.xml.Name)
1463 { 1464 {
1464 case "Folder" : 1465 case "Folder":
1465 Rest.Log.DebugFormat("{0} Processing {1} element", 1466 Rest.Log.DebugFormat("{0} Processing {1} element",
1466 MsgId, ic.xml.Name); 1467 MsgId, ic.xml.Name);
1467 CollectFolder(ic); 1468 CollectFolder(ic);
1468 break; 1469 break;
1469 case "Item" : 1470 case "Item":
1470 Rest.Log.DebugFormat("{0} Processing {1} element", 1471 Rest.Log.DebugFormat("{0} Processing {1} element",
1471 MsgId, ic.xml.Name); 1472 MsgId, ic.xml.Name);
1472 CollectItem(ic); 1473 CollectItem(ic);
1473 break; 1474 break;
1474 case "Asset" : 1475 case "Asset":
1475 Rest.Log.DebugFormat("{0} Processing {1} element", 1476 Rest.Log.DebugFormat("{0} Processing {1} element",
1476 MsgId, ic.xml.Name); 1477 MsgId, ic.xml.Name);
1477 CollectAsset(ic); 1478 CollectAsset(ic);
1478 break; 1479 break;
1479 case "Permissions" : 1480 case "Permissions":
1480 Rest.Log.DebugFormat("{0} Processing {1} element", 1481 Rest.Log.DebugFormat("{0} Processing {1} element",
1481 MsgId, ic.xml.Name); 1482 MsgId, ic.xml.Name);
1482 CollectPermissions(ic); 1483 CollectPermissions(ic);
1483 break; 1484 break;
1484 default : 1485 default:
1485 Rest.Log.DebugFormat("{0} Ignoring {1} element", 1486 Rest.Log.DebugFormat("{0} Ignoring {1} element",
1486 MsgId, ic.xml.Name); 1487 MsgId, ic.xml.Name);
1487 break; 1488 break;
1488 } 1489 }
1490
1489 // This stinks, but the ReadElement call above not only reads 1491 // This stinks, but the ReadElement call above not only reads
1490 // the imbedded data, but also consumes the end tag for Asset 1492 // the imbedded data, but also consumes the end tag for Asset
1491 // and moves the element pointer on to the containing Item's 1493 // and moves the element pointer on to the containing Item's
@@ -1501,32 +1503,32 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1501 case XmlNodeType.EndElement : 1503 case XmlNodeType.EndElement :
1502 switch (ic.xml.Name) 1504 switch (ic.xml.Name)
1503 { 1505 {
1504 case "Folder" : 1506 case "Folder":
1505 Rest.Log.DebugFormat("{0} Completing {1} element", 1507 Rest.Log.DebugFormat("{0} Completing {1} element",
1506 MsgId, ic.xml.Name); 1508 MsgId, ic.xml.Name);
1507 ic.Pop(); 1509 ic.Pop();
1508 break; 1510 break;
1509 case "Item" : 1511 case "Item":
1510 Rest.Log.DebugFormat("{0} Completing {1} element", 1512 Rest.Log.DebugFormat("{0} Completing {1} element",
1511 MsgId, ic.xml.Name); 1513 MsgId, ic.xml.Name);
1512 Validate(ic); 1514 Validate(ic);
1513 break; 1515 break;
1514 case "Asset" : 1516 case "Asset":
1515 Rest.Log.DebugFormat("{0} Completing {1} element", 1517 Rest.Log.DebugFormat("{0} Completing {1} element",
1516 MsgId, ic.xml.Name); 1518 MsgId, ic.xml.Name);
1517 break; 1519 break;
1518 case "Permissions" : 1520 case "Permissions":
1519 Rest.Log.DebugFormat("{0} Completing {1} element", 1521 Rest.Log.DebugFormat("{0} Completing {1} element",
1520 MsgId, ic.xml.Name); 1522 MsgId, ic.xml.Name);
1521 break; 1523 break;
1522 default : 1524 default:
1523 Rest.Log.DebugFormat("{0} Ignoring {1} element", 1525 Rest.Log.DebugFormat("{0} Ignoring {1} element",
1524 MsgId, ic.xml.Name); 1526 MsgId, ic.xml.Name);
1525 break; 1527 break;
1526 } 1528 }
1527 break; 1529 break;
1528 1530
1529 default : 1531 default:
1530 Rest.Log.DebugFormat("{0} Ignoring: <{1}>:<{2}>", 1532 Rest.Log.DebugFormat("{0} Ignoring: <{1}>:<{2}>",
1531 MsgId, ic.xml.NodeType, ic.xml.Value); 1533 MsgId, ic.xml.NodeType, ic.xml.Value);
1532 break; 1534 break;
@@ -1592,25 +1594,25 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1592 ic.xml.MoveToAttribute(i); 1594 ic.xml.MoveToAttribute(i);
1593 switch (ic.xml.Name) 1595 switch (ic.xml.Name)
1594 { 1596 {
1595 case "name" : 1597 case "name":
1596 result.Name = ic.xml.Value; 1598 result.Name = ic.xml.Value;
1597 break; 1599 break;
1598 case "uuid" : 1600 case "uuid":
1599 result.ID = new UUID(ic.xml.Value); 1601 result.ID = new UUID(ic.xml.Value);
1600 break; 1602 break;
1601 case "parent" : 1603 case "parent":
1602 result.ParentID = new UUID(ic.xml.Value); 1604 result.ParentID = new UUID(ic.xml.Value);
1603 break; 1605 break;
1604 case "owner" : 1606 case "owner":
1605 result.Owner = new UUID(ic.xml.Value); 1607 result.Owner = new UUID(ic.xml.Value);
1606 break; 1608 break;
1607 case "type" : 1609 case "type":
1608 result.Type = Int16.Parse(ic.xml.Value); 1610 result.Type = Int16.Parse(ic.xml.Value);
1609 break; 1611 break;
1610 case "version" : 1612 case "version":
1611 result.Version = UInt16.Parse(ic.xml.Value); 1613 result.Version = UInt16.Parse(ic.xml.Value);
1612 break; 1614 break;
1613 default : 1615 default:
1614 Rest.Log.DebugFormat("{0} Folder: unrecognized attribute: {1}:{2}", 1616 Rest.Log.DebugFormat("{0} Folder: unrecognized attribute: {1}:{2}",
1615 MsgId, ic.xml.Name, ic.xml.Value); 1617 MsgId, ic.xml.Name, ic.xml.Value);
1616 ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute <{0}>", 1618 ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute <{0}>",
@@ -1704,50 +1706,50 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1704 1706
1705 switch (ic.xml.Name) 1707 switch (ic.xml.Name)
1706 { 1708 {
1707 case "name" : 1709 case "name":
1708 result.Name = ic.xml.Value; 1710 result.Name = ic.xml.Value;
1709 break; 1711 break;
1710 case "desc" : 1712 case "desc":
1711 result.Description = ic.xml.Value; 1713 result.Description = ic.xml.Value;
1712 break; 1714 break;
1713 case "uuid" : 1715 case "uuid":
1714 result.ID = new UUID(ic.xml.Value); 1716 result.ID = new UUID(ic.xml.Value);
1715 break; 1717 break;
1716 case "folder" : 1718 case "folder":
1717 result.Folder = new UUID(ic.xml.Value); 1719 result.Folder = new UUID(ic.xml.Value);
1718 break; 1720 break;
1719 case "owner" : 1721 case "owner":
1720 result.Owner = new UUID(ic.xml.Value); 1722 result.Owner = new UUID(ic.xml.Value);
1721 break; 1723 break;
1722 case "invtype" : 1724 case "invtype":
1723 result.InvType = Int32.Parse(ic.xml.Value); 1725 result.InvType = Int32.Parse(ic.xml.Value);
1724 break; 1726 break;
1725 case "creator" : 1727 case "creator":
1726 result.Creator = new UUID(ic.xml.Value); 1728 result.Creator = new UUID(ic.xml.Value);
1727 break; 1729 break;
1728 case "assettype" : 1730 case "assettype":
1729 result.AssetType = Int32.Parse(ic.xml.Value); 1731 result.AssetType = Int32.Parse(ic.xml.Value);
1730 break; 1732 break;
1731 case "groupowned" : 1733 case "groupowned":
1732 result.GroupOwned = Boolean.Parse(ic.xml.Value); 1734 result.GroupOwned = Boolean.Parse(ic.xml.Value);
1733 break; 1735 break;
1734 case "groupid" : 1736 case "groupid":
1735 result.GroupID = new UUID(ic.xml.Value); 1737 result.GroupID = new UUID(ic.xml.Value);
1736 break; 1738 break;
1737 case "flags" : 1739 case "flags":
1738 result.Flags = UInt32.Parse(ic.xml.Value); 1740 result.Flags = UInt32.Parse(ic.xml.Value);
1739 break; 1741 break;
1740 case "creationdate" : 1742 case "creationdate":
1741 result.CreationDate = Int32.Parse(ic.xml.Value); 1743 result.CreationDate = Int32.Parse(ic.xml.Value);
1742 break; 1744 break;
1743 case "saletype" : 1745 case "saletype":
1744 result.SaleType = Byte.Parse(ic.xml.Value); 1746 result.SaleType = Byte.Parse(ic.xml.Value);
1745 break; 1747 break;
1746 case "saleprice" : 1748 case "saleprice":
1747 result.SalePrice = Int32.Parse(ic.xml.Value); 1749 result.SalePrice = Int32.Parse(ic.xml.Value);
1748 break; 1750 break;
1749 1751
1750 default : 1752 default:
1751 Rest.Log.DebugFormat("{0} Item: Unrecognized attribute: {1}:{2}", 1753 Rest.Log.DebugFormat("{0} Item: Unrecognized attribute: {1}:{2}",
1752 MsgId, ic.xml.Name, ic.xml.Value); 1754 MsgId, ic.xml.Name, ic.xml.Value);
1753 ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute", 1755 ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute",
@@ -1786,8 +1788,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1786 { 1788 {
1787 Rest.Log.DebugFormat("{0} Interpret asset element", MsgId); 1789 Rest.Log.DebugFormat("{0} Interpret asset element", MsgId);
1788 1790
1789 AssetBase asset = null;
1790
1791 string name = String.Empty; 1791 string name = String.Empty;
1792 string desc = String.Empty; 1792 string desc = String.Empty;
1793 sbyte type = (sbyte) AssetType.Unknown; 1793 sbyte type = (sbyte) AssetType.Unknown;
@@ -1807,41 +1807,40 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1807 ic.xml.MoveToAttribute(i); 1807 ic.xml.MoveToAttribute(i);
1808 switch (ic.xml.Name) 1808 switch (ic.xml.Name)
1809 { 1809 {
1810 case "name" :
1811 name = ic.xml.Value;
1812 break;
1810 1813
1811 case "name" : 1814 case "type" :
1812 name = ic.xml.Value; 1815 type = SByte.Parse(ic.xml.Value);
1813 break; 1816 break;
1814
1815 case "type" :
1816 type = SByte.Parse(ic.xml.Value);
1817 break;
1818 1817
1819 case "description" : 1818 case "description" :
1820 desc = ic.xml.Value; 1819 desc = ic.xml.Value;
1821 break; 1820 break;
1822 1821
1823 case "temporary" : 1822 case "temporary" :
1824 temp = Boolean.Parse(ic.xml.Value); 1823 temp = Boolean.Parse(ic.xml.Value);
1825 break; 1824 break;
1826 1825
1827 case "uuid" : 1826 case "uuid" :
1828 uuid = new UUID(ic.xml.Value); 1827 uuid = new UUID(ic.xml.Value);
1829 break; 1828 break;
1830 1829
1831 case "inline" : 1830 case "inline" :
1832 inline = Boolean.Parse(ic.xml.Value); 1831 inline = Boolean.Parse(ic.xml.Value);
1833 break; 1832 break;
1834 1833
1835 case "local" : 1834 case "local" :
1836 local = Boolean.Parse(ic.xml.Value); 1835 local = Boolean.Parse(ic.xml.Value);
1837 break; 1836 break;
1838 1837
1839 default : 1838 default :
1840 Rest.Log.DebugFormat("{0} Asset: Unrecognized attribute: {1}:{2}", 1839 Rest.Log.DebugFormat("{0} Asset: Unrecognized attribute: {1}:{2}",
1841 MsgId, ic.xml.Name, ic.xml.Value); 1840 MsgId, ic.xml.Name, ic.xml.Value);
1842 ic.Fail(Rest.HttpStatusCodeBadRequest, 1841 ic.Fail(Rest.HttpStatusCodeBadRequest,
1843 String.Format("unrecognized attribute <{0}>", ic.xml.Name)); 1842 String.Format("unrecognized attribute <{0}>", ic.xml.Name));
1844 break; 1843 break;
1845 } 1844 }
1846 } 1845 }
1847 } 1846 }
@@ -1870,7 +1869,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1870 // only if the size is non-zero. 1869 // only if the size is non-zero.
1871 1870
1872 else 1871 else
1873 { 1872 {
1873 AssetBase asset = null;
1874 string b64string = null; 1874 string b64string = null;
1875 1875
1876 // Generate a UUID if none were given, and generally none should 1876 // Generate a UUID if none were given, and generally none should
@@ -1912,9 +1912,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1912 { 1912 {
1913 ic.Item.AssetID = uuid; 1913 ic.Item.AssetID = uuid;
1914 } 1914 }
1915
1916 ic.Push(asset);
1915 } 1917 }
1916
1917 ic.Push(asset);
1918 } 1918 }
1919 1919
1920 /// <summary> 1920 /// <summary>
@@ -1931,27 +1931,27 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1931 ic.xml.MoveToAttribute(i); 1931 ic.xml.MoveToAttribute(i);
1932 switch (ic.xml.Name) 1932 switch (ic.xml.Name)
1933 { 1933 {
1934 case "current" : 1934 case "current":
1935 ic.CurrentPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); 1935 ic.CurrentPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
1936 break; 1936 break;
1937 case "next" : 1937 case "next":
1938 ic.NextPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); 1938 ic.NextPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
1939 break; 1939 break;
1940 case "group" : 1940 case "group":
1941 ic.GroupPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); 1941 ic.GroupPermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
1942 break; 1942 break;
1943 case "everyone" : 1943 case "everyone":
1944 ic.EveryOnePermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); 1944 ic.EveryOnePermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
1945 break; 1945 break;
1946 case "base" : 1946 case "base":
1947 ic.BasePermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber); 1947 ic.BasePermissions = UInt32.Parse(ic.xml.Value, System.Globalization.NumberStyles.HexNumber);
1948 break; 1948 break;
1949 default : 1949 default:
1950 Rest.Log.DebugFormat("{0} Permissions: invalid attribute {1}:{2}", 1950 Rest.Log.DebugFormat("{0} Permissions: invalid attribute {1}:{2}",
1951 MsgId,ic.xml.Name, ic.xml.Value); 1951 MsgId,ic.xml.Name, ic.xml.Value);
1952 ic.Fail(Rest.HttpStatusCodeBadRequest, 1952 ic.Fail(Rest.HttpStatusCodeBadRequest,
1953 String.Format("invalid attribute <{0}>", ic.xml.Name)); 1953 String.Format("invalid attribute <{0}>", ic.xml.Name));
1954 break; 1954 break;
1955 } 1955 }
1956 } 1956 }
1957 } 1957 }
@@ -2152,7 +2152,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
2152 /// extensions. 2152 /// extensions.
2153 /// </summary> 2153 /// </summary>
2154 2154
2155 internal UUID uuid = UUID.Zero; 2155 internal UUID uuid = UUID.Zero;
2156 internal bool HaveInventory = false; 2156 internal bool HaveInventory = false;
2157 internal ICollection<InventoryFolderImpl> folders = null; 2157 internal ICollection<InventoryFolderImpl> folders = null;
2158 internal ICollection<InventoryItemBase> items = null; 2158 internal ICollection<InventoryItemBase> items = null;